Skip to content

Commit

Permalink
Added StandingBlueBrazier and IronFirePit
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
Digitalroot committed Jun 1, 2024
1 parent 7eda989 commit 5589836
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 60 deletions.
2 changes: 2 additions & 0 deletions src/Digitalroot.Valheim.EternalFire.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=nview/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Digitalroot.Valheim.Common.Log" Version="1.1.53" />
<PackageReference Include="Digitalroot.Valheim.Common.Names" Version="1.4.31">
<PackageReference Include="Digitalroot.Valheim.Common.Names" Version="1.4.32">
<IncludeAssets></IncludeAssets>
</PackageReference>
<PackageReference Include="Digitalroot.Valheim.Common.References" Version="0.218.15">
Expand Down
84 changes: 48 additions & 36 deletions src/Digitalroot.Valheim.EternalFire/Main.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BepInEx;
using BepInEx.Configuration;
using Digitalroot.Valheim.Common;
using Digitalroot.Valheim.Common.Names;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Utils;
Expand All @@ -22,9 +23,9 @@ public partial class Main : BaseUnityPlugin, ITraceableLogging
public static Main Instance;

// [UsedImplicitly] public static ConfigEntry<int> NexusId;
private readonly Harmony harmony = new Harmony(Guid);
public static ConfigEntry<int> NexusId { get; private set; }
private static ConfigEntry<bool> config_fire_pit;
private static ConfigEntry<bool> config_iron_fire_pit;
private static ConfigEntry<bool> config_bonfire;
private static ConfigEntry<bool> config_hearth;
private static ConfigEntry<bool> config_piece_walltorch;
Expand All @@ -33,6 +34,7 @@ public partial class Main : BaseUnityPlugin, ITraceableLogging
private static ConfigEntry<bool> config_piece_groundtorch_green;
private static ConfigEntry<bool> config_piece_groundtorch_blue;
private static ConfigEntry<bool> config_piece_brazierfloor01;
private static ConfigEntry<bool> config_piece_brazierfloor02;
private static ConfigEntry<bool> config_piece_brazierceiling01;
private static ConfigEntry<bool> config_piece_jackoturnip;
private static ConfigEntry<bool> config_piece_oven;
Expand Down Expand Up @@ -60,24 +62,26 @@ private void Awake()
try
{
Log.Trace(Instance, $"{Namespace}.{MethodBase.GetCurrentMethod()?.DeclaringType?.Name}.{MethodBase.GetCurrentMethod()?.Name}");
NexusId = Config.Bind("General", "NexusID", 0000, new ConfigDescription("Nexus mod ID for updates", null, new ConfigurationManagerAttributes { Browsable = false, ReadOnly = true }));
config_fire_pit = Config.Bind<bool>("Fireplaces", "CampFire", true, "Enable Campfire");
config_bonfire = Config.Bind<bool>("Fireplaces", "Bonfire", true, "Enable Bonfire");
config_piece_walltorch = Config.Bind<bool>("Fireplaces", "Sconce", true, "Enable Sconce");
config_piece_groundtorch = Config.Bind<bool>("Fireplaces", "StandingIronTorch", true, "Enable Standing Iron Torch");
config_piece_groundtorch_wood = Config.Bind<bool>("Fireplaces", "StandingWoodTorch", true, "Enable Standing Wood Torch");
config_piece_groundtorch_green = Config.Bind<bool>("Fireplaces", "StandingGreenBurningIronTorch", true, "Enable Standing Green Burning Iron Torch");
config_piece_groundtorch_blue = Config.Bind<bool>("Fireplaces", "StandingBlueBurningIronTorch", true, "Enable Standing Blue Burning Iron Torch");
config_piece_brazierfloor01 = Config.Bind<bool>("Fireplaces", "StandingBrazier", true, "Enable Standing Brazier");
config_piece_brazierceiling01 = Config.Bind<bool>("Fireplaces", "HangingBrazier", true, "Enable Hanging Brazier");
config_piece_jackoturnip = Config.Bind<bool>("Fireplaces", "JackOTurnip", true, "Enable Jack-o-turnip");
config_hearth = Config.Bind<bool>("Fireplaces", "Hearth", true, "Enable Hearth");
config_piece_bathtub = Config.Bind<bool>("Fireplaces", "HotTub", true, "Enable Hot tub");
config_piece_oven = Config.Bind<bool>("CookingStations", "StoneOven", true, "Enable Stone oven");
config_smelter = Config.Bind<bool>("Smelters", "Smelter", false, "Enable Smelter");
config_blastfurnace = Config.Bind<bool>("Smelters", "BlastFurnace", false, "Enable Blast furnace");
config_eitrrefinery = Config.Bind<bool>("Smelters", "EitrRefinery", false, "Enable Eitr refinery");
config_custom_instance = Config.Bind<string>("Custom", "CustomPrefabs", "", "A comma-separated list of prefab names");
NexusId = Config.Bind(PluginConfigSection.General, "NexusID", 2754, new ConfigDescription("Nexus mod ID for updates", null, new ConfigurationManagerAttributes { Browsable = false, ReadOnly = true }));
config_fire_pit = Config.Bind<bool>(PluginConfigSection.Fireplaces, "CampFire", true, "Enable Campfire");
config_iron_fire_pit = Config.Bind<bool>(PluginConfigSection.Fireplaces, "IronFirePit", true, "Enable Iron Fire Pit");
config_bonfire = Config.Bind<bool>(PluginConfigSection.Fireplaces, "Bonfire", true, "Enable Bonfire");
config_piece_walltorch = Config.Bind<bool>(PluginConfigSection.Fireplaces, "Sconce", true, "Enable Sconce");
config_piece_groundtorch = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingIronTorch", true, "Enable Standing Iron Torch");
config_piece_groundtorch_wood = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingWoodTorch", true, "Enable Standing Wood Torch");
config_piece_groundtorch_green = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingGreenBurningIronTorch", true, "Enable Standing Green Burning Iron Torch");
config_piece_groundtorch_blue = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingBlueBurningIronTorch", true, "Enable Standing Blue Burning Iron Torch");
config_piece_brazierfloor01 = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingBrazier", true, "Enable Standing Brazier");
config_piece_brazierfloor02 = Config.Bind<bool>(PluginConfigSection.Fireplaces, "StandingBlueBrazier", true, "Enable Standing Blue Brazier");
config_piece_brazierceiling01 = Config.Bind<bool>(PluginConfigSection.Fireplaces, "HangingBrazier", true, "Enable Hanging Brazier");
config_piece_jackoturnip = Config.Bind<bool>(PluginConfigSection.Fireplaces, "JackOTurnip", true, "Enable Jack-o-Turnip");
config_hearth = Config.Bind<bool>(PluginConfigSection.Fireplaces, "Hearth", true, "Enable Hearth");
config_piece_bathtub = Config.Bind<bool>(PluginConfigSection.Fireplaces, "HotTub", true, "Enable Hot Tub");
config_piece_oven = Config.Bind<bool>(PluginConfigSection.CookingStations, "StoneOven", true, "Enable Stone Oven");
config_smelter = Config.Bind<bool>(PluginConfigSection.Smelters, "Smelter", false, "Enable Smelter");
config_blastfurnace = Config.Bind<bool>(PluginConfigSection.Smelters, "BlastFurnace", false, "Enable Blast Furnace");
config_eitrrefinery = Config.Bind<bool>(PluginConfigSection.Smelters, "EitrRefinery", false, "Enable Eitr Refinery");
config_custom_instance = Config.Bind<string>(PluginConfigSection.Custom, "CustomPrefabs", "", "A comma-separated list of prefab names");

_harmony = Harmony.CreateAndPatchAll(typeof(Main).Assembly, Guid);
}
Expand Down Expand Up @@ -110,69 +114,77 @@ public static async void Refuel(ZNetView znview)
public static bool ConfigCheck(string instanceName)
{
bool EternalFuel = false;
switch (instanceName)
switch (instanceName.Replace("(Clone)", string.Empty))
{
case "fire_pit(Clone)":
case Common.Names.Vanilla.PrefabNames.FirePit:
EternalFuel = config_fire_pit.Value;
break;

case "bonfire(Clone)":
case Common.Names.Vanilla.PrefabNames.FirePitIron:
EternalFuel = config_iron_fire_pit.Value;
break;

case Common.Names.Vanilla.PrefabNames.Bonfire:
EternalFuel = config_bonfire.Value;
break;

case "hearth(Clone)":
case Common.Names.Vanilla.PrefabNames.Hearth:
EternalFuel = config_hearth.Value;
break;

case "piece_walltorch(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceWalltorch:
EternalFuel = config_piece_walltorch.Value;
break;

case "piece_groundtorch(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceGroundtorch:
EternalFuel = config_piece_groundtorch.Value;
break;

case "piece_groundtorch_wood(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceGroundtorchWood:
EternalFuel = config_piece_groundtorch_wood.Value;
break;

case "piece_groundtorch_green(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceGroundtorchGreen:
EternalFuel = config_piece_groundtorch_green.Value;
break;

case "piece_groundtorch_blue(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceGroundtorchBlue:
EternalFuel = config_piece_groundtorch_blue.Value;
break;

case "piece_brazierfloor01(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceBrazierfloor01:
EternalFuel = config_piece_brazierfloor01.Value;
break;

case "piece_brazierceiling01(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceBrazierfloor02:
EternalFuel = config_piece_brazierfloor02.Value;
break;

case Common.Names.Vanilla.PrefabNames.PieceBrazierceiling01:
EternalFuel = config_piece_brazierceiling01.Value;
break;

case "piece_jackoturnip(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceJackoturnip:
EternalFuel = config_piece_jackoturnip.Value;
break;

case "piece_oven(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceOven:
EternalFuel = config_piece_oven.Value;
break;

case "smelter(Clone)":
case Common.Names.Vanilla.PrefabNames.Smelter:
EternalFuel = config_smelter.Value;
break;

case "blastfurnace(Clone)":
case Common.Names.Vanilla.PrefabNames.Blastfurnace:
EternalFuel = config_blastfurnace.Value;
break;

case "eitrrefinery(Clone)":
case Common.Names.Vanilla.PrefabNames.Eitrrefinery:
EternalFuel = config_eitrrefinery.Value;
break;

case "piece_bathtub(Clone)":
case Common.Names.Vanilla.PrefabNames.PieceBathtub:
EternalFuel = config_piece_bathtub.Value;
break;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Digitalroot.Valheim.EternalFire/MetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@ public partial class Main
public const string Name = "Eternal Fire";
public const string Guid = "digitalroot.mods.eternalfire";
public const string Namespace = "Digitalroot.Valheim" + nameof(EternalFire);

internal static class PluginConfigSection
{
internal static string General = nameof(General);
internal static string Fireplaces = nameof(Fireplaces);
internal static string CookingStations = nameof(CookingStations);
internal static string Smelters = nameof(Smelters);
internal static string Custom = nameof(Custom);
}
}
}
12 changes: 7 additions & 5 deletions src/Digitalroot.Valheim.EternalFire/Patch.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using HarmonyLib;
using JetBrains.Annotations;
using System.Diagnostics.CodeAnalysis;

