Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration and classes for the Eitr Refinery #770

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,5 @@ Please see [CONTRIBUTING.md](/CONTRIBUTING.md) for details on compiling V+ for d
* An 'Hachidan' N. - https://github.com/ahnguyen09
* Abra - https://github.com/Abrackadabra
* Increddibelly - https://github.com/increddibelly
* Radvo - https://github.com/Radvo
* Radvo - https://github.com/Radvo
* Shawn - https://github.com/shawnwallace
1 change: 1 addition & 0 deletions ValheimPlus/Configurations/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Configuration
public KilnConfiguration Kiln { get; set; }
public WindmillConfiguration Windmill { get; set; }
public SpinningWheelConfiguration SpinningWheel { get; set; }
public EitrRefineryConfiguration EitrRefinery { get; set; }
public MapConfiguration Map { get; set; }
public PlayerConfiguration Player { get; set; }
public ServerConfiguration Server { get; set; }
Expand Down
19 changes: 19 additions & 0 deletions ValheimPlus/Configurations/Sections/EitrRefineryConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace ValheimPlus.Configurations.Sections
{
public class EitrRefineryConfiguration : ServerSyncConfig<EitrRefineryConfiguration>
{
public int maximumSap { get; internal set; } = 20;

public int maximumSoftTissue { get; internal set; } = 20;

public float productionSpeed { get; internal set; } = 40;

public bool autoDeposit { get; internal set; } = false;

public bool autoFuel { get; internal set; } = false;

public bool ignorePrivateAreaCheck { get; internal set; } = true;

public float autoRange { get; internal set; } = 10;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class SpinningWheelConfiguration : ServerSyncConfig<SpinningWheelConfigur
{
public int maximumFlax { get; internal set; } = 50;
public float productionSpeed { get; internal set; } = 30;
public bool autoDeposit { get; internal set; } = true;
public bool autoFuel { get; internal set; } = true;
public bool autoDeposit { get; internal set; } = false;
public bool autoFuel { get; internal set; } = false;
public bool ignorePrivateAreaCheck { get; internal set; } = true;
public float autoRange { get; internal set; } = 10;
}
Expand Down
20 changes: 19 additions & 1 deletion ValheimPlus/GameClasses/Smelter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ private static void Prefix(ref Smelter __instance)
__instance.m_maxOre = Configuration.Current.SpinningWheel.maximumFlax;
__instance.m_secPerProduct = Configuration.Current.SpinningWheel.productionSpeed;
}
else if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName) && Configuration.Current.EitrRefinery.IsEnabled)
{
__instance.m_maxOre = Configuration.Current.EitrRefinery.maximumSap;
__instance.m_maxFuel = Configuration.Current.EitrRefinery.maximumSoftTissue;
__instance.m_secPerProduct = Configuration.Current.EitrRefinery.productionSpeed;
}
}

}
Expand Down Expand Up @@ -82,7 +88,11 @@ private static bool Prefix(string ore, int stack, ref Smelter __instance)
}
if (__instance.m_name.Equals(SmelterDefinitions.SpinningWheelName) && Configuration.Current.SpinningWheel.IsEnabled && Configuration.Current.SpinningWheel.autoDeposit)
{
return spawn(Helper.Clamp(Configuration.Current.SpinningWheel.autoRange, 1, 50), Configuration.Current.Windmill.ignorePrivateAreaCheck);
return spawn(Helper.Clamp(Configuration.Current.SpinningWheel.autoRange, 1, 50), Configuration.Current.SpinningWheel.ignorePrivateAreaCheck);
}
if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName) && Configuration.Current.EitrRefinery.IsEnabled && Configuration.Current.EitrRefinery.autoDeposit)
{
return spawn(Helper.Clamp(Configuration.Current.EitrRefinery.autoRange, 1, 50), Configuration.Current.EitrRefinery.ignorePrivateAreaCheck);
}
bool spawn(float autoDepositRange, bool ignorePrivateAreaCheck)
{
Expand Down Expand Up @@ -196,6 +206,13 @@ static void Prefix(Smelter __instance)
autoFuelRange = Configuration.Current.SpinningWheel.autoRange;
ignorePrivateAreaCheck = Configuration.Current.SpinningWheel.ignorePrivateAreaCheck;
}
else if (__instance.m_name.Equals(SmelterDefinitions.EitrRefineryName))
{
if (!Configuration.Current.EitrRefinery.IsEnabled || !Configuration.Current.EitrRefinery.autoFuel)
return;
autoFuelRange = Configuration.Current.EitrRefinery.autoRange;
ignorePrivateAreaCheck = Configuration.Current.EitrRefinery.ignorePrivateAreaCheck;
}

autoFuelRange = Helper.Clamp(autoFuelRange, 1, 50);

Expand Down Expand Up @@ -345,6 +362,7 @@ public static class SmelterDefinitions
public static readonly string FurnaceName = "$piece_blastfurnace";
public static readonly string WindmillName = "$piece_windmill";
public static readonly string SpinningWheelName = "$piece_spinningwheel";
public static readonly string EitrRefineryName = "$piece_eitrrefinery";
}

public static class FurnaceDefinitions
Expand Down
3 changes: 2 additions & 1 deletion ValheimPlus/ValheimPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard" />
<Reference Include="netstandard" />
<Reference Include="0Harmony, Version=2.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HarmonyX.2.10.0\lib\net45\0Harmony.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -343,6 +343,7 @@
<Compile Include="Configurations\Sections\BedConfiguration.cs" />
<Compile Include="Configurations\Sections\BrightnessConfiguration.cs" />
<Compile Include="Configurations\Sections\ChatConfiguration.cs" />
<Compile Include="Configurations\Sections\EitrRefineryConfiguration.cs" />
<Compile Include="Configurations\Sections\GameClockConfiguration.cs" />
<Compile Include="Configurations\Sections\MonsterProjectileConfiguration.cs" />
<Compile Include="Configurations\Sections\PlayerProjectileConfiguration.cs" />
Expand Down
29 changes: 29 additions & 0 deletions valheim_plus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,35 @@ ignorePrivateAreaCheck=true
autoRange=10


[EitrRefinery]

; Change false to true to enable this section. https://valheim.plus/documentation/list#EitrRefinery
enabled = false

; Maximum amount of sap in an Eitr Refinery.
maximumSap = 20

; Maximum amount of soft tissue in an Eitr Refinery.
maximumSoftTissue = 20

; The time it takes for the Eitr Refinery to produce a single eitr in seconds.
productionSpeed = 40

; Instead of dropping the items, they will be placed inside the nearest nearby chests.
autoDeposit = true

; The Eitr Refinery will pull sap and soft tissue from nearby chests to be automatically added to it when it's empty.
autoFuel = true

; This option prevents the Eitr Refinery to pull items from warded areas if it isn't placed inside of it.
; For convenience, we recommend this to be set to true.
ignorePrivateAreaCheck = true

; The range of the chest detection for the auto deposit and auto fuel features.
; Maximum is 50
autoRange = 5


[PlayerProjectile]

; Change false to true to enable this section. https://valheim.plus/documentation/list#PlayerProjectile
Expand Down