Add ModuleManagerMapper for dynamic module management
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
@@ -8,11 +10,11 @@ using HarmonyLib.Tools;
|
||||
// TODO: Maybe make props faster, thrusters work fine
|
||||
|
||||
namespace TerraTech {
|
||||
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
||||
[BepInPlugin(PluginGuid, PluginName, PluginVersion)]
|
||||
public class Main : BaseUnityPlugin {
|
||||
private const string pluginGuid = "CykaMod";
|
||||
private const string pluginName = "CykaMod";
|
||||
private const string pluginVersion = "1.0.0";
|
||||
private const string PluginGuid = "CykaMod";
|
||||
private const string PluginName = "CykaMod";
|
||||
private const string PluginVersion = "1.0.0";
|
||||
|
||||
public static ConfigEntry<bool> debug;
|
||||
public static ConfigEntry<float> xpMultiplier;
|
||||
@@ -72,7 +74,7 @@ namespace TerraTech {
|
||||
|
||||
Logger.LogInfo("Cyka mod loaded");
|
||||
HarmonyFileLog.Enabled = true;
|
||||
Harmony harmony = new Harmony(pluginGuid);
|
||||
Harmony harmony = new Harmony(PluginGuid);
|
||||
harmony.PatchAll();
|
||||
var originalMethods = harmony.GetPatchedMethods();
|
||||
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
||||
|
@@ -14,7 +14,7 @@ namespace TerraTech {
|
||||
return tank.ControllableByLocalPlayer;
|
||||
}
|
||||
|
||||
public static Func<object, bool> IsObjectPlayerTank = obj => {
|
||||
public static Func<object, bool> isObjectPlayerTank = obj => {
|
||||
if (obj == null)
|
||||
return false;
|
||||
try {
|
||||
|
@@ -6,14 +6,14 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleBoosterManager {
|
||||
private static readonly MultipliedObjectManager<FanJet> fanManager =
|
||||
private static readonly MultipliedObjectManager<FanJet> FanManager =
|
||||
new MultipliedObjectManager<FanJet>(ConfigureFanThruster);
|
||||
private static readonly MultipliedObjectManager<BoosterJet> jetManager =
|
||||
private static readonly MultipliedObjectManager<BoosterJet> JetManager =
|
||||
new MultipliedObjectManager<BoosterJet>(ConfigureJetThruster);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> fanThrustMultiplier;
|
||||
public static ConfigEntry<float> jetThrustMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> fanThrustMultiplier;
|
||||
private static ConfigEntry<float> jetThrustMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -44,34 +44,41 @@ namespace TerraTech {
|
||||
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||
if (!playerOnly.Value)
|
||||
return true;
|
||||
return CykUtil.IsObjectPlayerTank(obj);
|
||||
return CykUtil.isObjectPlayerTank(obj);
|
||||
};
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleBooster), "OnAttached")]
|
||||
static void PostfixCreate(ModuleBooster __instance) {
|
||||
public static void PostfixCreate(ModuleBooster __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var fans = trav.Field("fans").GetValue<List<FanJet>>();
|
||||
var jets = trav.Field("jets").GetValue<List<BoosterJet>>();
|
||||
|
||||
foreach (var fan in fans) fanManager.OnObjectAttached(fan);
|
||||
foreach (var jet in jets) jetManager.OnObjectAttached(jet);
|
||||
foreach (var fan in fans) FanManager.OnObjectAttached(fan);
|
||||
foreach (var jet in jets) JetManager.OnObjectAttached(jet);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleBooster), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleBooster __instance) {
|
||||
public static void PostfixDestroy(ModuleBooster __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var fans = trav.Field("fans").GetValue<List<FanJet>>();
|
||||
var jets = trav.Field("jets").GetValue<List<BoosterJet>>();
|
||||
|
||||
foreach (var fan in fans) fanManager.OnObjectDetached(fan);
|
||||
foreach (var jet in jets) jetManager.OnObjectDetached(jet);
|
||||
foreach (var fan in fans) FanManager.OnObjectDetached(fan);
|
||||
foreach (var jet in jets) JetManager.OnObjectDetached(jet);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
fanManager.ApplyAll();
|
||||
jetManager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
FanManager.ApplyAll();
|
||||
JetManager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleBooster: {0}", obj);
|
||||
PostfixCreate(obj as ModuleBooster);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,12 +5,12 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleEnergyManager {
|
||||
private static readonly MultipliedObjectManager<ModuleEnergy> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleEnergy> Manager =
|
||||
new MultipliedObjectManager<ModuleEnergy>(ConfigureModuleEnergy);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> outputMultiplier;
|
||||
public static ConfigEntry<float> powerUpDelayMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> outputMultiplier;
|
||||
private static ConfigEntry<float> powerUpDelayMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -43,18 +43,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergy), "OnAnchorStatusChanged")]
|
||||
static void PostfixCreate(ModuleEnergy __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleEnergy __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleEnergy __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleEnergy __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleEnergy: {0}", obj);
|
||||
PostfixCreate(obj as ModuleEnergy);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleEnergyStoreManager {
|
||||
private static readonly MultipliedObjectManager<ModuleEnergyStore> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleEnergyStore> Manager =
|
||||
new MultipliedObjectManager<ModuleEnergyStore>(ConfigureModuleEnergyStore);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> capacityMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> capacityMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -36,18 +36,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergyStore), "OnAttached")]
|
||||
static void PostfixCreate(ModuleEnergyStore __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleEnergyStore __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergyStore), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleEnergyStore __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleEnergyStore __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleEnergyStore: {0}", obj);
|
||||
PostfixCreate(obj as ModuleEnergyStore);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleFuelTankManager {
|
||||
private static readonly MultipliedObjectManager<ModuleFuelTank> manager =
|
||||
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;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> fuelCapacityMultiplier;
|
||||
private static ConfigEntry<float> fuelRefillMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -39,23 +38,30 @@ namespace TerraTech {
|
||||
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||
if (!playerOnly.Value)
|
||||
return true;
|
||||
return CykUtil.IsObjectPlayerTank(obj);
|
||||
return CykUtil.isObjectPlayerTank(obj);
|
||||
};
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")]
|
||||
static void PostfixCreate(ModuleFuelTank __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleFuelTank __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleFuelTank __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleFuelTank __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleFuelTank: {0}", obj);
|
||||
PostfixCreate(obj as ModuleFuelTank);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleGyroManager {
|
||||
private static readonly MultipliedObjectManager<ModuleGyro> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleGyro> Manager =
|
||||
new MultipliedObjectManager<ModuleGyro>(ConfigureModuleGyro);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> activeSpeedMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> activeSpeedMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -36,18 +36,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleGyro), "OnAttached")]
|
||||
static void PostfixCreate(ModuleGyro __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleGyro __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleGyro), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleGyro __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleGyro __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleGyro: {0}", obj);
|
||||
PostfixCreate(obj as ModuleGyro);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleHeartManager {
|
||||
private static readonly MultipliedObjectManager<ModuleHeart> manager =
|
||||
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;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> eventHorizonRadiusMultiplier;
|
||||
private static ConfigEntry<float> setupTimeMultiplier;
|
||||
private static ConfigEntry<float> startShrinkingRadiusMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -48,23 +47,30 @@ namespace TerraTech {
|
||||
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||
if (!playerOnly.Value)
|
||||
return true;
|
||||
return CykUtil.IsObjectPlayerTank(obj);
|
||||
return CykUtil.isObjectPlayerTank(obj);
|
||||
};
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleHeart), "OnAttached")]
|
||||
static void PostfixCreate(ModuleHeart __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleHeart __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleHeart), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleHeart __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleHeart __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleHeart: {0}", obj);
|
||||
PostfixCreate(obj as ModuleHeart);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,25 +5,25 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleItemHolderManager {
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolder> beamManager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolder> BeamManager =
|
||||
new MultipliedObjectManager<ModuleItemHolder>(ConfigureBeam);
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolderBeam> beamHolderManager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolderBeam> BeamHolderManager =
|
||||
new MultipliedObjectManager<ModuleItemHolderBeam>(ConfigureBeamHolder);
|
||||
private static readonly MultipliedObjectManager<ModuleItemPickup> beamPickupManager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemPickup> BeamPickupManager =
|
||||
new MultipliedObjectManager<ModuleItemPickup>(ConfigureBeamPickup);
|
||||
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolderMagnet> magnetHolderManager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemHolderMagnet> MagnetHolderManager =
|
||||
new MultipliedObjectManager<ModuleItemHolderMagnet>(ConfigureMagnetHolder);
|
||||
private static readonly MultipliedObjectManager<ModuleItemPickup> magnetPickupManager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemPickup> MagnetPickupManager =
|
||||
new MultipliedObjectManager<ModuleItemPickup>(ConfigureMagnetPickup);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> capacityPerStackMultiplier;
|
||||
public static ConfigEntry<float> beamStrengthMultiplier;
|
||||
public static ConfigEntry<float> beamHeightIncrementScaleMultiplier;
|
||||
public static ConfigEntry<float> beamPickupRangeMultiplier;
|
||||
public static ConfigEntry<float> magnetStrengthMultiplier;
|
||||
public static ConfigEntry<float> magnetPickupRangeMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> capacityPerStackMultiplier;
|
||||
private static ConfigEntry<float> beamStrengthMultiplier;
|
||||
private static ConfigEntry<float> beamHeightIncrementScaleMultiplier;
|
||||
private static ConfigEntry<float> beamPickupRangeMultiplier;
|
||||
private static ConfigEntry<float> magnetStrengthMultiplier;
|
||||
private static ConfigEntry<float> magnetPickupRangeMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -96,62 +96,69 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolder), "OnAttached")]
|
||||
static void PostfixCreate(ModuleItemHolder __instance) {
|
||||
beamManager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleItemHolder __instance) {
|
||||
BeamManager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolder), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemHolder __instance) {
|
||||
beamManager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleItemHolder __instance) {
|
||||
BeamManager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnAttached")]
|
||||
static void PostfixCreate(ModuleItemHolderBeam __instance) {
|
||||
public static void PostfixCreate(ModuleItemHolderBeam __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var pickup = trav.Field("m_Pickup").GetValue<ModuleItemPickup>();
|
||||
|
||||
beamHolderManager.OnObjectAttached(__instance);
|
||||
beamPickupManager.OnObjectAttached(pickup);
|
||||
BeamHolderManager.OnObjectAttached(__instance);
|
||||
BeamPickupManager.OnObjectAttached(pickup);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemHolderBeam __instance) {
|
||||
public static void PostfixDestroy(ModuleItemHolderBeam __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var pickup = trav.Field("m_Pickup").GetValue<ModuleItemPickup>();
|
||||
|
||||
beamHolderManager.OnObjectDetached(__instance);
|
||||
beamPickupManager.OnObjectDetached(pickup);
|
||||
BeamHolderManager.OnObjectDetached(__instance);
|
||||
BeamPickupManager.OnObjectDetached(pickup);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnAttached")]
|
||||
static void PostfixCreate(ModuleItemHolderMagnet __instance) {
|
||||
public static void PostfixCreate(ModuleItemHolderMagnet __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var pickup = trav.Field("m_Pickup").GetValue<ModuleItemPickup>();
|
||||
|
||||
magnetHolderManager.OnObjectAttached(__instance);
|
||||
magnetPickupManager.OnObjectAttached(pickup);
|
||||
MagnetHolderManager.OnObjectAttached(__instance);
|
||||
MagnetPickupManager.OnObjectAttached(pickup);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemHolderMagnet __instance) {
|
||||
public static void PostfixDestroy(ModuleItemHolderMagnet __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var pickup = trav.Field("m_Pickup").GetValue<ModuleItemPickup>();
|
||||
|
||||
magnetHolderManager.OnObjectDetached(__instance);
|
||||
magnetPickupManager.OnObjectDetached(pickup);
|
||||
MagnetHolderManager.OnObjectDetached(__instance);
|
||||
MagnetPickupManager.OnObjectDetached(pickup);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
beamManager.ApplyAll();
|
||||
beamHolderManager.ApplyAll();
|
||||
beamPickupManager.ApplyAll();
|
||||
magnetHolderManager.ApplyAll();
|
||||
magnetPickupManager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
BeamManager.ApplyAll();
|
||||
BeamHolderManager.ApplyAll();
|
||||
BeamPickupManager.ApplyAll();
|
||||
MagnetHolderManager.ApplyAll();
|
||||
MagnetPickupManager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleItemHolder: {0}", obj);
|
||||
PostfixCreate(obj as ModuleItemHolder);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,13 +5,13 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleItemProducerManager {
|
||||
private static readonly MultipliedObjectManager<ModuleItemProducer> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleItemProducer> Manager =
|
||||
new MultipliedObjectManager<ModuleItemProducer>(ConfigureModuleItemProducer);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> resourceGroundRadiusMultiplier;
|
||||
public static ConfigEntry<float> minDispenseIntervalMultiplier;
|
||||
public static ConfigEntry<float> secPerItemProducedMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> resourceGroundRadiusMultiplier;
|
||||
private static ConfigEntry<float> minDispenseIntervalMultiplier;
|
||||
private static ConfigEntry<float> secPerItemProducedMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
@@ -53,18 +53,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
||||
static void PostfixCreate(ModuleItemProducer __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleItemProducer __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemProducer), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemProducer __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleItemProducer __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleItemProducer: {0}", obj);
|
||||
PostfixCreate(obj as ModuleItemProducer);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,17 +5,17 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleRemoteChargerManager {
|
||||
private static readonly MultipliedObjectManager<ModuleRemoteCharger> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleRemoteCharger> Manager =
|
||||
new MultipliedObjectManager<ModuleRemoteCharger>(ConfigureModuleRemoteCharger);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> arcFiringIntervalMultiplier;
|
||||
public static ConfigEntry<float> chargingRadiusMultiplier;
|
||||
public static ConfigEntry<float> powerTransferPerArcMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> arcFiringIntervalMultiplier;
|
||||
private static ConfigEntry<float> chargingRadiusMultiplier;
|
||||
private static ConfigEntry<float> powerTransferPerArcMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("Remote Charger", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -53,18 +53,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")]
|
||||
static void PostfixCreate(ModuleRemoteCharger __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleRemoteCharger __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleRemoteCharger __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleRemoteCharger __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleRemoteCharger: {0}", obj);
|
||||
PostfixCreate(obj as ModuleRemoteCharger);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,18 +5,18 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleShieldGeneratorManager {
|
||||
private static readonly MultipliedObjectManager<ModuleShieldGenerator> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleShieldGenerator> Manager =
|
||||
new MultipliedObjectManager<ModuleShieldGenerator>(ConfigureShieldGenerator);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> radiusMultiplier;
|
||||
public static ConfigEntry<float> radiusMultiplierHealing;
|
||||
public static ConfigEntry<float> heartbeatIntervalMultiplier;
|
||||
public static ConfigEntry<float> powerUpDelayMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> radiusMultiplier;
|
||||
private static ConfigEntry<float> radiusMultiplierHealing;
|
||||
private static ConfigEntry<float> heartbeatIntervalMultiplier;
|
||||
private static ConfigEntry<float> powerUpDelayMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("Shield", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -46,10 +46,10 @@ namespace TerraTech {
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_HealingHeartbeatInterval", heartbeatIntervalMultiplier,
|
||||
ShouldApply));
|
||||
|
||||
obj.AddField(new FieldConfiguration<float, float>("m_Radius", radiusMultiplier, instance => {
|
||||
if (!ShouldApply(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;
|
||||
}));
|
||||
|
||||
@@ -64,18 +64,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnAttached")]
|
||||
static void PostfixCreate(ModuleShieldGenerator __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleShieldGenerator __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleShieldGenerator __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleShieldGenerator __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleShieldGenerator: {0}", obj);
|
||||
PostfixCreate(obj as ModuleShieldGenerator);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,23 +5,23 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWeaponGunManager {
|
||||
private static readonly MultipliedObjectManager<ModuleWeaponGun> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleWeaponGun> Manager =
|
||||
new MultipliedObjectManager<ModuleWeaponGun>(ConfigureManager);
|
||||
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
||||
private static readonly MultipliedObjectManager<FireData> FireDataManager =
|
||||
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
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;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> kickbackStrengthMultiplier;
|
||||
private static ConfigEntry<float> muzzleVelocityMultiplier;
|
||||
private static ConfigEntry<float> burstCooldownMultiplier;
|
||||
private static ConfigEntry<float> burstShotCountMultiplier;
|
||||
private static ConfigEntry<float> shotCooldownMultiplier;
|
||||
private static ConfigEntry<bool> seekingRoundsAll;
|
||||
private static ConfigEntry<bool> resetBurstOnInterruptAll;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("WeaponGun", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -84,31 +84,38 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleWeaponGun __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>());
|
||||
FireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
var trav = Traverse.Create(__instance);
|
||||
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||
return;
|
||||
|
||||
var firingData = trav.Field("m_FiringData");
|
||||
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||
FireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
fireDataManager.ApplyAll();
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
FireDataManager.ApplyAll();
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleWeaponGun: {0}", obj);
|
||||
PostfixCreate(obj as ModuleWeaponGun);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,15 +5,15 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWeaponManager {
|
||||
private static readonly MultipliedObjectManager<ModuleWeapon> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleWeapon> Manager =
|
||||
new MultipliedObjectManager<ModuleWeapon>(ConfigureManager);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> rotateSpeedMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> rotateSpeedMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("ModuleWeapon", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -36,18 +36,25 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeapon), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWeapon __instance) {
|
||||
manager.OnObjectAttached(__instance);
|
||||
public static void PostfixCreate(ModuleWeapon __instance) {
|
||||
Manager.OnObjectAttached(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeapon), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWeapon __instance) {
|
||||
manager.OnObjectDetached(__instance);
|
||||
public static void PostfixDestroy(ModuleWeapon __instance) {
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleWeapon: {0}", obj);
|
||||
PostfixCreate(obj as ModuleWeapon);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,16 +5,16 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWheelsManager {
|
||||
private static readonly MultipliedObjectManager<ManWheels.TorqueParams> torqueParamsManager =
|
||||
private static readonly MultipliedObjectManager<ManWheels.TorqueParams> TorqueParamsManager =
|
||||
new MultipliedObjectManager<ManWheels.TorqueParams>(ConfigureTorqueParams);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> torqueRpmMultiplier;
|
||||
public static ConfigEntry<float> torqueMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> torqueRpmMultiplier;
|
||||
private static ConfigEntry<float> torqueMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("TorqueParams", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -43,22 +43,29 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWheels), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWheels __instance) {
|
||||
public static void PostfixCreate(ModuleWheels __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var torqueParams = trav.Field("torqueParams");
|
||||
torqueParamsManager.OnObjectAttached(torqueParams.GetValue<ManWheels.TorqueParams>());
|
||||
TorqueParamsManager.OnObjectAttached(torqueParams.GetValue<ManWheels.TorqueParams>());
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWheels), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWheels __instance) {
|
||||
public static void PostfixDestroy(ModuleWheels __instance) {
|
||||
var trav = Traverse.Create(__instance);
|
||||
var torqueParams = trav.Field("torqueParams");
|
||||
torqueParamsManager.OnObjectDetached(torqueParams.GetValue<ManWheels.TorqueParams>());
|
||||
TorqueParamsManager.OnObjectDetached(torqueParams.GetValue<ManWheels.TorqueParams>());
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
torqueParamsManager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
TorqueParamsManager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleWheels: {0}", obj);
|
||||
PostfixCreate(obj as ModuleWheels);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -5,17 +5,17 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ModuleWingManager {
|
||||
private static readonly MultipliedObjectManager<ModuleWing.Aerofoil> manager =
|
||||
private static readonly MultipliedObjectManager<ModuleWing.Aerofoil> Manager =
|
||||
new MultipliedObjectManager<ModuleWing.Aerofoil>(ConfigureAerofoil);
|
||||
|
||||
public static ConfigEntry<bool> playerOnly;
|
||||
public static ConfigEntry<float> angleRangeMultiplier;
|
||||
public static ConfigEntry<float> turnSpeedMultiplier;
|
||||
public static ConfigEntry<float> liftStrengthMultiplier;
|
||||
private static ConfigEntry<bool> playerOnly;
|
||||
private static ConfigEntry<float> angleRangeMultiplier;
|
||||
private static ConfigEntry<float> turnSpeedMultiplier;
|
||||
private static ConfigEntry<float> liftStrengthMultiplier;
|
||||
|
||||
public static void Setup(ConfigFile config) {
|
||||
float min = 0.01f;
|
||||
float max = 32f;
|
||||
const float min = 0.01f;
|
||||
const float max = 32f;
|
||||
|
||||
playerOnly = config.Bind("Aerofoil", "Player Only", false, new ConfigDescription("Player Only"));
|
||||
playerOnly.SettingChanged += (sender, args) => DoPatch();
|
||||
@@ -52,28 +52,32 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWing), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWing __instance) {
|
||||
public static void PostfixCreate(ModuleWing __instance) {
|
||||
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||
return;
|
||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||
var aerofoil = __instance.m_Aerofoils[i];
|
||||
manager.OnObjectAttached(aerofoil);
|
||||
Manager.OnObjectAttached(aerofoil);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWing), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWing __instance) {
|
||||
public static void PostfixDestroy(ModuleWing __instance) {
|
||||
if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance))
|
||||
return;
|
||||
for (int i = 0; i < __instance.m_Aerofoils.Length; i++) {
|
||||
var aerofoil = __instance.m_Aerofoils[i];
|
||||
manager.OnObjectDetached(aerofoil);
|
||||
}
|
||||
foreach (var aerofoil in __instance.m_Aerofoils) Manager.OnObjectDetached(aerofoil);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
}
|
||||
private static void DoPatch() {
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
|
||||
public static readonly Func<Module, bool> Register = obj => {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Registering ModuleWing: {0}", obj);
|
||||
PostfixCreate(obj as ModuleWing);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -71,18 +71,18 @@ namespace TerraTech {
|
||||
_applyCondition = applyCondition;
|
||||
}
|
||||
|
||||
public ConfigEntry<TMul> GetMultiplier(object instance) {
|
||||
public ConfigEntry<TMul> GetMultiplier(object __instance) {
|
||||
if (_conditionalMultiplier == null) {
|
||||
return _defaultMultiplier;
|
||||
}
|
||||
return _conditionalMultiplier(instance);
|
||||
return _conditionalMultiplier(__instance);
|
||||
}
|
||||
|
||||
public bool ShouldApply(object instance) {
|
||||
public bool ShouldApply(object __instance) {
|
||||
if (_applyCondition == null) {
|
||||
return true;
|
||||
}
|
||||
return _applyCondition(instance);
|
||||
return _applyCondition(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,18 +247,18 @@ namespace TerraTech {
|
||||
_applyCondition = applyCondition;
|
||||
}
|
||||
|
||||
public ConfigEntry<bool> GetValue(object instance) {
|
||||
public ConfigEntry<bool> GetValue(object __instance) {
|
||||
if (_conditionalValue == null) {
|
||||
return _value;
|
||||
}
|
||||
return _conditionalValue(instance);
|
||||
return _conditionalValue(__instance);
|
||||
}
|
||||
|
||||
public bool ShouldApply(object instance) {
|
||||
public bool ShouldApply(object __instance) {
|
||||
if (_applyCondition == null) {
|
||||
return true;
|
||||
}
|
||||
return _applyCondition(instance);
|
||||
return _applyCondition(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,9 +353,9 @@ namespace TerraTech {
|
||||
private readonly Traverse _objectTraverse;
|
||||
private readonly Dictionary<string, IFieldModifier> _fields;
|
||||
|
||||
public MultipliedObject(T instance) {
|
||||
_instance = instance;
|
||||
_objectTraverse = Traverse.Create(instance);
|
||||
public MultipliedObject(T __instance) {
|
||||
_instance = __instance;
|
||||
_objectTraverse = Traverse.Create(__instance);
|
||||
_fields = new Dictionary<string, IFieldModifier>();
|
||||
}
|
||||
|
||||
@@ -413,68 +413,68 @@ namespace TerraTech {
|
||||
_managedObjects = new Dictionary<T, MultipliedObject<T>>();
|
||||
}
|
||||
|
||||
private void SafeRemove(T instance) {
|
||||
if (instance == null)
|
||||
private void SafeRemove(T __instance) {
|
||||
if (__instance == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
_managedObjects.Remove(instance);
|
||||
_managedObjects.Remove(__instance);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error removing instance from _managedObjects: {0}", e);
|
||||
Console.WriteLine("Error removing __instance from _managedObjects: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnObjectAttached(T instance) {
|
||||
public void OnObjectAttached(T __instance) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("{0}.OnAttached", typeof(T).Name);
|
||||
|
||||
if (instance == null) {
|
||||
Console.WriteLine("Attempted to attach null instance");
|
||||
if (__instance == null) {
|
||||
Console.WriteLine("Attempted to attach null __instance");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (_managedObjects.ContainsKey(instance)) {
|
||||
if (_managedObjects.ContainsKey(__instance)) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("{0} already managed, skipping", typeof(T).Name);
|
||||
return;
|
||||
}
|
||||
|
||||
var multipliedObject = new MultipliedObject<T>(instance);
|
||||
var multipliedObject = new MultipliedObject<T>(__instance);
|
||||
_configureObject(multipliedObject);
|
||||
multipliedObject.CaptureFrom();
|
||||
_managedObjects.Add(instance, multipliedObject);
|
||||
_managedObjects.Add(__instance, multipliedObject);
|
||||
multipliedObject.LogValues("Patching");
|
||||
|
||||
ApplyTo(instance);
|
||||
ApplyTo(__instance);
|
||||
multipliedObject.LogValues("Patched");
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error in OnObjectAttached: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnObjectDetached(T instance) {
|
||||
public void OnObjectDetached(T __instance) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("{0}.OnDetaching", typeof(T).Name);
|
||||
if (instance == null) {
|
||||
Console.WriteLine("Attempted to detach null instance");
|
||||
if (__instance == null) {
|
||||
Console.WriteLine("Attempted to detach null __instance");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
MultipliedObject<T> multipliedObject;
|
||||
if (_managedObjects.TryGetValue(instance, out multipliedObject)) {
|
||||
if (_managedObjects.TryGetValue(__instance, out multipliedObject)) {
|
||||
if (Main.debug.Value)
|
||||
multipliedObject.LogValues("Restoring");
|
||||
|
||||
try {
|
||||
RestoreTo(instance);
|
||||
RestoreTo(__instance);
|
||||
multipliedObject.LogValues("Restored");
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error restoring values: {0}", e);
|
||||
}
|
||||
|
||||
SafeRemove(instance);
|
||||
SafeRemove(__instance);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error in OnObjectDetached: {0}", e);
|
||||
@@ -488,40 +488,40 @@ namespace TerraTech {
|
||||
// Make a copy of the keys to avoid modification during enumeration
|
||||
var instances = _managedObjects.Keys.ToList();
|
||||
|
||||
foreach (var instance in instances) {
|
||||
foreach (var __instance in instances) {
|
||||
try {
|
||||
RestoreTo(instance, fieldNames);
|
||||
ApplyTo(instance, fieldNames);
|
||||
RestoreTo(__instance, fieldNames);
|
||||
ApplyTo(__instance, fieldNames);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error applying to instance: {0}", e);
|
||||
Console.WriteLine("Error applying to __instance: {0}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyTo(T instance, IEnumerable<string> fieldNames = null) {
|
||||
public void ApplyTo(T __instance, IEnumerable<string> fieldNames = null) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Applying {0}", typeof(T).Name);
|
||||
if (instance == null)
|
||||
if (__instance == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
MultipliedObject<T> obj;
|
||||
if (_managedObjects.TryGetValue(instance, out obj))
|
||||
if (_managedObjects.TryGetValue(__instance, out obj))
|
||||
obj.ApplyTo(fieldNames);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error in ApplyTo: {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreTo(T instance, IEnumerable<string> fieldNames = null) {
|
||||
public void RestoreTo(T __instance, IEnumerable<string> fieldNames = null) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Restoring {0}", typeof(T).Name);
|
||||
if (instance == null)
|
||||
if (__instance == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
MultipliedObject<T> obj;
|
||||
if (_managedObjects.TryGetValue(instance, out obj))
|
||||
if (_managedObjects.TryGetValue(__instance, out obj))
|
||||
obj.RestoreTo(fieldNames);
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("Error in RestoreTo: {0}", e);
|
||||
|
@@ -5,7 +5,7 @@ namespace TerraTech {
|
||||
public class Patches {
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
||||
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
||||
static void XpMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
||||
xp = (int)(xp * Main.xpMultiplier.Value);
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ namespace TerraTech {
|
||||
public class SeekingProjectileManager {
|
||||
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
||||
class Patch {
|
||||
static void Postfix(SeekingProjectile __instance) {
|
||||
public static void Postfix(SeekingProjectile __instance) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("SeekingProjectile created");
|
||||
|
||||
|
@@ -4,7 +4,7 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class TankBeamManager {
|
||||
private static readonly MultipliedObjectManager<TankBeam> manager =
|
||||
private static readonly MultipliedObjectManager<TankBeam> Manager =
|
||||
new MultipliedObjectManager<TankBeam>(ConfigureBeam);
|
||||
|
||||
public static ConfigEntry<float> hoverClearanceMultiplier;
|
||||
@@ -39,15 +39,15 @@ namespace TerraTech {
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(TankBeam), "EnableBeam")]
|
||||
static void PostfixCreate(TankBeam __instance, ref bool enable) {
|
||||
public static void PostfixCreate(TankBeam __instance, ref bool enable) {
|
||||
if (enable)
|
||||
manager.OnObjectAttached(__instance);
|
||||
Manager.OnObjectAttached(__instance);
|
||||
else
|
||||
manager.OnObjectDetached(__instance);
|
||||
Manager.OnObjectDetached(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
manager.ApplyAll();
|
||||
Manager.ApplyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user