namespace Digitalroot.Valheim.EternalFire
{
[UsedImplicitly]
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class Patch
{
[HarmonyPatch]
public class PatchFireplaceUpdateFireplace
{
[HarmonyPrefix, HarmonyPatch(typeof(Fireplace), nameof(Fireplace.UpdateFireplace))]
static void Prefix(ref Fireplace __instance, ref ZNetView ___m_nview)
private static void Prefix(ref Fireplace __instance, ref ZNetView ___m_nview)
{
if (Main.ConfigCheck(__instance.name)) ___m_nview.GetZDO().Set("fuel", __instance.m_maxFuel);
}
Expand All @@ -22,7 +24,7 @@ static void Prefix(ref Fireplace __instance, ref ZNetView ___m_nview)
public class PatchCookingStationSetFuel
{
[HarmonyPrefix, HarmonyPatch(typeof(CookingStation), nameof(CookingStation.SetFuel))]
static void Prefix(ref CookingStation __instance, ref float fuel)
private static void Prefix(ref CookingStation __instance, ref float fuel)
{
if (Main.ConfigCheck(__instance.name)) fuel = __instance.m_maxFuel;
}
Expand All @@ -32,7 +34,7 @@ static void Prefix(ref CookingStation __instance, ref float fuel)
public class PatchCookingStationAwake
{
[HarmonyPostfix, HarmonyPatch(typeof(CookingStation), nameof(CookingStation.Awake))]
static void Postfix(ref CookingStation __instance, ref ZNetView ___m_nview)
private static void Postfix(ref CookingStation __instance, ref ZNetView ___m_nview)
{
if (!___m_nview.isActiveAndEnabled || Player.m_localPlayer == null || Player.m_localPlayer.IsTeleporting()) return;
if (Main.ConfigCheck(__instance.name)) Main.Refuel(___m_nview);
Expand All @@ -47,7 +49,7 @@ static void Postfix(ref CookingStation __instance, ref ZNetView ___m_nview)
public class PatchSmelterSetFuel
{
[HarmonyPrefix, HarmonyPatch(typeof(Smelter), nameof(Smelter.SetFuel))]
static void Prefix(ref Smelter __instance, ref float fuel)
private static void Prefix(ref Smelter __instance, ref float fuel)
{
if (Main.ConfigCheck(__instance.name)) fuel = __instance.m_maxFuel;
}
Expand All @@ -57,7 +59,7 @@ static void Prefix(ref Smelter __instance, ref float fuel)
public class PatchSmelterAwake
{
[HarmonyPostfix, HarmonyPatch(typeof(Smelter), nameof(Smelter.Awake))]
static void Postfix(ref Smelter __instance, ref ZNetView ___m_nview)
private static void Postfix(ref Smelter __instance, ref ZNetView ___m_nview)
{
if (!___m_nview.isActiveAndEnabled || Player.m_localPlayer == null || Player.m_localPlayer.IsTeleporting()) return;

Expand Down
20 changes: 3 additions & 17 deletions src/Digitalroot.Valheim.EternalFire/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
},
"Digitalroot.Valheim.Common.Names": {
"type": "Direct",
"requested": "[1.4.31, )",
"resolved": "1.4.31",
"contentHash": "t9xQAy+gDA8B1CbN9xDe51xGdJ7X/yojhiS/ZC6/PPS8mOb89RH9F0ESFOyvHvhyuOBIuqbW1clE4QWfrem44A==",
"requested": "[1.4.32, )",
"resolved": "1.4.32",
"contentHash": "nmnzPGhVzfb7jI2VoL6I+WPROGqUcJfeInqPWasMjskwmAYem1iCtOBfCSgYlCAcYaH2g3K4frIPvtTjCqzF0A==",
"dependencies": {
"Digitalroot.Valheim.Common.Utils": "1.0.63"
}
Expand Down Expand Up @@ -84,15 +84,6 @@
"Fody": "6.3.0"
}
},
"Microsoft.NETFramework.ReferenceAssemblies": {
"type": "Direct",
"requested": "[1.0.3, )",
"resolved": "1.0.3",
"contentHash": "vUc9Npcs14QsyOD01tnv/m8sQUnGTGOw1BCmKcv77LBJY7OxhJ+zJF7UD/sCL3lYNFuqmQEVlkfS4Quif6FyYg==",
"dependencies": {
"Microsoft.NETFramework.ReferenceAssemblies.net48": "1.0.3"
}
},
"BepInEx.BaseLib": {
"type": "Transitive",
"resolved": "5.4.20",
Expand Down Expand Up @@ -125,11 +116,6 @@
"resolved": "1.2.0",
"contentHash": "jcZROJ28bmrZx/RaFHcTlSy3x4SmSsMolJiKoluFFrE7oMiXUnYx1K+SJeHJhow05W0Rg9oi9HEyZWwdYSV3cw=="
},
"Microsoft.NETFramework.ReferenceAssemblies.net48": {
"type": "Transitive",
"resolved": "1.0.3",
"contentHash": "zMk4D+9zyiEWByyQ7oPImPN/Jhpj166Ky0Nlla4eXlNL8hI/BtSJsgR8Inldd4NNpIAH3oh8yym0W2DrhXdSLQ=="
},
"Mono.Cecil": {
"type": "Transitive",
"resolved": "0.11.4",
Expand Down
2 changes: 1 addition & 1 deletion src/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down

0 comments on commit 5589836

Please sign in to comment.