Compare commits
10 Commits
446ef52012
...
e4700847df
Author | SHA1 | Date | |
---|---|---|---|
e4700847df | |||
acdc4d2a78 | |||
7964f8f395 | |||
9e3e4fa367 | |||
b10eb8752b | |||
d0ffe1951b | |||
4f51f8599e | |||
5723e9592e | |||
dc7be36bdb | |||
0b4883ed6c |
@@ -6,6 +6,7 @@
|
|||||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CUnityEngine_002ECoreModule_002Edll/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CUnityEngine_002ECoreModule_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CUnityEngine_002Edll/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CUnityEngine_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ABaseUnityPlugin_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F9185a461e2a54cd99ed3b83eace57b3d1f200_003F59_003Fb886ba39_003FBaseUnityPlugin_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ABaseUnityPlugin_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F9185a461e2a54cd99ed3b83eace57b3d1f200_003F59_003Fb886ba39_003FBaseUnityPlugin_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATraverse_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F474744d65d8e460fa08cd5fd82b5d65f32000_003F24_003F10e7e9ab_003FTraverse_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer /></s:String>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer /></s:String>
|
||||||
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</s:String>
|
<s:String x:Key="/Default/Environment/Hierarchy/Build/BuildTool/CustomBuildToolPath/@EntryValue">C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</s:String>
|
||||||
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">262144</s:Int64>
|
<s:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">262144</s:Int64>
|
||||||
|
@@ -21,6 +21,7 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> seekingProjectileVisionConeAngleMultiplier;
|
public static ConfigEntry<float> seekingProjectileVisionConeAngleMultiplier;
|
||||||
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
||||||
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
||||||
|
public static ConfigEntry<bool> projectileExplodeOnStick;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
debug = Config.Bind("General", "Debug", false);
|
debug = Config.Bind("General", "Debug", false);
|
||||||
@@ -40,6 +41,8 @@ namespace TerraTech {
|
|||||||
ModuleWheelsManager.Setup(Config);
|
ModuleWheelsManager.Setup(Config);
|
||||||
TankBeamManager.Setup(Config);
|
TankBeamManager.Setup(Config);
|
||||||
ModuleWeaponManager.Setup(Config);
|
ModuleWeaponManager.Setup(Config);
|
||||||
|
ModuleHeartManager.Setup(Config);
|
||||||
|
ModuleFuelTankManager.Setup(Config);
|
||||||
|
|
||||||
xpMultiplier =
|
xpMultiplier =
|
||||||
Config.Bind("General", "XP Multiplier", 1f,
|
Config.Bind("General", "XP Multiplier", 1f,
|
||||||
@@ -63,6 +66,9 @@ namespace TerraTech {
|
|||||||
Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Seeking Projectile Turn Speed Multiplier",
|
new ConfigDescription("Seeking Projectile Turn Speed Multiplier",
|
||||||
new AcceptableValueRange<float>(min, max)));
|
new AcceptableValueRange<float>(min, max)));
|
||||||
|
projectileExplodeOnStick = Config.Bind(
|
||||||
|
"Weapons", "Projectile Explode On Stick", false,
|
||||||
|
new ConfigDescription("Projectile Explode On Stick", new AcceptableValueRange<bool>(false, true)));
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
|
@@ -14,7 +14,7 @@ namespace TerraTech {
|
|||||||
return tank.ControllableByLocalPlayer;
|
return tank.ControllableByLocalPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsObjectTank(object obj) {
|
public static Func<object, bool> IsObjectPlayerTank = obj => {
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
return false;
|
return false;
|
||||||
try {
|
try {
|
||||||
@@ -23,8 +23,6 @@ namespace TerraTech {
|
|||||||
Console.WriteLine("Failed to check if object is a player tank: " + e.Message);
|
Console.WriteLine("Failed to check if object is a player tank: " + e.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<BoosterJet> jetManager =
|
private static readonly MultipliedObjectManager<BoosterJet> jetManager =
|
||||||
new MultipliedObjectManager<BoosterJet>(ConfigureJetThruster);
|
new MultipliedObjectManager<BoosterJet>(ConfigureJetThruster);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> fanThrustMultiplier;
|
public static ConfigEntry<float> fanThrustMultiplier;
|
||||||
public static ConfigEntry<float> jetThrustMultiplier;
|
public static ConfigEntry<float> jetThrustMultiplier;
|
||||||
|
|
||||||
@@ -18,6 +19,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Booster", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
fanThrustMultiplier =
|
fanThrustMultiplier =
|
||||||
config.Bind("Booster", "Fan Thrust Multiplier", 1f,
|
config.Bind("Booster", "Fan Thrust Multiplier", 1f,
|
||||||
new ConfigDescription("Fan Thrust Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Fan Thrust Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -30,13 +34,19 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureFanThruster(MultipliedObject<FanJet> obj) {
|
private static void ConfigureFanThruster(MultipliedObject<FanJet> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Force", fanThrustMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_Force", fanThrustMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureJetThruster(MultipliedObject<BoosterJet> obj) {
|
private static void ConfigureJetThruster(MultipliedObject<BoosterJet> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Force", jetThrustMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_Force", jetThrustMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsObjectPlayerTank(obj);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleBooster), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleBooster), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleBooster __instance) {
|
static void PostfixCreate(ModuleBooster __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleEnergy> manager =
|
private static readonly MultipliedObjectManager<ModuleEnergy> manager =
|
||||||
new MultipliedObjectManager<ModuleEnergy>(ConfigureModuleEnergy);
|
new MultipliedObjectManager<ModuleEnergy>(ConfigureModuleEnergy);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> outputMultiplier;
|
public static ConfigEntry<float> outputMultiplier;
|
||||||
public static ConfigEntry<float> powerUpDelayMultiplier;
|
public static ConfigEntry<float> powerUpDelayMultiplier;
|
||||||
|
|
||||||
@@ -14,6 +16,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Energy", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
outputMultiplier =
|
outputMultiplier =
|
||||||
config.Bind("Energy", "Output Multiplier", 1f,
|
config.Bind("Energy", "Output Multiplier", 1f,
|
||||||
new ConfigDescription("Output Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Output Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -26,12 +31,18 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureModuleEnergy(MultipliedObject<ModuleEnergy> obj) {
|
private static void ConfigureModuleEnergy(MultipliedObject<ModuleEnergy> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_OutputPerSecond", outputMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_OutputPerSecond", outputMultiplier, ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_PowerUpDelay", powerUpDelayMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_PowerUpDelay", powerUpDelayMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleEnergy), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleEnergy), "OnAnchorStatusChanged")]
|
||||||
static void PostfixCreate(ModuleEnergy __instance) {
|
static void PostfixCreate(ModuleEnergy __instance) {
|
||||||
manager.OnObjectAttached(__instance);
|
manager.OnObjectAttached(__instance);
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,12 +8,16 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleEnergyStore> manager =
|
private static readonly MultipliedObjectManager<ModuleEnergyStore> manager =
|
||||||
new MultipliedObjectManager<ModuleEnergyStore>(ConfigureModuleEnergyStore);
|
new MultipliedObjectManager<ModuleEnergyStore>(ConfigureModuleEnergyStore);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> capacityMultiplier;
|
public static ConfigEntry<float> capacityMultiplier;
|
||||||
|
|
||||||
public static void Setup(ConfigFile config) {
|
public static void Setup(ConfigFile config) {
|
||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Energy", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
capacityMultiplier =
|
capacityMultiplier =
|
||||||
config.Bind("Energy", "Capacity Multiplier", 1f,
|
config.Bind("Energy", "Capacity Multiplier", 1f,
|
||||||
new ConfigDescription("Capacity Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Capacity Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -20,9 +25,15 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureModuleEnergyStore(MultipliedObject<ModuleEnergyStore> obj) {
|
private static void ConfigureModuleEnergyStore(MultipliedObject<ModuleEnergyStore> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Capacity", capacityMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_Capacity", capacityMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleEnergyStore), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleEnergyStore), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleEnergyStore __instance) {
|
static void PostfixCreate(ModuleEnergyStore __instance) {
|
||||||
|
61
Projects/TerraTech/TerraTech/ModuleFuelTankManager.cs
Normal file
61
Projects/TerraTech/TerraTech/ModuleFuelTankManager.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ModuleFuelTankManager {
|
||||||
|
private static readonly MultipliedObjectManager<ModuleFuelTank> manager =
|
||||||
|
new MultipliedObjectManager<ModuleFuelTank>(ConfigureFuelTank);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
|
public static ConfigEntry<float> fuelCapacityMultiplier;
|
||||||
|
public static ConfigEntry<float> fuelRefillMultiplier;
|
||||||
|
|
||||||
|
public static void Setup(ConfigFile config) {
|
||||||
|
float min = 0.01f;
|
||||||
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("FuelTank", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
fuelCapacityMultiplier = config.Bind(
|
||||||
|
"FuelTank", "Fuel Capacity Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fuel Capacity Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
fuelCapacityMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
fuelRefillMultiplier =
|
||||||
|
config.Bind("FuelTank", "Fuel Refill Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fuel Refill Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
fuelRefillMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureFuelTank(MultipliedObject<ModuleFuelTank> obj) {
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_Capacity", fuelCapacityMultiplier, ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_RefillRate", fuelRefillMultiplier, ShouldApply));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsObjectPlayerTank(obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleFuelTank __instance) {
|
||||||
|
manager.OnObjectAttached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleFuelTank __instance) {
|
||||||
|
manager.OnObjectDetached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
manager.ApplyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,12 +8,16 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleGyro> manager =
|
private static readonly MultipliedObjectManager<ModuleGyro> manager =
|
||||||
new MultipliedObjectManager<ModuleGyro>(ConfigureModuleGyro);
|
new MultipliedObjectManager<ModuleGyro>(ConfigureModuleGyro);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> activeSpeedMultiplier;
|
public static ConfigEntry<float> activeSpeedMultiplier;
|
||||||
|
|
||||||
public static void Setup(ConfigFile config) {
|
public static void Setup(ConfigFile config) {
|
||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Gyro", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
activeSpeedMultiplier = config.Bind(
|
activeSpeedMultiplier = config.Bind(
|
||||||
"Gyro", "Active Speed Multiplier", 1f,
|
"Gyro", "Active Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Active Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Active Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -20,9 +25,15 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureModuleGyro(MultipliedObject<ModuleGyro> obj) {
|
private static void ConfigureModuleGyro(MultipliedObject<ModuleGyro> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_ActiveSpeed", activeSpeedMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_ActiveSpeed", activeSpeedMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleGyro), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleGyro), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleGyro __instance) {
|
static void PostfixCreate(ModuleGyro __instance) {
|
||||||
|
70
Projects/TerraTech/TerraTech/ModuleHeartManager.cs
Normal file
70
Projects/TerraTech/TerraTech/ModuleHeartManager.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ModuleHeartManager {
|
||||||
|
private static readonly MultipliedObjectManager<ModuleHeart> manager =
|
||||||
|
new MultipliedObjectManager<ModuleHeart>(ConfigureHeart);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
|
public static ConfigEntry<float> eventHorizonRadiusMultiplier;
|
||||||
|
public static ConfigEntry<float> setupTimeMultiplier;
|
||||||
|
public static ConfigEntry<float> startShrinkingRadiusMultiplier;
|
||||||
|
|
||||||
|
public static void Setup(ConfigFile config) {
|
||||||
|
float min = 0.01f;
|
||||||
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Heart", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
eventHorizonRadiusMultiplier = config.Bind(
|
||||||
|
"Heart", "Event Horizon Radius Multiplier", 1f,
|
||||||
|
new ConfigDescription("Event Horizon Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
eventHorizonRadiusMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
setupTimeMultiplier =
|
||||||
|
config.Bind("Heart", "Setup Time Multiplier", 1f,
|
||||||
|
new ConfigDescription("Setup Time Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
setupTimeMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
|
startShrinkingRadiusMultiplier = config.Bind(
|
||||||
|
"Heart", "Start Shrinking Radius Multiplier", 1f,
|
||||||
|
new ConfigDescription("Start Shrinking Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
|
startShrinkingRadiusMultiplier.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfigureHeart(MultipliedObject<ModuleHeart> obj) {
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_EventHorizonRadius", eventHorizonRadiusMultiplier,
|
||||||
|
ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_SetupTime", setupTimeMultiplier, ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_StartShrinkingRadius", startShrinkingRadiusMultiplier,
|
||||||
|
ShouldApply));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsObjectPlayerTank(obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleHeart), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleHeart __instance) {
|
||||||
|
manager.OnObjectAttached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleHeart), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleHeart __instance) {
|
||||||
|
manager.OnObjectDetached(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
manager.ApplyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleItemPickup> magnetPickupManager =
|
private static readonly MultipliedObjectManager<ModuleItemPickup> magnetPickupManager =
|
||||||
new MultipliedObjectManager<ModuleItemPickup>(ConfigureMagnetPickup);
|
new MultipliedObjectManager<ModuleItemPickup>(ConfigureMagnetPickup);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> capacityPerStackMultiplier;
|
public static ConfigEntry<float> capacityPerStackMultiplier;
|
||||||
public static ConfigEntry<float> beamStrengthMultiplier;
|
public static ConfigEntry<float> beamStrengthMultiplier;
|
||||||
public static ConfigEntry<float> beamHeightIncrementScaleMultiplier;
|
public static ConfigEntry<float> beamHeightIncrementScaleMultiplier;
|
||||||
@@ -27,6 +29,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Item Holder", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
capacityPerStackMultiplier = config.Bind(
|
capacityPerStackMultiplier = config.Bind(
|
||||||
"Item Holder", "Capacity Per Stack Multiplier", 1f,
|
"Item Holder", "Capacity Per Stack Multiplier", 1f,
|
||||||
new ConfigDescription("Capacity Per Stack Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Capacity Per Stack Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -60,27 +65,35 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureBeam(MultipliedObject<ModuleItemHolder> obj) {
|
private static void ConfigureBeam(MultipliedObject<ModuleItemHolder> obj) {
|
||||||
obj.AddField(new FieldConfiguration<int, float>("m_CapacityPerStack", capacityPerStackMultiplier));
|
obj.AddField(
|
||||||
|
new FieldConfiguration<int, float>("m_CapacityPerStack", capacityPerStackMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureBeamHolder(MultipliedObject<ModuleItemHolderBeam> obj) {
|
private static void ConfigureBeamHolder(MultipliedObject<ModuleItemHolderBeam> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_BeamStrength", beamStrengthMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_BeamStrength", beamStrengthMultiplier, ShouldApply));
|
||||||
obj.AddField(
|
obj.AddField(new FieldConfiguration<float, float>("m_HeightIncrementScale",
|
||||||
new FieldConfiguration<float, float>("m_HeightIncrementScale", beamHeightIncrementScaleMultiplier));
|
beamHeightIncrementScaleMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureBeamPickup(MultipliedObject<ModuleItemPickup> obj) {
|
private static void ConfigureBeamPickup(MultipliedObject<ModuleItemPickup> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_PickupRange", beamPickupRangeMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_PickupRange", beamPickupRangeMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureMagnetHolder(MultipliedObject<ModuleItemHolderMagnet> obj) {
|
private static void ConfigureMagnetHolder(MultipliedObject<ModuleItemHolderMagnet> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Strength", magnetStrengthMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_Strength", magnetStrengthMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureMagnetPickup(MultipliedObject<ModuleItemPickup> obj) {
|
private static void ConfigureMagnetPickup(MultipliedObject<ModuleItemPickup> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_PickupRange", magnetPickupRangeMultiplier));
|
obj.AddField(
|
||||||
|
new FieldConfiguration<float, float>("m_PickupRange", magnetPickupRangeMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleItemHolder), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleItemHolder), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleItemHolder __instance) {
|
static void PostfixCreate(ModuleItemHolder __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleItemProducer> manager =
|
private static readonly MultipliedObjectManager<ModuleItemProducer> manager =
|
||||||
new MultipliedObjectManager<ModuleItemProducer>(ConfigureModuleItemProducer);
|
new MultipliedObjectManager<ModuleItemProducer>(ConfigureModuleItemProducer);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> resourceGroundRadiusMultiplier;
|
public static ConfigEntry<float> resourceGroundRadiusMultiplier;
|
||||||
public static ConfigEntry<float> minDispenseIntervalMultiplier;
|
public static ConfigEntry<float> minDispenseIntervalMultiplier;
|
||||||
public static ConfigEntry<float> secPerItemProducedMultiplier;
|
public static ConfigEntry<float> secPerItemProducedMultiplier;
|
||||||
@@ -15,6 +17,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Item Producer", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
resourceGroundRadiusMultiplier = config.Bind(
|
resourceGroundRadiusMultiplier = config.Bind(
|
||||||
"Item Producer", "Resource Ground Radius Multiplier", 1f,
|
"Item Producer", "Resource Ground Radius Multiplier", 1f,
|
||||||
new ConfigDescription("Resource Ground Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Resource Ground Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -32,12 +37,20 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureModuleItemProducer(MultipliedObject<ModuleItemProducer> obj) {
|
private static void ConfigureModuleItemProducer(MultipliedObject<ModuleItemProducer> obj) {
|
||||||
obj.AddField(
|
obj.AddField(new FieldConfiguration<float, float>("m_ResourceGroundRadius", resourceGroundRadiusMultiplier,
|
||||||
new FieldConfiguration<float, float>("m_ResourceGroundRadius", resourceGroundRadiusMultiplier));
|
ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_MinDispenseInterval", minDispenseIntervalMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_MinDispenseInterval", minDispenseIntervalMultiplier,
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_SecPerItemProduced", secPerItemProducedMultiplier));
|
ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_SecPerItemProduced", secPerItemProducedMultiplier,
|
||||||
|
ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
||||||
static void PostfixCreate(ModuleItemProducer __instance) {
|
static void PostfixCreate(ModuleItemProducer __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleRemoteCharger> manager =
|
private static readonly MultipliedObjectManager<ModuleRemoteCharger> manager =
|
||||||
new MultipliedObjectManager<ModuleRemoteCharger>(ConfigureModuleRemoteCharger);
|
new MultipliedObjectManager<ModuleRemoteCharger>(ConfigureModuleRemoteCharger);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> arcFiringIntervalMultiplier;
|
public static ConfigEntry<float> arcFiringIntervalMultiplier;
|
||||||
public static ConfigEntry<float> chargingRadiusMultiplier;
|
public static ConfigEntry<float> chargingRadiusMultiplier;
|
||||||
public static ConfigEntry<float> powerTransferPerArcMultiplier;
|
public static ConfigEntry<float> powerTransferPerArcMultiplier;
|
||||||
@@ -15,6 +17,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Remote Charger", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
arcFiringIntervalMultiplier = config.Bind(
|
arcFiringIntervalMultiplier = config.Bind(
|
||||||
"Remote Charger", "Arc Firing Interval Multiplier", 1f,
|
"Remote Charger", "Arc Firing Interval Multiplier", 1f,
|
||||||
new ConfigDescription("Arc Firing Interval Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Arc Firing Interval Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -32,11 +37,20 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureModuleRemoteCharger(MultipliedObject<ModuleRemoteCharger> obj) {
|
private static void ConfigureModuleRemoteCharger(MultipliedObject<ModuleRemoteCharger> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_ArcFiringInterval", arcFiringIntervalMultiplier));
|
obj.AddField(
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_ChargingRadius", chargingRadiusMultiplier));
|
new FieldConfiguration<float, float>("m_ArcFiringInterval", arcFiringIntervalMultiplier, ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_PowerTransferPerArc", powerTransferPerArcMultiplier));
|
obj.AddField(
|
||||||
|
new FieldConfiguration<float, float>("m_ChargingRadius", chargingRadiusMultiplier, ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_PowerTransferPerArc", powerTransferPerArcMultiplier,
|
||||||
|
ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleRemoteCharger __instance) {
|
static void PostfixCreate(ModuleRemoteCharger __instance) {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using BepInEx.Configuration;
|
using System;
|
||||||
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
namespace TerraTech {
|
namespace TerraTech {
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleShieldGenerator> manager =
|
private static readonly MultipliedObjectManager<ModuleShieldGenerator> manager =
|
||||||
new MultipliedObjectManager<ModuleShieldGenerator>(ConfigureShieldGenerator);
|
new MultipliedObjectManager<ModuleShieldGenerator>(ConfigureShieldGenerator);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> radiusMultiplier;
|
public static ConfigEntry<float> radiusMultiplier;
|
||||||
public static ConfigEntry<float> radiusMultiplierHealing;
|
public static ConfigEntry<float> radiusMultiplierHealing;
|
||||||
public static ConfigEntry<float> heartbeatIntervalMultiplier;
|
public static ConfigEntry<float> heartbeatIntervalMultiplier;
|
||||||
@@ -16,6 +18,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Shield", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
radiusMultiplier =
|
radiusMultiplier =
|
||||||
config.Bind("Shield", "Radius Multiplier", 1f,
|
config.Bind("Shield", "Radius Multiplier", 1f,
|
||||||
new ConfigDescription("Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Radius Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -38,17 +43,25 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureShieldGenerator(MultipliedObject<ModuleShieldGenerator> obj) {
|
private static void ConfigureShieldGenerator(MultipliedObject<ModuleShieldGenerator> obj) {
|
||||||
obj.AddField(
|
obj.AddField(new FieldConfiguration<float, float>("m_HealingHeartbeatInterval", heartbeatIntervalMultiplier,
|
||||||
new FieldConfiguration<float, float>("m_HealingHeartbeatInterval", heartbeatIntervalMultiplier));
|
ShouldApply));
|
||||||
|
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Radius", radiusMultiplier, instance => {
|
obj.AddField(new FieldConfiguration<float, float>("m_Radius", radiusMultiplier, instance => {
|
||||||
|
if (!ShouldApply(instance))
|
||||||
|
return radiusMultiplier;
|
||||||
var shield = (ModuleShieldGenerator)instance;
|
var shield = (ModuleShieldGenerator)instance;
|
||||||
return shield.m_Healing ? radiusMultiplierHealing : radiusMultiplier;
|
return shield.m_Healing ? radiusMultiplierHealing : radiusMultiplier;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_PowerUpDelay", powerUpDelayMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_PowerUpDelay", powerUpDelayMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleShieldGenerator __instance) {
|
static void PostfixCreate(ModuleShieldGenerator __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -9,6 +10,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
||||||
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> kickbackStrengthMultiplier;
|
public static ConfigEntry<float> kickbackStrengthMultiplier;
|
||||||
public static ConfigEntry<float> muzzleVelocityMultiplier;
|
public static ConfigEntry<float> muzzleVelocityMultiplier;
|
||||||
public static ConfigEntry<float> burstCooldownMultiplier;
|
public static ConfigEntry<float> burstCooldownMultiplier;
|
||||||
@@ -21,6 +23,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("WeaponGun", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
kickbackStrengthMultiplier = config.Bind(
|
kickbackStrengthMultiplier = config.Bind(
|
||||||
"FireData", "Kickback Strength Multiplier", 1f,
|
"FireData", "Kickback Strength Multiplier", 1f,
|
||||||
new ConfigDescription("Kickback Strength Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Kickback Strength Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -58,11 +63,12 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureManager(MultipliedObject<ModuleWeaponGun> obj) {
|
private static void ConfigureManager(MultipliedObject<ModuleWeaponGun> obj) {
|
||||||
obj.AddBooleanField(new BooleanFieldConfiguration("m_SeekingRounds", seekingRoundsAll));
|
obj.AddBooleanField(new BooleanFieldConfiguration("m_SeekingRounds", seekingRoundsAll, ShouldApply));
|
||||||
obj.AddBooleanField(new BooleanFieldConfiguration("m_ResetBurstOnInterrupt", resetBurstOnInterruptAll));
|
obj.AddBooleanField(
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_BurstCooldown", burstCooldownMultiplier));
|
new BooleanFieldConfiguration("m_ResetBurstOnInterrupt", resetBurstOnInterruptAll, ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<int, float>("m_BurstShotCount", burstShotCountMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_BurstCooldown", burstCooldownMultiplier, ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_ShotCooldown", shotCooldownMultiplier));
|
obj.AddField(new FieldConfiguration<int, float>("m_BurstShotCount", burstShotCountMultiplier, ShouldApply));
|
||||||
|
obj.AddField(new FieldConfiguration<float, float>("m_ShotCooldown", shotCooldownMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureFireData(MultipliedObject<FireData> obj) {
|
private static void ConfigureFireData(MultipliedObject<FireData> obj) {
|
||||||
@@ -70,22 +76,34 @@ namespace TerraTech {
|
|||||||
obj.AddField(new FieldConfiguration<float, float>("m_KickbackStrength", kickbackStrengthMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_KickbackStrength", kickbackStrengthMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||||
var trav = Traverse.Create(__instance);
|
|
||||||
var firingData = trav.Field("m_FireData");
|
|
||||||
fireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
|
||||||
manager.OnObjectAttached(__instance);
|
manager.OnObjectAttached(__instance);
|
||||||
|
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var firingData = trav.Field("m_FiringData");
|
||||||
|
fireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
||||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||||
|
manager.OnObjectAttached(__instance);
|
||||||
var trav = Traverse.Create(__instance);
|
var trav = Traverse.Create(__instance);
|
||||||
var firingData = trav.Field("m_FireData");
|
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var firingData = trav.Field("m_FiringData");
|
||||||
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||||
manager.OnObjectDetached(__instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoPatch() {
|
public static void DoPatch() {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,12 +8,16 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleWeapon> manager =
|
private static readonly MultipliedObjectManager<ModuleWeapon> manager =
|
||||||
new MultipliedObjectManager<ModuleWeapon>(ConfigureManager);
|
new MultipliedObjectManager<ModuleWeapon>(ConfigureManager);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> rotateSpeedMultiplier;
|
public static ConfigEntry<float> rotateSpeedMultiplier;
|
||||||
|
|
||||||
public static void Setup(ConfigFile config) {
|
public static void Setup(ConfigFile config) {
|
||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("ModuleWeapon", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
rotateSpeedMultiplier = config.Bind(
|
rotateSpeedMultiplier = config.Bind(
|
||||||
"ModuleWeapon", "Rotate Speed Multiplier", 1f,
|
"ModuleWeapon", "Rotate Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Rotate Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Rotate Speed Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -20,9 +25,15 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureManager(MultipliedObject<ModuleWeapon> obj) {
|
private static void ConfigureManager(MultipliedObject<ModuleWeapon> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_RotateSpeed", rotateSpeedMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_RotateSpeed", rotateSpeedMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWeapon), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleWeapon), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleWeapon __instance) {
|
static void PostfixCreate(ModuleWeapon __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ManWheels.TorqueParams> torqueParamsManager =
|
private static readonly MultipliedObjectManager<ManWheels.TorqueParams> torqueParamsManager =
|
||||||
new MultipliedObjectManager<ManWheels.TorqueParams>(ConfigureTorqueParams);
|
new MultipliedObjectManager<ManWheels.TorqueParams>(ConfigureTorqueParams);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> torqueRpmMultiplier;
|
public static ConfigEntry<float> torqueRpmMultiplier;
|
||||||
public static ConfigEntry<float> torqueMultiplier;
|
public static ConfigEntry<float> torqueMultiplier;
|
||||||
|
|
||||||
@@ -14,6 +16,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("TorqueParams", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
torqueRpmMultiplier =
|
torqueRpmMultiplier =
|
||||||
config.Bind("TorqueParams", "Torque RPM Multiplier", 1f,
|
config.Bind("TorqueParams", "Torque RPM Multiplier", 1f,
|
||||||
new ConfigDescription("Torque RPM Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Torque RPM Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -26,10 +31,16 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureTorqueParams(MultipliedObject<ManWheels.TorqueParams> obj) {
|
private static void ConfigureTorqueParams(MultipliedObject<ManWheels.TorqueParams> obj) {
|
||||||
obj.AddField(new FieldConfiguration<float, float>("torqueCurveMaxRpm", torqueRpmMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("torqueCurveMaxRpm", torqueRpmMultiplier, ShouldApply));
|
||||||
obj.AddField(new FieldConfiguration<float, float>("torqueCurveMaxTorque", torqueMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("torqueCurveMaxTorque", torqueMultiplier, ShouldApply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWheels), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleWheels), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleWheels __instance) {
|
static void PostfixCreate(ModuleWheels __instance) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ namespace TerraTech {
|
|||||||
private static readonly MultipliedObjectManager<ModuleWing.Aerofoil> manager =
|
private static readonly MultipliedObjectManager<ModuleWing.Aerofoil> manager =
|
||||||
new MultipliedObjectManager<ModuleWing.Aerofoil>(ConfigureAerofoil);
|
new MultipliedObjectManager<ModuleWing.Aerofoil>(ConfigureAerofoil);
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> angleRangeMultiplier;
|
public static ConfigEntry<float> angleRangeMultiplier;
|
||||||
public static ConfigEntry<float> turnSpeedMultiplier;
|
public static ConfigEntry<float> turnSpeedMultiplier;
|
||||||
public static ConfigEntry<float> liftStrengthMultiplier;
|
public static ConfigEntry<float> liftStrengthMultiplier;
|
||||||
@@ -15,6 +17,9 @@ namespace TerraTech {
|
|||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
float max = 32f;
|
float max = 32f;
|
||||||
|
|
||||||
|
playerOnly = config.Bind("Aerofoil", "Player Only", false, new ConfigDescription("Player Only"));
|
||||||
|
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
angleRangeMultiplier =
|
angleRangeMultiplier =
|
||||||
config.Bind("Aerofoil", "Angle Range Multiplier", 1f,
|
config.Bind("Aerofoil", "Angle Range Multiplier", 1f,
|
||||||
new ConfigDescription("Angle Range Multiplier", new AcceptableValueRange<float>(min, max)));
|
new ConfigDescription("Angle Range Multiplier", new AcceptableValueRange<float>(min, max)));
|
||||||
@@ -39,9 +44,17 @@ namespace TerraTech {
|
|||||||
obj.AddField(new FieldConfiguration<float, float>("liftStrength", liftStrengthMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("liftStrength", liftStrengthMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
|
if (!playerOnly.Value)
|
||||||
|
return true;
|
||||||
|
return CykUtil.IsPlayerTank(obj as Module);
|
||||||
|
};
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWing), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleWing), "OnAttached")]
|
||||||
static void PostfixCreate(ModuleWing __instance) {
|
static void PostfixCreate(ModuleWing __instance) {
|
||||||
|
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||||
|
return;
|
||||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||||
var aerofoil = __instance.m_Aerofoils[i];
|
var aerofoil = __instance.m_Aerofoils[i];
|
||||||
manager.OnObjectAttached(aerofoil);
|
manager.OnObjectAttached(aerofoil);
|
||||||
@@ -51,6 +64,8 @@ namespace TerraTech {
|
|||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleWing), "OnDetaching")]
|
[HarmonyPatch(typeof(ModuleWing), "OnDetaching")]
|
||||||
static void PostfixDestroy(ModuleWing __instance) {
|
static void PostfixDestroy(ModuleWing __instance) {
|
||||||
|
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||||
|
return;
|
||||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||||
var aerofoil = __instance.m_Aerofoils[i];
|
var aerofoil = __instance.m_Aerofoils[i];
|
||||||
manager.OnObjectDetached(aerofoil);
|
manager.OnObjectDetached(aerofoil);
|
||||||
|
@@ -21,6 +21,7 @@ namespace TerraTech {
|
|||||||
private string _fieldName;
|
private string _fieldName;
|
||||||
private ConfigEntry<TMul> _defaultMultiplier;
|
private ConfigEntry<TMul> _defaultMultiplier;
|
||||||
private Func<object, ConfigEntry<TMul>> _conditionalMultiplier;
|
private Func<object, ConfigEntry<TMul>> _conditionalMultiplier;
|
||||||
|
private Func<object, bool> _applyCondition;
|
||||||
|
|
||||||
public string FieldName {
|
public string FieldName {
|
||||||
get { return _fieldName; }
|
get { return _fieldName; }
|
||||||
@@ -37,6 +38,11 @@ namespace TerraTech {
|
|||||||
set { _conditionalMultiplier = value; }
|
set { _conditionalMultiplier = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Func<object, bool> ApplyCondition {
|
||||||
|
get { return _applyCondition; }
|
||||||
|
set { _applyCondition = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public FieldConfiguration(string fieldName, ConfigEntry<TMul> defaultMultiplier) {
|
public FieldConfiguration(string fieldName, ConfigEntry<TMul> defaultMultiplier) {
|
||||||
_fieldName = fieldName;
|
_fieldName = fieldName;
|
||||||
_defaultMultiplier = defaultMultiplier;
|
_defaultMultiplier = defaultMultiplier;
|
||||||
@@ -49,28 +55,54 @@ namespace TerraTech {
|
|||||||
_conditionalMultiplier = conditionalMultiplier;
|
_conditionalMultiplier = conditionalMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FieldConfiguration(string fieldName, ConfigEntry<TMul> defaultMultiplier,
|
||||||
|
Func<object, bool> applyCondition) {
|
||||||
|
_fieldName = fieldName;
|
||||||
|
_defaultMultiplier = defaultMultiplier;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldConfiguration(string fieldName, ConfigEntry<TMul> defaultMultiplier,
|
||||||
|
Func<object, ConfigEntry<TMul>> conditionalMultiplier,
|
||||||
|
Func<object, bool> applyCondition) {
|
||||||
|
_fieldName = fieldName;
|
||||||
|
_defaultMultiplier = defaultMultiplier;
|
||||||
|
_conditionalMultiplier = conditionalMultiplier;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigEntry<TMul> GetMultiplier(object instance) {
|
public ConfigEntry<TMul> GetMultiplier(object instance) {
|
||||||
if (_conditionalMultiplier == null) {
|
if (_conditionalMultiplier == null) {
|
||||||
return _defaultMultiplier;
|
return _defaultMultiplier;
|
||||||
}
|
}
|
||||||
return _conditionalMultiplier(instance);
|
return _conditionalMultiplier(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShouldApply(object instance) {
|
||||||
|
if (_applyCondition == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return _applyCondition(instance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MultipliedField<TField, TMul> : IFieldModifier {
|
public class MultipliedField<TField, TMul> : IFieldModifier {
|
||||||
private readonly string _fieldName;
|
private readonly string _fieldName;
|
||||||
private readonly ConfigEntry<TMul> _multiplier;
|
private readonly ConfigEntry<TMul> _multiplier;
|
||||||
private readonly Traverse _parentTraverse;
|
private readonly Traverse _parentTraverse;
|
||||||
|
private readonly Func<object, bool> _applyCondition;
|
||||||
private TField _originalValue;
|
private TField _originalValue;
|
||||||
|
|
||||||
public string FieldName {
|
public string FieldName {
|
||||||
get { return _fieldName; }
|
get { return _fieldName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public MultipliedField(string fieldName, ConfigEntry<TMul> multiplier, Traverse parentTraverse) {
|
public MultipliedField(string fieldName, ConfigEntry<TMul> multiplier, Traverse parentTraverse,
|
||||||
|
Func<object, bool> applyCondition = null) {
|
||||||
_fieldName = fieldName;
|
_fieldName = fieldName;
|
||||||
_multiplier = multiplier;
|
_multiplier = multiplier;
|
||||||
_parentTraverse = parentTraverse;
|
_parentTraverse = parentTraverse;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
|
||||||
if (!parentTraverse.Field(fieldName).FieldExists()) {
|
if (!parentTraverse.Field(fieldName).FieldExists()) {
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
@@ -128,6 +160,12 @@ namespace TerraTech {
|
|||||||
|
|
||||||
public void Apply() {
|
public void Apply() {
|
||||||
try {
|
try {
|
||||||
|
if (_applyCondition != null && !_applyCondition(_parentTraverse.GetValue())) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Skipping {0}: condition not met", _fieldName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var newValue = MultiplyValues(_originalValue, _multiplier.Value);
|
var newValue = MultiplyValues(_originalValue, _multiplier.Value);
|
||||||
|
|
||||||
if (Main.debug.Value)
|
if (Main.debug.Value)
|
||||||
@@ -160,6 +198,7 @@ namespace TerraTech {
|
|||||||
private string _fieldName;
|
private string _fieldName;
|
||||||
private ConfigEntry<bool> _value;
|
private ConfigEntry<bool> _value;
|
||||||
private Func<object, ConfigEntry<bool>> _conditionalValue;
|
private Func<object, ConfigEntry<bool>> _conditionalValue;
|
||||||
|
private Func<object, bool> _applyCondition;
|
||||||
|
|
||||||
public string FieldName {
|
public string FieldName {
|
||||||
get { return _fieldName; }
|
get { return _fieldName; }
|
||||||
@@ -176,6 +215,11 @@ namespace TerraTech {
|
|||||||
set { _conditionalValue = value; }
|
set { _conditionalValue = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Func<object, bool> ApplyCondition {
|
||||||
|
get { return _applyCondition; }
|
||||||
|
set { _applyCondition = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public BooleanFieldConfiguration(string fieldName, ConfigEntry<bool> value) {
|
public BooleanFieldConfiguration(string fieldName, ConfigEntry<bool> value) {
|
||||||
_fieldName = fieldName;
|
_fieldName = fieldName;
|
||||||
_value = value;
|
_value = value;
|
||||||
@@ -188,28 +232,53 @@ namespace TerraTech {
|
|||||||
_conditionalValue = conditionalValue;
|
_conditionalValue = conditionalValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BooleanFieldConfiguration(string fieldName, ConfigEntry<bool> value, Func<object, bool> applyCondition) {
|
||||||
|
_fieldName = fieldName;
|
||||||
|
_value = value;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanFieldConfiguration(string fieldName, ConfigEntry<bool> value,
|
||||||
|
Func<object, ConfigEntry<bool>> conditionalValue,
|
||||||
|
Func<object, bool> applyCondition) {
|
||||||
|
_fieldName = fieldName;
|
||||||
|
_value = value;
|
||||||
|
_conditionalValue = conditionalValue;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigEntry<bool> GetValue(object instance) {
|
public ConfigEntry<bool> GetValue(object instance) {
|
||||||
if (_conditionalValue == null) {
|
if (_conditionalValue == null) {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
return _conditionalValue(instance);
|
return _conditionalValue(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShouldApply(object instance) {
|
||||||
|
if (_applyCondition == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return _applyCondition(instance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BooleanField : IFieldModifier {
|
public class BooleanField : IFieldModifier {
|
||||||
private readonly string _fieldName;
|
private readonly string _fieldName;
|
||||||
private readonly ConfigEntry<bool> _value;
|
private readonly ConfigEntry<bool> _value;
|
||||||
private readonly Traverse _parentTraverse;
|
private readonly Traverse _parentTraverse;
|
||||||
|
private readonly Func<object, bool> _applyCondition;
|
||||||
private bool _originalValue;
|
private bool _originalValue;
|
||||||
|
|
||||||
public string FieldName {
|
public string FieldName {
|
||||||
get { return _fieldName; }
|
get { return _fieldName; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public BooleanField(string fieldName, ConfigEntry<bool> value, Traverse parentTraverse) {
|
public BooleanField(string fieldName, ConfigEntry<bool> value, Traverse parentTraverse,
|
||||||
|
Func<object, bool> applyCondition = null) {
|
||||||
_fieldName = fieldName;
|
_fieldName = fieldName;
|
||||||
_value = value;
|
_value = value;
|
||||||
_parentTraverse = parentTraverse;
|
_parentTraverse = parentTraverse;
|
||||||
|
_applyCondition = applyCondition;
|
||||||
|
|
||||||
if (!parentTraverse.Field(fieldName).FieldExists()) {
|
if (!parentTraverse.Field(fieldName).FieldExists()) {
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
@@ -240,6 +309,12 @@ namespace TerraTech {
|
|||||||
|
|
||||||
public void Apply() {
|
public void Apply() {
|
||||||
try {
|
try {
|
||||||
|
if (_applyCondition != null && !_applyCondition(_parentTraverse.GetValue())) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Skipping {0}: condition not met", _fieldName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_value.Value) {
|
if (_value.Value) {
|
||||||
if (Main.debug.Value)
|
if (Main.debug.Value)
|
||||||
Console.WriteLine("Applying to {0}: forcing to true", _fieldName);
|
Console.WriteLine("Applying to {0}: forcing to true", _fieldName);
|
||||||
@@ -287,12 +362,12 @@ namespace TerraTech {
|
|||||||
public void AddField<TField, TMul>(FieldConfiguration<TField, TMul> config) {
|
public void AddField<TField, TMul>(FieldConfiguration<TField, TMul> config) {
|
||||||
var multiplier = config.GetMultiplier(_instance);
|
var multiplier = config.GetMultiplier(_instance);
|
||||||
_fields[config.FieldName] =
|
_fields[config.FieldName] =
|
||||||
new MultipliedField<TField, TMul>(config.FieldName, multiplier, _objectTraverse);
|
new MultipliedField<TField, TMul>(config.FieldName, multiplier, _objectTraverse, config.ShouldApply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBooleanField(BooleanFieldConfiguration config) {
|
public void AddBooleanField(BooleanFieldConfiguration config) {
|
||||||
var value = config.GetValue(_instance);
|
var value = config.GetValue(_instance);
|
||||||
_fields[config.FieldName] = new BooleanField(config.FieldName, value, _objectTraverse);
|
_fields[config.FieldName] = new BooleanField(config.FieldName, value, _objectTraverse, config.ShouldApply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CaptureFrom() {
|
public void CaptureFrom() {
|
||||||
@@ -303,16 +378,14 @@ namespace TerraTech {
|
|||||||
|
|
||||||
public void ApplyTo(IEnumerable<string> fieldNames = null) {
|
public void ApplyTo(IEnumerable<string> fieldNames = null) {
|
||||||
IEnumerable<string> fieldsToApply = fieldNames ?? _fields.Keys;
|
IEnumerable<string> fieldsToApply = fieldNames ?? _fields.Keys;
|
||||||
foreach (var fieldName in fieldsToApply.Where(name => _fields.ContainsKey(name))) {
|
foreach (var fieldName in fieldsToApply.Where(name => _fields.ContainsKey(name)))
|
||||||
_fields[fieldName].Apply();
|
_fields[fieldName].Apply();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestoreTo(IEnumerable<string> fieldNames = null) {
|
public void RestoreTo(IEnumerable<string> fieldNames = null) {
|
||||||
IEnumerable<string> fieldsToRestore = fieldNames ?? _fields.Keys;
|
IEnumerable<string> fieldsToRestore = fieldNames ?? _fields.Keys;
|
||||||
foreach (var fieldName in fieldsToRestore.Where(name => _fields.ContainsKey(name))) {
|
foreach (var fieldName in fieldsToRestore.Where(name => _fields.ContainsKey(name)))
|
||||||
_fields[fieldName].Restore();
|
_fields[fieldName].Restore();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogValues(string prefix) {
|
public void LogValues(string prefix) {
|
||||||
@@ -347,7 +420,7 @@ namespace TerraTech {
|
|||||||
try {
|
try {
|
||||||
_managedObjects.Remove(instance);
|
_managedObjects.Remove(instance);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error removing instance from _managedObjects: {0}", e));
|
Console.WriteLine("Error removing instance from _managedObjects: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +449,7 @@ namespace TerraTech {
|
|||||||
ApplyTo(instance);
|
ApplyTo(instance);
|
||||||
multipliedObject.LogValues("Patched");
|
multipliedObject.LogValues("Patched");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error in OnObjectAttached: {0}", e));
|
Console.WriteLine("Error in OnObjectAttached: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,13 +471,13 @@ namespace TerraTech {
|
|||||||
RestoreTo(instance);
|
RestoreTo(instance);
|
||||||
multipliedObject.LogValues("Restored");
|
multipliedObject.LogValues("Restored");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error restoring values: {0}", e));
|
Console.WriteLine("Error restoring values: {0}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeRemove(instance);
|
SafeRemove(instance);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error in OnObjectDetached: {0}", e));
|
Console.WriteLine("Error in OnObjectDetached: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +493,7 @@ namespace TerraTech {
|
|||||||
RestoreTo(instance, fieldNames);
|
RestoreTo(instance, fieldNames);
|
||||||
ApplyTo(instance, fieldNames);
|
ApplyTo(instance, fieldNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error applying to instance: {0}", e));
|
Console.WriteLine("Error applying to instance: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,7 +509,7 @@ namespace TerraTech {
|
|||||||
if (_managedObjects.TryGetValue(instance, out obj))
|
if (_managedObjects.TryGetValue(instance, out obj))
|
||||||
obj.ApplyTo(fieldNames);
|
obj.ApplyTo(fieldNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error in ApplyTo: {0}", e));
|
Console.WriteLine("Error in ApplyTo: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +524,7 @@ namespace TerraTech {
|
|||||||
if (_managedObjects.TryGetValue(instance, out obj))
|
if (_managedObjects.TryGetValue(instance, out obj))
|
||||||
obj.RestoreTo(fieldNames);
|
obj.RestoreTo(fieldNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Console.WriteLine(String.Format("Error in RestoreTo: {0}", e));
|
Console.WriteLine("Error in RestoreTo: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
Projects/TerraTech/TerraTech/ProjectilePatch.cs
Normal file
22
Projects/TerraTech/TerraTech/ProjectilePatch.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ProjectilePatch {
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(Projectile), "StickToObjectWithVisuals")]
|
||||||
|
static void Prefix(Projectile __instance) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Projectile created");
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var explodeOnStick = trav.Field("m_ExplodeOnStick");
|
||||||
|
|
||||||
|
if (!explodeOnStick.GetValue<bool>()) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Exploding on stick");
|
||||||
|
explodeOnStick.SetValue(Main.projectileExplodeOnStick.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,9 @@ namespace TerraTech {
|
|||||||
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
||||||
class Patch {
|
class Patch {
|
||||||
static void Postfix(SeekingProjectile __instance) {
|
static void Postfix(SeekingProjectile __instance) {
|
||||||
Console.WriteLine("SeekingProjectile created");
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("SeekingProjectile created");
|
||||||
|
|
||||||
SetField(
|
SetField(
|
||||||
__instance, "m_VisionConeAngle",
|
__instance, "m_VisionConeAngle",
|
||||||
Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
||||||
@@ -25,4 +27,4 @@ namespace TerraTech {
|
|||||||
Traverse.Create(seekingProjectile).Field(field).SetValue(value);
|
Traverse.Create(seekingProjectile).Field(field).SetValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,9 @@
|
|||||||
<Compile Include="TankBeamManager.cs" />
|
<Compile Include="TankBeamManager.cs" />
|
||||||
<Compile Include="ModuleWeaponManager.cs" />
|
<Compile Include="ModuleWeaponManager.cs" />
|
||||||
<Compile Include="CykUtil.cs" />
|
<Compile Include="CykUtil.cs" />
|
||||||
|
<Compile Include="ModuleHeartManager.cs" />
|
||||||
|
<Compile Include="ModuleFuelTankManager.cs" />
|
||||||
|
<Compile Include="ProjectilePatch.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
@@ -70,6 +73,9 @@
|
|||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>$(GAME_MANAGED)/UnityEngine.CoreModule.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.Networking">
|
||||||
|
<HintPath>$(GAME_MANAGED)/UnityEngine.Networking.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp">
|
||||||
<HintPath>$(GAME_MANAGED)/Assembly-CSharp.dll</HintPath>
|
<HintPath>$(GAME_MANAGED)/Assembly-CSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
Reference in New Issue
Block a user