Add ModuleWeaponGunManager for configurable weapon gun settings
This commit is contained in:
@@ -33,8 +33,7 @@ namespace TerraTech {
|
||||
}
|
||||
|
||||
private static void ConfigureModuleRemoteCharger(MultipliedObject<ModuleRemoteCharger> obj) {
|
||||
obj.AddField(
|
||||
new FieldConfiguration<float, float>("m_ArcFiringInterval", arcFiringIntervalMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_ArcFiringInterval", arcFiringIntervalMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_ChargingRadius", chargingRadiusMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_PowerTransferPerArc", powerTransferPerArcMultiplier));
|
||||
}
|
||||
|
@@ -5,11 +5,18 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWeaponGunManager {
|
||||
private static readonly MultipliedObjectManager<FireData> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleWeaponGun> manager =
|
||||
new MultipliedObjectManager<ModuleWeaponGun>(ConfigureManager);
|
||||
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
||||
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
||||
|
||||
public static ConfigEntry<float> kickbackStrengthMultiplier;
|
||||
public static ConfigEntry<float> muzzleVelocityMultiplier;
|
||||
public static ConfigEntry<float> burstCooldownMultiplier;
|
||||
public static ConfigEntry<float> burstShotCountMultiplier;
|
||||
public static ConfigEntry<float> shotCooldownMultiplier;
|
||||
public static ConfigEntry<bool> seekingRoundsAll;
|
||||
public static ConfigEntry<bool> resetBurstOnInterruptAll;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -24,6 +31,39 @@ namespace TerraTech {
|
||||
"FireData", "Muzzle Velocity Multiplier", 1f,
|
||||
new ConfigDescription("Muzzle Velocity Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
muzzleVelocityMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||
|
||||
burstCooldownMultiplier = config.Bind(
|
||||
"FireData", "Burst Cooldown Multiplier", 1f,
|
||||
new ConfigDescription("Burst Cooldown Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
burstCooldownMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||
|
||||
burstShotCountMultiplier = config.Bind(
|
||||
"FireData", "Burst Shot Count Multiplier", 1f,
|
||||
new ConfigDescription("Burst Shot Count Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
burstShotCountMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||
|
||||
shotCooldownMultiplier = config.Bind(
|
||||
"FireData", "Shot Cooldown Multiplier", 1f,
|
||||
new ConfigDescription("Shot Cooldown Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
shotCooldownMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||
|
||||
seekingRoundsAll =
|
||||
config.Bind("FireData", "Seeking Rounds All", false,
|
||||
new ConfigDescription("Seeking Rounds All", new AcceptableValueRange<bool>(false, true)));
|
||||
seekingRoundsAll.SettingChanged += (sender, args) => DoPatch();
|
||||
|
||||
resetBurstOnInterruptAll = config.Bind(
|
||||
"FireData", "Reset Burst On Interrupt All", false,
|
||||
new ConfigDescription("Reset Burst On Interrupt All", new AcceptableValueRange<bool>(false, true)));
|
||||
resetBurstOnInterruptAll.SettingChanged += (sender, args) => DoPatch();
|
||||
}
|
||||
|
||||
private static void ConfigureManager(MultipliedObject<ModuleWeaponGun> obj) {
|
||||
// obj.AddField(new FieldConfiguration<bool, bool>("m_SeekingRounds", seekingRoundsAll));
|
||||
// obj.AddField(new FieldConfiguration<bool, bool>("m_ResetBurstOnInterrupt", resetBurstOnInterruptAll));
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_BurstCooldown", burstCooldownMultiplier));
|
||||
obj.AddField(new FieldConfiguration<int, float>("m_BurstShotCount", burstShotCountMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_ShotCooldown", shotCooldownMultiplier));
|
||||
}
|
||||
|
||||
private static void ConfigureFireData(MultipliedObject<FireData> obj) {
|
||||
@@ -36,7 +76,8 @@ namespace TerraTech {
|
||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var firingData = trav.Field("m_FireData");
|
||||
manager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||
fireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||
manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
@@ -44,10 +85,12 @@ namespace TerraTech {
|
||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var firingData = trav.Field("m_FireData");
|
||||
manager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||
manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
fireDataManager.ApplyAll();
|
||||
manager.ApplyAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user