"Fix" rotation speed maybe
This commit is contained in:
@@ -130,6 +130,7 @@ namespace TerraTech {
|
||||
allProjectilesHoming = Config.Bind("General", "Make All Projectiles Home", false);
|
||||
|
||||
shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||
weaponRotationSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||
energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
||||
magnetStrenghtMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||
magnetRadiusMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||
|
@@ -21,15 +21,5 @@ namespace TerraTech {
|
||||
static void HeartbeatMulti(ref float interval) {
|
||||
interval *= Main.heartbeatIntervalMultiplier.Value;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "RotateSpeed", MethodType.Getter)]
|
||||
static void WeaponRotationSpeedMulti(ref float __result) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("WeaponRotationSpeedMulti: {0}", __result);
|
||||
__result *= Main.weaponRotationSpeedMultiplier.Value;
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("WeaponRotationSpeedMulti: {0}", __result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,11 +6,11 @@ using HarmonyLib;
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class WeaponPropertiesManager {
|
||||
private static Dictionary<ModuleWeaponGun, float> shotCooldown = new Dictionary<ModuleWeaponGun, float>();
|
||||
private static Dictionary<ModuleWeapon, float> shotCooldown = new Dictionary<ModuleWeapon, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||
[HarmonyPatch(typeof(ModuleWeapon), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWeapon __instance) {
|
||||
// Console.WriteLine("ModuleWeaponGun.OnAttached");
|
||||
if (!shotCooldown.ContainsKey(__instance)) {
|
||||
shotCooldown.Add(__instance, __instance.m_ShotCooldown);
|
||||
@@ -23,8 +23,8 @@ namespace TerraTech {
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||
[HarmonyPatch(typeof(ModuleWeapon), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWeapon __instance) {
|
||||
// Console.WriteLine("ModuleWeaponGun.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_ShotCooldown: {1}", __instance.name,
|
||||
// __instance.m_ShotCooldown);
|
||||
@@ -36,20 +36,30 @@ namespace TerraTech {
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleWeaponGun", shotCooldown.Count);
|
||||
foreach (KeyValuePair<ModuleWeaponGun, float> keyValuePair in shotCooldown) {
|
||||
foreach (KeyValuePair<ModuleWeapon, float> keyValuePair in shotCooldown) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleWeaponGun moduleWeaponGun) {
|
||||
moduleWeaponGun.m_ShotCooldown = shotCooldown[moduleWeaponGun] / Main.shootingSpeedMultiplier.Value;
|
||||
static void DoPatchSingle(ModuleWeapon moduleWeapon) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Patching {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown);
|
||||
moduleWeapon.m_ShotCooldown = shotCooldown[moduleWeapon] / Main.shootingSpeedMultiplier.Value;
|
||||
moduleWeapon.m_RotateSpeed *= Main.weaponRotationSpeedMultiplier.Value;
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Patched {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleWeaponGun moduleWeaponGun) {
|
||||
if (shotCooldown.ContainsKey(moduleWeaponGun)) {
|
||||
moduleWeaponGun.m_ShotCooldown = shotCooldown[moduleWeaponGun];
|
||||
static void DoRestoreSingle(ModuleWeapon moduleWeapon) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Restoring {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown);
|
||||
if (shotCooldown.ContainsKey(moduleWeapon)) {
|
||||
moduleWeapon.m_ShotCooldown = shotCooldown[moduleWeapon];
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Restored {0}; m_ShotCooldown: {1}", moduleWeapon.name,
|
||||
moduleWeapon.m_ShotCooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user