Add ModuleWeaponManager for configurable weapon rotate speed
This commit is contained in:
@@ -39,6 +39,7 @@ namespace TerraTech {
|
|||||||
ModuleRemoteChargerManager.Setup(Config);
|
ModuleRemoteChargerManager.Setup(Config);
|
||||||
ModuleWheelsManager.Setup(Config);
|
ModuleWheelsManager.Setup(Config);
|
||||||
TankBeamManager.Setup(Config);
|
TankBeamManager.Setup(Config);
|
||||||
|
ModuleWeaponManager.Setup(Config);
|
||||||
|
|
||||||
xpMultiplier =
|
xpMultiplier =
|
||||||
Config.Bind("General", "XP Multiplier", 1f,
|
Config.Bind("General", "XP Multiplier", 1f,
|
||||||
|
43
Projects/TerraTech/TerraTech/ModuleWeaponManager.cs
Normal file
43
Projects/TerraTech/TerraTech/ModuleWeaponManager.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ModuleWeaponManager {
|
||||||
|
private static readonly MultipliedObjectManager<ModuleWeapon> manager =
|
||||||
|
new MultipliedObjectManager<ModuleWeapon>(ConfigureManager);
|
||||||
|
|
||||||
|
public static ConfigEntry<float> rotateSpeedMultiplier;
|
||||||
|
|
||||||
|
public static void Setup(ConfigFile config) {
|
||||||
|
float min = 0.01f;
|
||||||
|
float max = 32f;
|
||||||
|
|
||||||
|
rotateSpeedMultiplier = config.Bind(
|
||||||
|
"ModuleWeapon", "Rotate Speed Multiplier", 1f,
|
||||||
|
new ConfigDescription("Rotate Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
rotateSpeedMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureManager(MultipliedObject<ModuleWeapon> obj) {
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_RotateSpeed", rotateSpeedMultiplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleWeapon), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleWeapon __instance) {
|
||||||
|
manager.OnObjectAttached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleWeapon), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleWeapon __instance) {
|
||||||
|
manager.OnObjectDetached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
manager.ApplyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -54,6 +54,7 @@
|
|||||||
<Compile Include="ModuleRemoteChargerManager.cs" />
|
<Compile Include="ModuleRemoteChargerManager.cs" />
|
||||||
<Compile Include="ModuleWheelsManager.cs" />
|
<Compile Include="ModuleWheelsManager.cs" />
|
||||||
<Compile Include="TankBeamManager.cs" />
|
<Compile Include="TankBeamManager.cs" />
|
||||||
|
<Compile Include="ModuleWeaponManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
|
Reference in New Issue
Block a user