Add aerofoil configuration multipliers and ModuleWingManager
This commit is contained in:
@@ -45,6 +45,10 @@ namespace TerraTech {
|
||||
public static ConfigEntry<float> shopBlocksGeneratedTotalMultiplier;
|
||||
public static ConfigEntry<float> shopPerBlockStopMultiplier;
|
||||
|
||||
public static ConfigEntry<float> aerofoilAngleRangeMultiplier;
|
||||
public static ConfigEntry<float> aerofoilAngleTurnSpeedMultiplier;
|
||||
public static ConfigEntry<float> aerofoilLiftStrengthMultiplier;
|
||||
|
||||
public static ConfigEntry<float> shieldRadiusMultiplier;
|
||||
public static ConfigEntry<float> shieldRadiusMultiplierHealing;
|
||||
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
||||
@@ -71,16 +75,35 @@ namespace TerraTech {
|
||||
shieldRadiusMultiplier = Config.Bind(
|
||||
"Shield", "Shield Radius Multiplier", 1f,
|
||||
new ConfigDescription("Shield Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
shieldRadiusMultiplier.SettingChanged += (sender, args) => ModuleShieldGeneratorManager.DoPatch();
|
||||
shieldHeartbeatIntervalMultiplier =
|
||||
Config.Bind("Shield", "Shield Heartbeat Interval Multiplier", 1f,
|
||||
new ConfigDescription("Shield Heartbeat Interval Multiplier",
|
||||
new AcceptableValueRange<float>(min, max)));
|
||||
shieldHeartbeatIntervalMultiplier.SettingChanged += (sender, args) =>
|
||||
ModuleShieldGeneratorManager.DoPatch();
|
||||
shieldPowerUpDelayMultiplier = Config.Bind(
|
||||
"Shield", "Shield Power Up Delay Multiplier", 1f,
|
||||
new ConfigDescription("Shield Power Up Delay Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
shieldPowerUpDelayMultiplier.SettingChanged += (sender, args) => ModuleShieldGeneratorManager.DoPatch();
|
||||
shieldRadiusMultiplierHealing = Config.Bind(
|
||||
"Shield", "Shield Radius Multiplier Healing", 1f,
|
||||
new ConfigDescription("Shield Radius Multiplier Healing", new AcceptableValueRange<float>(min, max)));
|
||||
shieldRadiusMultiplierHealing.SettingChanged += (sender, args) => ModuleShieldGeneratorManager.DoPatch();
|
||||
|
||||
aerofoilAngleRangeMultiplier = Config.Bind(
|
||||
"Aerofoil", "Aerofoil Angle Range Multiplier", 1f,
|
||||
new ConfigDescription("Aerofoil Angle Range Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
aerofoilAngleRangeMultiplier.SettingChanged += (sender, args) => ModuleWingManager.DoPatch();
|
||||
aerofoilAngleTurnSpeedMultiplier =
|
||||
Config.Bind("Aerofoil", "Aerofoil Angle Turn Speed Multiplier", 1f,
|
||||
new ConfigDescription("Aerofoil Angle Turn Speed Multiplier",
|
||||
new AcceptableValueRange<float>(min, max)));
|
||||
aerofoilAngleTurnSpeedMultiplier.SettingChanged += (sender, args) => ModuleWingManager.DoPatch();
|
||||
aerofoilLiftStrengthMultiplier = Config.Bind(
|
||||
"Aerofoil", "Aerofoil Lift Strength Multiplier", 1f,
|
||||
new ConfigDescription("Aerofoil Lift Strength Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||
aerofoilLiftStrengthMultiplier.SettingChanged += (sender, args) => ModuleWingManager.DoPatch();
|
||||
|
||||
shootingSpeedMultiplier = Config.Bind(
|
||||
"Weapons", "Shooting Speed Multiplier", 1f,
|
||||
|
40
Projects/TerraTech/TerraTech/ModuleWingManager.cs
Normal file
40
Projects/TerraTech/TerraTech/ModuleWingManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWingManager {
|
||||
private static readonly MultipliedObjectManager<ModuleWing.Aerofoil> manager =
|
||||
new MultipliedObjectManager<ModuleWing.Aerofoil>(ConfigureAerofoil);
|
||||
|
||||
private static void ConfigureAerofoil(MultipliedObject<ModuleWing.Aerofoil> obj) {
|
||||
obj.AddField(new FieldConfiguration<float>("flipAngleRangeActual", Main.aerofoilAngleRangeMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float>("flipAngleRangeVisual", Main.aerofoilAngleRangeMultiplier));
|
||||
|
||||
obj.AddField(new FieldConfiguration<float>("flipAngleTurnSpeed", Main.aerofoilAngleTurnSpeedMultiplier));
|
||||
obj.AddField(new FieldConfiguration<float>("liftStrength", Main.aerofoilLiftStrengthMultiplier));
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWing), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWing __instance) {
|
||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||
var aerofoil = __instance.m_Aerofoils[i];
|
||||
manager.OnObjectAttached(aerofoil);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWing), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWing __instance) {
|
||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||
var aerofoil = __instance.m_Aerofoils[i];
|
||||
manager.OnObjectDetached(aerofoil);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
}
|
||||
}
|
@@ -43,6 +43,7 @@
|
||||
<Compile Include="Patches.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SeekingProjectileManager.cs" />
|
||||
<Compile Include="ModuleWingManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
|
Reference in New Issue
Block a user