Add TankBeamManager for configurable tank beam settings
This commit is contained in:
@@ -38,6 +38,7 @@ namespace TerraTech {
|
|||||||
ModuleItemProducerManager.Setup(Config);
|
ModuleItemProducerManager.Setup(Config);
|
||||||
ModuleRemoteChargerManager.Setup(Config);
|
ModuleRemoteChargerManager.Setup(Config);
|
||||||
ModuleWheelsManager.Setup(Config);
|
ModuleWheelsManager.Setup(Config);
|
||||||
|
TankBeamManager.Setup(Config);
|
||||||
|
|
||||||
xpMultiplier =
|
xpMultiplier =
|
||||||
Config.Bind("General", "XP Multiplier", 1f,
|
Config.Bind("General", "XP Multiplier", 1f,
|
||||||
|
57
Projects/TerraTech/TerraTech/TankBeamManager.cs
Normal file
57
Projects/TerraTech/TerraTech/TankBeamManager.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class TankBeamManager {
|
||||||
|
private static readonly MultipliedObjectManager<TankBeam> manager =
|
||||||
|
new MultipliedObjectManager<TankBeam>(ConfigureBeam);
|
||||||
|
|
||||||
|
public static ConfigEntry<float> hoverClearanceMultiplier;
|
||||||
|
public static ConfigEntry<float> nudgeSpeedForwardMultiplier;
|
||||||
|
public static ConfigEntry<float> nudgeSpeedRotateMultiplier;
|
||||||
|
|
||||||
|
public static void Setup(ConfigFile config) {
|
||||||
|
float min = 0.01f;
|
||||||
|
float max = 32f;
|
||||||
|
|
||||||
|
hoverClearanceMultiplier = config.Bind(
|
||||||
|
"TankBeam", "Hover Clearance Multiplier", 1f,
|
||||||
|
new ConfigDescription("Hover Clearance Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
hoverClearanceMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
nudgeSpeedForwardMultiplier = config.Bind(
|
||||||
|
"TankBeam", "Nudge Speed Forward Multiplier", 1f,
|
||||||
|
new ConfigDescription("Nudge Speed Forward Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
nudgeSpeedForwardMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
nudgeSpeedRotateMultiplier = config.Bind(
|
||||||
|
"TankBeam", "Nudge Speed Rotate Multiplier", 1f,
|
||||||
|
new ConfigDescription("Nudge Speed Rotate Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
nudgeSpeedRotateMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureBeam(MultipliedObject<TankBeam> obj) {
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("hoverClearance", hoverClearanceMultiplier));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("nudgeSpeedForward", nudgeSpeedForwardMultiplier));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("nudgeSpeedRotate", nudgeSpeedRotateMultiplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(TankBeam), "OnSpawn")]
|
||||||
|
static void PostfixCreate(TankBeam __instance) {
|
||||||
|
manager.OnObjectAttached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(TankBeam), "OnRecycle")]
|
||||||
|
static void PostfixDestroy(TankBeam __instance) {
|
||||||
|
manager.OnObjectDetached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
manager.ApplyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -53,6 +53,7 @@
|
|||||||
<Compile Include="ModuleItemProducerManager.cs" />
|
<Compile Include="ModuleItemProducerManager.cs" />
|
||||||
<Compile Include="ModuleRemoteChargerManager.cs" />
|
<Compile Include="ModuleRemoteChargerManager.cs" />
|
||||||
<Compile Include="ModuleWheelsManager.cs" />
|
<Compile Include="ModuleWheelsManager.cs" />
|
||||||
|
<Compile Include="TankBeamManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
|
Reference in New Issue
Block a user