Add FireData configuration multipliers for kickback and muzzle velocity
This commit is contained in:
@@ -54,6 +54,9 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
||||||
public static ConfigEntry<float> shieldPowerUpDelayMultiplier;
|
public static ConfigEntry<float> shieldPowerUpDelayMultiplier;
|
||||||
|
|
||||||
|
public static ConfigEntry<float> fireDataKickbackStrengthMultiplier;
|
||||||
|
public static ConfigEntry<float> fireDataMuzzleVelocityMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
debug = Config.Bind("General", "Debug", false);
|
debug = Config.Bind("General", "Debug", false);
|
||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
@@ -105,6 +108,17 @@ namespace TerraTech {
|
|||||||
new ConfigDescription("Aerofoil Lift Strength Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Aerofoil Lift Strength Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
aerofoilLiftStrengthMultiplier.SettingChanged += (sender, args) => ModuleWingManager.DoPatch();
|
aerofoilLiftStrengthMultiplier.SettingChanged += (sender, args) => ModuleWingManager.DoPatch();
|
||||||
|
|
||||||
|
fireDataKickbackStrengthMultiplier =
|
||||||
|
Config.Bind("FireData", "Fire Data Kickback Strength Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fire Data Kickback Strength Multiplier",
|
||||||
|
new AcceptableValueRange<float>(min, max)));
|
||||||
|
fireDataKickbackStrengthMultiplier.SettingChanged += (sender, args) => FireDataManager.DoPatch();
|
||||||
|
fireDataMuzzleVelocityMultiplier =
|
||||||
|
Config.Bind("FireData", "Fire Data Muzzle Velocity Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fire Data Muzzle Velocity Multiplier",
|
||||||
|
new AcceptableValueRange<float>(min, max)));
|
||||||
|
fireDataMuzzleVelocityMultiplier.SettingChanged += (sender, args) => FireDataManager.DoPatch();
|
||||||
|
|
||||||
shootingSpeedMultiplier = Config.Bind(
|
shootingSpeedMultiplier = Config.Bind(
|
||||||
"Weapons", "Shooting Speed Multiplier", 1f,
|
"Weapons", "Shooting Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
35
Projects/TerraTech/TerraTech/FireDataManager.cs
Normal file
35
Projects/TerraTech/TerraTech/FireDataManager.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class FireDataManager {
|
||||||
|
private static readonly MultipliedObjectManager<FireData> manager =
|
||||||
|
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
||||||
|
|
||||||
|
private static void ConfigureFireData(MultipliedObject<FireData> obj) {
|
||||||
|
obj.AddField(new FieldConfiguration<float>("m_MuzzleVelocity", Main.fireDataMuzzleVelocityMultiplier));
|
||||||
|
obj.AddField(new FieldConfiguration<float>("m_KickbackStrength", Main.fireDataKickbackStrengthMultiplier));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var firingData = trav.Field("m_FireData");
|
||||||
|
manager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var firingData = trav.Field("m_FireData");
|
||||||
|
manager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
manager.ApplyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -44,6 +44,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SeekingProjectileManager.cs" />
|
<Compile Include="SeekingProjectileManager.cs" />
|
||||||
<Compile Include="ModuleWingManager.cs" />
|
<Compile Include="ModuleWingManager.cs" />
|
||||||
|
<Compile Include="FireDataManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
|
Reference in New Issue
Block a user