Add house flipper mods
This commit is contained in:
16
Projects/HouseFlipper/HouseFlipper.sln
Normal file
16
Projects/HouseFlipper/HouseFlipper.sln
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HouseFlipper", "HouseFlipper\HouseFlipper.csproj", "{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
79
Projects/HouseFlipper/HouseFlipper/BeamPropertiesManager.cs
Normal file
79
Projects/HouseFlipper/HouseFlipper/BeamPropertiesManager.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class BeamPropertiesManager {
|
||||
private static Dictionary<ModuleItemHolderBeam, float> strenghts = new Dictionary<ModuleItemHolderBeam, float>();
|
||||
private static Dictionary<ModuleItemHolderBeam, float> radii = new Dictionary<ModuleItemHolderBeam, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnAttached")]
|
||||
static void PostfixCreate(ModuleItemHolderBeam __instance) {
|
||||
// Console.WriteLine("ModuleItemHolderBeam.OnAttached");
|
||||
if (!strenghts.ContainsKey(__instance)) {
|
||||
strenghts.Add(__instance, GetStrength(__instance));
|
||||
radii.Add(__instance, GetRadius(__instance));
|
||||
// Console.WriteLine("Patching {0}; m_BeamStrength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_BeamStrength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemHolderBeam __instance) {
|
||||
// Console.WriteLine("ModuleItemHolderBeam.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_BeamStrength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_BeamStrength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
strenghts.Remove(__instance);
|
||||
radii.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleItemHolderBeam", strenghts.Count);
|
||||
foreach (KeyValuePair<ModuleItemHolderBeam, float> keyValuePair in strenghts) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleItemHolderBeam moduleItemHolderBeam) {
|
||||
SetStrength(moduleItemHolderBeam, strenghts[moduleItemHolderBeam] * Main.beamStrenghtMultiplier.Value);
|
||||
SetRadius(moduleItemHolderBeam, radii[moduleItemHolderBeam] * Main.beamRadiusMultiplier.Value);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleItemHolderBeam moduleItemHolderBeam) {
|
||||
if (strenghts.ContainsKey(moduleItemHolderBeam)) {
|
||||
SetStrength(moduleItemHolderBeam, strenghts[moduleItemHolderBeam]);
|
||||
SetRadius(moduleItemHolderBeam, radii[moduleItemHolderBeam]);
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetStrength(ModuleItemHolderBeam moduleItemHolderBeam) {
|
||||
return Traverse.Create(moduleItemHolderBeam).Field("m_BeamStrength").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetStrength(ModuleItemHolderBeam moduleItemHolderBeam, float value) {
|
||||
Traverse.Create(moduleItemHolderBeam).Field("m_BeamStrength").SetValue(value);
|
||||
}
|
||||
|
||||
private static float GetRadius(ModuleItemHolderBeam moduleItemHolderBeam) {
|
||||
ModuleItemPickup moduleItemPickup = Traverse.Create(moduleItemHolderBeam).Field("m_Pickup").GetValue() as ModuleItemPickup;
|
||||
if (moduleItemPickup) {
|
||||
float radius = Traverse.Create(moduleItemPickup).Field("m_PickupRange").GetValue() as float? ?? 0f;
|
||||
return radius;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private static void SetRadius(ModuleItemHolderBeam moduleItemHolderBeam, float value) {
|
||||
ModuleItemPickup moduleItemPickup = Traverse.Create(moduleItemHolderBeam).Field("m_Pickup").GetValue() as ModuleItemPickup;
|
||||
if (moduleItemPickup) {
|
||||
Traverse.Create(moduleItemPickup).Field("m_PickupRange").SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
Projects/HouseFlipper/HouseFlipper/Class1.cs
Normal file
121
Projects/HouseFlipper/HouseFlipper/Class1.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System.Linq;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using HarmonyLib.Tools;
|
||||
|
||||
// TODO: Make shield and repair bigger
|
||||
// TODO: Maybe make props faster, thrusters work fine
|
||||
|
||||
namespace HouseFlipper {
|
||||
[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";
|
||||
|
||||
public static ConfigEntry<float> xpMultiplier;
|
||||
public static ConfigEntry<float> moneyMultiplier;
|
||||
public static ConfigEntry<float> energyGenMultiplier;
|
||||
public static ConfigEntry<float> heartbeatIntervalMultiplier;
|
||||
public static ConfigEntry<float> shootingSpeedMultiplier;
|
||||
public static ConfigEntry<float> muzzleVelocityMultiplier;
|
||||
public static ConfigEntry<bool> allProjectilesHoming;
|
||||
public static ConfigEntry<float> magnetStrenghtMultiplier;
|
||||
public static ConfigEntry<float> magnetRadiusMultiplier;
|
||||
public static ConfigEntry<float> beamStrenghtMultiplier;
|
||||
public static ConfigEntry<float> beamRadiusMultiplier;
|
||||
public static ConfigEntry<float> fuelTankRefillMultiplier;
|
||||
public static ConfigEntry<float> fuelTankCapacityMultiplier;
|
||||
public static ConfigEntry<float> minerGroundArea;
|
||||
public static ConfigEntry<float> minerMiningSpeed;
|
||||
public static ConfigEntry<float> wheelTorqueMultiplier;
|
||||
public static ConfigEntry<float> wheelSpeedMultiplier;
|
||||
public static ConfigEntry<float> jetThrustMultiplier;
|
||||
public static ConfigEntry<float> seekingProjectileVisionConeAngleMultiplier;
|
||||
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
||||
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
||||
public static ConfigEntry<float> wirelessChargingRadiusMultiplier;
|
||||
public static ConfigEntry<float> wirelessChargingPowerPerArcMultiplier;
|
||||
public static ConfigEntry<float> wirelessChargingArcFiringIntervalMultiplier;
|
||||
|
||||
public void Awake() {
|
||||
xpMultiplier = Config.Bind("General", "XP Multiplier", 1f, new ConfigDescription("XP Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
moneyMultiplier = Config.Bind("General", "Money Multiplier", 1f,
|
||||
new ConfigDescription("Money Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
energyGenMultiplier = Config.Bind("General", "Energy Generation Multiplier", 1f,
|
||||
new ConfigDescription("Energy Generation Multiplier", new AcceptableValueRange<float>(1f, 64f)));
|
||||
heartbeatIntervalMultiplier = Config.Bind("General", "Heartbeat Interval Multiplier", 1f,
|
||||
new ConfigDescription("Heartbeat Interval Multiplier", new AcceptableValueRange<float>(0.1f, 2f)));
|
||||
|
||||
shootingSpeedMultiplier = Config.Bind("Weapons", "Shooting Speed Multiplier", 1f,
|
||||
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(0.2f, 8f)));
|
||||
muzzleVelocityMultiplier = Config.Bind("Weapons", "Muzzle Velocity Multiplier", 1f,
|
||||
new ConfigDescription("Muzzle Velocity Multiplier", new AcceptableValueRange<float>(0.2f, 32f)));
|
||||
seekingProjectileVisionConeAngleMultiplier = Config.Bind("Weapons", "Seeking Projectile Cone Vision Angle Multiplier", 1f,
|
||||
new ConfigDescription("Seeking Projectile Cone Vision Angle Multiplier", new AcceptableValueRange<float>(0.2f, 32f)));
|
||||
seekingProjectileVisionRangeMultiplier = Config.Bind("Weapons", "Seeking Projectile Vision Range Multiplier", 1f,
|
||||
new ConfigDescription("Seeking Projectile Vision Range Multiplier", new AcceptableValueRange<float>(0.2f, 32f)));
|
||||
seekingProjectileTurningSpeedMultiplier = Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
||||
new ConfigDescription("Seeking Projectile Turn Speed Multiplier", new AcceptableValueRange<float>(0.2f, 32f)));
|
||||
|
||||
magnetStrenghtMultiplier = Config.Bind("Attractors", "Magnet Strength Multiplier", 1f,
|
||||
new ConfigDescription("Magnet Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||
magnetRadiusMultiplier = Config.Bind("Attractors", "Magnet Radius Multiplier", 1f,
|
||||
new ConfigDescription("Magnet Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||
beamStrenghtMultiplier = Config.Bind("Attractors", "Beam Strength Multiplier", 1f,
|
||||
new ConfigDescription("Beam Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||
beamRadiusMultiplier = Config.Bind("Attractors", "Beam Radius Multiplier", 1f,
|
||||
new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||
|
||||
wirelessChargingRadiusMultiplier = Config.Bind("Power", "Wireless Charger Radius Multiplier", 1f,
|
||||
new ConfigDescription("Wireless Charger Radius Multiplier", new AcceptableValueRange<float>(0.2f, 16f)));
|
||||
wirelessChargingArcFiringIntervalMultiplier = Config.Bind("Power", "Wireless Charger Arc Firing Interval", 1f,
|
||||
new ConfigDescription("Wireless Charger Arc Firing Interval", new AcceptableValueRange<float>(0.02f, 16f)));
|
||||
wirelessChargingPowerPerArcMultiplier = Config.Bind("Power", "Wireless Charger Power Per Arc", 1f,
|
||||
new ConfigDescription("Wireless Charger Power Per Arc", new AcceptableValueRange<float>(0.2f, 16f)));
|
||||
|
||||
fuelTankRefillMultiplier = Config.Bind("Propulsion", "Fuel Tank Refill Rate Multiplier", 1f,
|
||||
new ConfigDescription("Fuel Tank Refill Rate Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
fuelTankCapacityMultiplier = Config.Bind("Propulsion", "Fuel Tank Capacity Multiplier", 1f,
|
||||
new ConfigDescription("Fuel Tank Capacity Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
wheelTorqueMultiplier = Config.Bind("Propulsion", "Wheel Torque Multiplier", 1f,
|
||||
new ConfigDescription("Wheel Torque Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
wheelSpeedMultiplier = Config.Bind("Propulsion", "Wheel Max RPM Multiplier", 1f,
|
||||
new ConfigDescription("Wheel Max RPM Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
jetThrustMultiplier = Config.Bind("Propulsion", "Jet Thrust Multiplier", 1f,
|
||||
new ConfigDescription("Jet Thrust Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||
|
||||
minerGroundArea = Config.Bind("Production", "Miner Ground Deposit Scan Area", 1f,
|
||||
new ConfigDescription("Miner Ground Deposit Scan Area", new AcceptableValueRange<float>(1f, 32f)));
|
||||
minerMiningSpeed = Config.Bind("Production", "Miner Mining Speed", 1f,
|
||||
new ConfigDescription("Miner Mining Speed", new AcceptableValueRange<float>(1f, 32f)));
|
||||
|
||||
allProjectilesHoming = Config.Bind("General", "Make All Projectiles Home", false);
|
||||
|
||||
shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||
energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
||||
magnetStrenghtMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||
magnetRadiusMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||
beamStrenghtMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
||||
beamRadiusMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
||||
fuelTankRefillMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
||||
fuelTankCapacityMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
||||
wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
||||
wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
||||
jetThrustMultiplier.SettingChanged += (sender, args) => ThrusterPropertiesManager.DoPatch();
|
||||
minerGroundArea.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
||||
minerMiningSpeed.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
||||
wirelessChargingPowerPerArcMultiplier.SettingChanged += (sender, args) => WirelessChargerPropertiesManager.DoPatch();
|
||||
wirelessChargingArcFiringIntervalMultiplier.SettingChanged += (sender, args) => WirelessChargerPropertiesManager.DoPatch();
|
||||
wirelessChargingRadiusMultiplier.SettingChanged += (sender, args) => WirelessChargerPropertiesManager.DoPatch();
|
||||
|
||||
Logger.LogInfo("Cyka mod loaded");
|
||||
HarmonyFileLog.Enabled = true;
|
||||
Harmony harmony = new Harmony(pluginGuid);
|
||||
harmony.PatchAll();
|
||||
var originalMethods = harmony.GetPatchedMethods();
|
||||
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
||||
}
|
||||
}
|
||||
}
|
55
Projects/HouseFlipper/HouseFlipper/FuelPropertiesManager.cs
Normal file
55
Projects/HouseFlipper/HouseFlipper/FuelPropertiesManager.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class FuelPropertiesManager {
|
||||
private static Dictionary<ModuleFuelTank, float> refillRate = new Dictionary<ModuleFuelTank, float>();
|
||||
private static Dictionary<ModuleFuelTank, float> capacity = new Dictionary<ModuleFuelTank, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")]
|
||||
static void PostfixCreate(ModuleFuelTank __instance) {
|
||||
// Console.WriteLine("ModuleFuelTank.OnAttached");
|
||||
if (!refillRate.ContainsKey(__instance)) {
|
||||
refillRate.Add(__instance, __instance.m_RefillRate);
|
||||
capacity.Add(__instance, __instance.m_Capacity);
|
||||
// Console.WriteLine("Patching {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleFuelTank __instance) {
|
||||
// Console.WriteLine("ModuleFuelTank.OnAttached");
|
||||
// Console.WriteLine("Restoring {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
refillRate.Remove(__instance);
|
||||
capacity.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleFuelTank", refillRate.Count);
|
||||
foreach (KeyValuePair<ModuleFuelTank, float> keyValuePair in refillRate) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleFuelTank moduleFuelTank) {
|
||||
moduleFuelTank.m_RefillRate = refillRate[moduleFuelTank] * Main.fuelTankRefillMultiplier.Value;
|
||||
moduleFuelTank.m_Capacity = capacity[moduleFuelTank] * Main.fuelTankCapacityMultiplier.Value;
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleFuelTank moduleFuelTank) {
|
||||
if (refillRate.ContainsKey(moduleFuelTank)) {
|
||||
moduleFuelTank.m_RefillRate = refillRate[moduleFuelTank];
|
||||
moduleFuelTank.m_Capacity = capacity[moduleFuelTank];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class GeneratorPropertiesManager {
|
||||
private static Dictionary<ModuleEnergy, float> generators = new Dictionary<ModuleEnergy, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergy), "OnAttached")]
|
||||
static void PostfixCreate(ModuleEnergy __instance) {
|
||||
// Console.WriteLine("ModuleEnergy.OnAttached");
|
||||
if (!generators.ContainsKey(__instance)) {
|
||||
generators.Add(__instance, GetValue(__instance));
|
||||
// Console.WriteLine("Patching {0}; m_OutputPerSecond: {1}", __instance.name, GetValue(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_OutputPerSecond: {1}", __instance.name, GetValue(__instance));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleEnergy __instance) {
|
||||
// Console.WriteLine("ModuleEnergy.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_OutputPerSecond: {1}", __instance.name, GetValue(__instance));
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_OutputPerSecond: {1}", __instance.name, GetValue(__instance));
|
||||
generators.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleEnergy", generators.Count);
|
||||
foreach (KeyValuePair<ModuleEnergy, float> keyValuePair in generators) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleEnergy moduleEnergy) {
|
||||
SetValue(moduleEnergy, generators[moduleEnergy] * Main.energyGenMultiplier.Value);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleEnergy moduleEnergy) {
|
||||
if (generators.ContainsKey(moduleEnergy)) {
|
||||
SetValue(moduleEnergy, generators[moduleEnergy]);
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetValue(ModuleEnergy moduleEnergy) {
|
||||
return Traverse.Create(moduleEnergy).Field("m_OutputPerSecond").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetValue(ModuleEnergy moduleEnergy, float value) {
|
||||
Traverse.Create(moduleEnergy).Field("m_OutputPerSecond").SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch(typeof(Projectile), "Fire")]
|
||||
public class HomingAndVelocityProjectilePatch {
|
||||
private static Dictionary<FireData, float> velocities = new Dictionary<FireData, float>();
|
||||
|
||||
static void Prefix(Vector3 fireDirection, ref FireData fireData, ref ModuleWeaponGun weapon, Tank shooter, ref bool seekingRounds, bool replayRounds) {
|
||||
if (Main.allProjectilesHoming.Value) {
|
||||
seekingRounds = true;
|
||||
}
|
||||
if (!velocities.ContainsKey(fireData)) {
|
||||
velocities.Add(fireData, fireData.m_MuzzleVelocity);
|
||||
fireData.m_MuzzleVelocity *= Main.muzzleVelocityMultiplier.Value;
|
||||
} else if (velocities[fireData] != fireData.m_MuzzleVelocity * Main.muzzleVelocityMultiplier.Value) {
|
||||
fireData.m_MuzzleVelocity = velocities[fireData] * Main.muzzleVelocityMultiplier.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
78
Projects/HouseFlipper/HouseFlipper/HouseFlipper.csproj
Normal file
78
Projects/HouseFlipper/HouseFlipper/HouseFlipper.csproj
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TerraTech</RootNamespace>
|
||||
<AssemblyName>TerraTech</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BeamPropertiesManager.cs" />
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="FuelPropertiesManager.cs" />
|
||||
<Compile Include="GeneratorPropertiesManager.cs" />
|
||||
<Compile Include="HomingAndVelocityProjectilePatch.cs" />
|
||||
<Compile Include="MagnetPropertiesManager.cs" />
|
||||
<Compile Include="MinerPropertiesManager.cs" />
|
||||
<Compile Include="Patches.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SeekingProjectileManager.cs" />
|
||||
<Compile Include="ThrusterPropertiesManager.cs" />
|
||||
<Compile Include="WeaponPropertiesManager.cs" />
|
||||
<Compile Include="WheelPropertiesManager.cs" />
|
||||
<Compile Include="WirelessChargerPropertiesManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>..\libs\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\libs\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BepInEx">
|
||||
<HintPath>..\libs\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ConfigurationManager">
|
||||
<HintPath>..\libs\ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\libs\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\libs\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class MagnetPropertiesManager {
|
||||
private static Dictionary<ModuleItemHolderMagnet, float> strenghts = new Dictionary<ModuleItemHolderMagnet, float>();
|
||||
private static Dictionary<ModuleItemHolderMagnet, float> radii = new Dictionary<ModuleItemHolderMagnet, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnAttached")]
|
||||
static void PostfixCreate(ModuleItemHolderMagnet __instance) {
|
||||
// Console.WriteLine("ModuleItemHolderMagnet.OnAttached");
|
||||
if (!strenghts.ContainsKey(__instance)) {
|
||||
strenghts.Add(__instance, GetStrength(__instance));
|
||||
radii.Add(__instance, GetRadius(__instance));
|
||||
// Console.WriteLine("Patching {0}; m_Strength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_Strength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemHolderMagnet __instance) {
|
||||
// Console.WriteLine("ModuleItemHolderMagnet.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_Strength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_Strength: {1}; m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), GetRadius(__instance));
|
||||
strenghts.Remove(__instance);
|
||||
radii.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleItemHolderMagnet", strenghts.Count);
|
||||
foreach (KeyValuePair<ModuleItemHolderMagnet, float> keyValuePair in strenghts) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleItemHolderMagnet moduleItemHolderMagnet) {
|
||||
SetStrength(moduleItemHolderMagnet, strenghts[moduleItemHolderMagnet] * Main.magnetStrenghtMultiplier.Value);
|
||||
SetRadius(moduleItemHolderMagnet, radii[moduleItemHolderMagnet] * Main.magnetRadiusMultiplier.Value);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleItemHolderMagnet moduleItemHolderMagnet) {
|
||||
if (strenghts.ContainsKey(moduleItemHolderMagnet)) {
|
||||
SetStrength(moduleItemHolderMagnet, strenghts[moduleItemHolderMagnet]);
|
||||
}
|
||||
if (radii.ContainsKey(moduleItemHolderMagnet)) {
|
||||
SetRadius(moduleItemHolderMagnet, radii[moduleItemHolderMagnet]);
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetStrength(ModuleItemHolderMagnet moduleItemHolderMagnet) {
|
||||
return Traverse.Create(moduleItemHolderMagnet).Field("m_Strength").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetStrength(ModuleItemHolderMagnet moduleItemHolderMagnet, float value) {
|
||||
Traverse.Create(moduleItemHolderMagnet).Field("m_Strength").SetValue(value);
|
||||
}
|
||||
|
||||
private static float GetRadius(ModuleItemHolderMagnet moduleItemHolderMagnet) {
|
||||
ModuleItemPickup moduleItemPickup = Traverse.Create(moduleItemHolderMagnet).Field("m_Pickup").GetValue() as ModuleItemPickup;
|
||||
if (moduleItemPickup) {
|
||||
float radius = Traverse.Create(moduleItemPickup).Field("m_PickupRange").GetValue() as float? ?? 0f;
|
||||
return radius;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private static void SetRadius(ModuleItemHolderMagnet moduleItemHolderMagnet, float value) {
|
||||
ModuleItemPickup moduleItemPickup = Traverse.Create(moduleItemHolderMagnet).Field("m_Pickup").GetValue() as ModuleItemPickup;
|
||||
if (moduleItemPickup) {
|
||||
Traverse.Create(moduleItemPickup).Field("m_PickupRange").SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
86
Projects/HouseFlipper/HouseFlipper/MinerPropertiesManager.cs
Normal file
86
Projects/HouseFlipper/HouseFlipper/MinerPropertiesManager.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class MinerPropertiesManager {
|
||||
private static Dictionary<ModuleItemProducer, float> area = new Dictionary<ModuleItemProducer, float>();
|
||||
private static Dictionary<ModuleItemProducer, float> speed = new Dictionary<ModuleItemProducer, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
||||
static void PostfixCreate(ModuleItemProducer __instance) {
|
||||
// Console.WriteLine("ModuleItemProducer.GetClosestResourceReservoirInRange");
|
||||
if (!area.ContainsKey(__instance)) {
|
||||
area.Add(__instance, GetArea(__instance));
|
||||
speed.Add(__instance, GetSpeed(__instance));
|
||||
// Console.WriteLine("Patching {0}; m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance),
|
||||
// GetSpeed(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance),
|
||||
// GetSpeed(__instance));
|
||||
} else {
|
||||
if (GetArea(__instance) == area[__instance]) {
|
||||
// Console.WriteLine("{0} area reset, patching again... m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name,
|
||||
// GetArea(__instance), GetSpeed(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance),
|
||||
// GetSpeed(__instance));
|
||||
}
|
||||
if (GetSpeed(__instance) == speed[__instance]) {
|
||||
// Console.WriteLine("{0} speed reset, patching again... m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name,
|
||||
// GetArea(__instance), GetSpeed(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance),
|
||||
// GetSpeed(__instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ModuleItemProducer), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleItemProducer __instance) {
|
||||
// Console.WriteLine("ModuleItemProducer.OnRecycle");
|
||||
DoRestoreSingle(__instance);
|
||||
area.Remove(__instance);
|
||||
speed.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleItemProducer", area.Count);
|
||||
foreach (KeyValuePair<ModuleItemProducer, float> keyValuePair in area) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleItemProducer moduleItemProducer) {
|
||||
SetArea(moduleItemProducer, area[moduleItemProducer] * Main.minerGroundArea.Value);
|
||||
SetSpeed(moduleItemProducer, speed[moduleItemProducer] / Main.minerMiningSpeed.Value);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleItemProducer moduleItemProducer) {
|
||||
if (area.ContainsKey(moduleItemProducer)) {
|
||||
SetArea(moduleItemProducer, area[moduleItemProducer]);
|
||||
SetSpeed(moduleItemProducer, speed[moduleItemProducer]);
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetArea(ModuleItemProducer moduleItemProducer) {
|
||||
return Traverse.Create(moduleItemProducer).Field("m_ResourceGroundRadius").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetArea(ModuleItemProducer moduleItemProducer, float value) {
|
||||
Traverse.Create(moduleItemProducer).Field("m_ResourceGroundRadius").SetValue(value);
|
||||
}
|
||||
|
||||
private static float GetSpeed(ModuleItemProducer moduleItemProducer) {
|
||||
return Traverse.Create(moduleItemProducer).Field("m_SecPerItemProduced").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetSpeed(ModuleItemProducer moduleItemProducer, float value) {
|
||||
Traverse.Create(moduleItemProducer).Field("m_SecPerItemProduced").SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
24
Projects/HouseFlipper/HouseFlipper/Patches.cs
Normal file
24
Projects/HouseFlipper/HouseFlipper/Patches.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class Patches {
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
||||
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
||||
xp = (int)(xp * Main.xpMultiplier.Value);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ManPlayer), "AddMoney")]
|
||||
static void MoneyMulti(ref int amount) {
|
||||
amount = (int)(amount * Main.moneyMultiplier.Value);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")]
|
||||
static void HeartbeatMulti(ref float interval) {
|
||||
interval *= Main.heartbeatIntervalMultiplier.Value;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TerraTech")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TerraTech")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
public class SeekingProjectileManager {
|
||||
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
||||
class Patch {
|
||||
static void Postfix(SeekingProjectile __instance) {
|
||||
Console.WriteLine("SeekingProjectile created");
|
||||
SetField(__instance, "m_VisionConeAngle", Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
||||
SetField(__instance, "m_VisionRange", Main.seekingProjectileVisionRangeMultiplier.Value * GetField(__instance, "m_VisionRange"));
|
||||
SetField(__instance, "m_TurnSpeed", Main.seekingProjectileTurningSpeedMultiplier.Value * GetField(__instance, "m_TurnSpeed"));
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetField(SeekingProjectile seekingProjectile, string field) {
|
||||
return Traverse.Create(seekingProjectile).Field(field).GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetField(SeekingProjectile seekingProjectile, string field, float value) {
|
||||
Traverse.Create(seekingProjectile).Field(field).SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ThrusterPropertiesManager {
|
||||
private static Dictionary<ModuleBooster, Dictionary<BoosterJet, float>> boosters = new Dictionary<ModuleBooster, Dictionary<BoosterJet, float>>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleBooster), "OnAttached")]
|
||||
static void PostfixCreate(ModuleBooster __instance) {
|
||||
// Console.WriteLine("ModuleBooster.OnAttached");
|
||||
if (!boosters.ContainsKey(__instance)) {
|
||||
boosters.Add(__instance, Map(__instance));
|
||||
// Console.WriteLine("Patching {0}; force: {1}", __instance.name, GetForceAsString(__instance));
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; force: {1}", __instance.name, GetForceAsString(__instance));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleBooster), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleBooster __instance) {
|
||||
// Console.WriteLine("ModuleBooster.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; force: {1}", __instance.name, GetForceAsString(__instance));
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; force: {1}", __instance.name, GetForceAsString(__instance));
|
||||
boosters.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleBooster", boosters.Count);
|
||||
foreach (KeyValuePair<ModuleBooster, Dictionary<BoosterJet, float>> keyValuePair in boosters) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleBooster moduleBooster) {
|
||||
List<BoosterJet> jets = GetValue(moduleBooster);
|
||||
for (var i = 0; i < jets.Count; i++) {
|
||||
boosters[moduleBooster][jets[i]] = GetValue(jets[i]);
|
||||
SetValue(jets[i], GetValue(jets[i]) * Main.jetThrustMultiplier.Value);
|
||||
}
|
||||
SetValue(moduleBooster, jets);
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleBooster moduleBooster) {
|
||||
if (boosters.ContainsKey(moduleBooster)) {
|
||||
foreach (BoosterJet boosterJet in GetValue(moduleBooster)) {
|
||||
SetValue(boosterJet, boosters[moduleBooster][boosterJet]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<BoosterJet, float> Map(ModuleBooster moduleBooster) {
|
||||
Dictionary<BoosterJet, float> jets = new Dictionary<BoosterJet, float>();
|
||||
foreach (BoosterJet boosterJet in GetValue(moduleBooster)) {
|
||||
jets.Add(boosterJet, GetValue(boosterJet));
|
||||
}
|
||||
return jets;
|
||||
}
|
||||
|
||||
private static List<BoosterJet> GetValue(ModuleBooster moduleBooster) {
|
||||
return Traverse.Create(moduleBooster).Field("jets").GetValue() as List<BoosterJet>;
|
||||
}
|
||||
|
||||
private static void SetValue(ModuleBooster moduleBooster, List<BoosterJet> value) {
|
||||
Traverse.Create(moduleBooster).Field("jets").SetValue(value);
|
||||
}
|
||||
|
||||
private static float GetValue(BoosterJet boosterJet) {
|
||||
return Traverse.Create(boosterJet).Field("m_Force").GetValue() as float? ?? 0f;
|
||||
}
|
||||
|
||||
private static void SetValue(BoosterJet boosterJet, float value) {
|
||||
Traverse.Create(boosterJet).Field("m_Force").SetValue(value);
|
||||
}
|
||||
|
||||
private static string GetForceAsString(ModuleBooster moduleBooster) {
|
||||
string result = "";
|
||||
foreach (BoosterJet boosterJet in GetValue(moduleBooster)) {
|
||||
result += GetValue(boosterJet) + ", ";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class WeaponPropertiesManager {
|
||||
private static Dictionary<ModuleWeaponGun, float> shotCooldown = new Dictionary<ModuleWeaponGun, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
||||
// Console.WriteLine("ModuleWeaponGun.OnAttached");
|
||||
if (!shotCooldown.ContainsKey(__instance)) {
|
||||
shotCooldown.Add(__instance, __instance.m_ShotCooldown);
|
||||
// Console.WriteLine("Patching {0}; m_ShotCooldown: {1}", __instance.name, __instance.m_ShotCooldown);
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_ShotCooldown: {1}", __instance.name, __instance.m_ShotCooldown);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
||||
// Console.WriteLine("ModuleWeaponGun.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_ShotCooldown: {1}", __instance.name, __instance.m_ShotCooldown);
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_ShotCooldown: {1}", __instance.name, __instance.m_ShotCooldown);
|
||||
shotCooldown.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleWeaponGun", shotCooldown.Count);
|
||||
foreach (KeyValuePair<ModuleWeaponGun, 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 DoRestoreSingle(ModuleWeaponGun moduleWeaponGun) {
|
||||
if (shotCooldown.ContainsKey(moduleWeaponGun)) {
|
||||
moduleWeaponGun.m_ShotCooldown = shotCooldown[moduleWeaponGun];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
63
Projects/HouseFlipper/HouseFlipper/WheelPropertiesManager.cs
Normal file
63
Projects/HouseFlipper/HouseFlipper/WheelPropertiesManager.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class WheelPropertiesManager {
|
||||
private static Dictionary<ModuleWheels, float> torques = new Dictionary<ModuleWheels, float>();
|
||||
private static Dictionary<ModuleWheels, float> maxRpm = new Dictionary<ModuleWheels, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWheels), "OnAttached")]
|
||||
static void PostfixCreate(ModuleWheels __instance) {
|
||||
// Console.WriteLine("ModuleWheels.OnAttached");
|
||||
if (!torques.ContainsKey(__instance)) {
|
||||
torques.Add(__instance, __instance.m_TorqueParams.torqueCurveMaxTorque);
|
||||
maxRpm.Add(__instance, __instance.m_TorqueParams.torqueCurveMaxRpm);
|
||||
// Console.WriteLine("Patching {0}; m_TorqueParams.torqueCurveMaxTorque: {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxTorque,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxRpm);
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_TorqueParams.torqueCurveMaxTorque: {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxTorque,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxRpm);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleWheels), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleWheels __instance) {
|
||||
// Console.WriteLine("ModuleWheels.OnDetaching");
|
||||
// Console.WriteLine("Restoring {0}; m_TorqueParams.torqueCurveMaxTorque: {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxTorque,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxRpm);
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_TorqueParams.torqueCurveMaxTorque: {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxTorque,
|
||||
// __instance.m_TorqueParams.torqueCurveMaxRpm);
|
||||
torques.Remove(__instance);
|
||||
maxRpm.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleWheels", torques.Count);
|
||||
foreach (KeyValuePair<ModuleWheels, float> keyValuePair in torques) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleWheels moduleWheels) {
|
||||
moduleWheels.m_TorqueParams.torqueCurveMaxRpm = maxRpm[moduleWheels] * Main.wheelSpeedMultiplier.Value;
|
||||
moduleWheels.m_TorqueParams.torqueCurveMaxTorque = torques[moduleWheels] * Main.wheelTorqueMultiplier.Value;
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleWheels moduleWheels) {
|
||||
if (torques.ContainsKey(moduleWheels)) {
|
||||
moduleWheels.m_TorqueParams.torqueCurveMaxTorque = torques[moduleWheels];
|
||||
moduleWheels.m_TorqueParams.torqueCurveMaxRpm = maxRpm[moduleWheels];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
|
||||
// TODO: Fix this, no workey
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class WirelessChargerPropertiesManager {
|
||||
private static Dictionary<ModuleRemoteCharger, float> radius = new Dictionary<ModuleRemoteCharger, float>();
|
||||
private static Dictionary<ModuleRemoteCharger, float> transferPerArc = new Dictionary<ModuleRemoteCharger, float>();
|
||||
private static Dictionary<ModuleRemoteCharger, float> arcFiringInterval = new Dictionary<ModuleRemoteCharger, float>();
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")]
|
||||
static void PostfixCreate(ModuleRemoteCharger __instance) {
|
||||
// Console.WriteLine("ModuleRemoteCharger.OnAttached");
|
||||
if (!radius.ContainsKey(__instance)) {
|
||||
radius.Add(__instance, __instance.m_ChargingRadius);
|
||||
transferPerArc.Add(__instance, __instance.m_PowerTransferPerArc);
|
||||
arcFiringInterval.Add(__instance, __instance.m_ArcFiringInterval);
|
||||
// Console.WriteLine("Patching {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
DoPatchSingle(__instance);
|
||||
// Console.WriteLine("Patched {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ModuleRemoteCharger), "OnDetaching")]
|
||||
static void PostfixDestroy(ModuleRemoteCharger __instance) {
|
||||
// Console.WriteLine("ModuleRemoteCharger.OnAttached");
|
||||
// Console.WriteLine("Restoring {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
DoRestoreSingle(__instance);
|
||||
// Console.WriteLine("Restored {0}; m_RefillRate: {1}; m_Capacity: {2}", __instance.name, __instance.m_RefillRate, __instance.m_Capacity);
|
||||
radius.Remove(__instance);
|
||||
transferPerArc.Remove(__instance);
|
||||
arcFiringInterval.Remove(__instance);
|
||||
}
|
||||
|
||||
public static void DoPatch() {
|
||||
// Console.WriteLine("Modifying {0} ModuleRemoteCharger", radius.Count);
|
||||
foreach (KeyValuePair<ModuleRemoteCharger, float> keyValuePair in radius) {
|
||||
DoRestoreSingle(keyValuePair.Key);
|
||||
DoPatchSingle(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
static void DoPatchSingle(ModuleRemoteCharger moduleRemoteCharger) {
|
||||
moduleRemoteCharger.m_ChargingRadius = radius[moduleRemoteCharger] * Main.wirelessChargingRadiusMultiplier.Value;
|
||||
moduleRemoteCharger.m_PowerTransferPerArc = radius[moduleRemoteCharger] * Main.wirelessChargingPowerPerArcMultiplier.Value;
|
||||
moduleRemoteCharger.m_ArcFiringInterval = radius[moduleRemoteCharger] * Main.wirelessChargingArcFiringIntervalMultiplier.Value;
|
||||
}
|
||||
|
||||
static void DoRestoreSingle(ModuleRemoteCharger moduleRemoteCharger) {
|
||||
if (radius.ContainsKey(moduleRemoteCharger)) {
|
||||
moduleRemoteCharger.m_ChargingRadius = radius[moduleRemoteCharger];
|
||||
moduleRemoteCharger.m_PowerTransferPerArc = radius[moduleRemoteCharger];
|
||||
moduleRemoteCharger.m_ArcFiringInterval = radius[moduleRemoteCharger];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\TerraTech.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\TerraTech.pdb
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\0Harmony.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\Assembly-CSharp.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\BepInEx.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\UnityEngine.CoreModule.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\UnityEngine.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\obj\Debug\TerraTech.csprojResolveAssemblyReference.cache
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\obj\Debug\TerraTech.dll
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\obj\Debug\TerraTech.pdb
|
||||
C:\Users\Administrator\RiderProjects\Bepinex\Projects\TerraTech\TerraTech\bin\Debug\ConfigurationManager.dll
|
Binary file not shown.
11
Projects/HouseFlipper/TerraTech.sln.DotSettings.user
Normal file
11
Projects/HouseFlipper/TerraTech.sln.DotSettings.user
Normal file
@@ -0,0 +1,11 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005C0Harmony_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CAssembly_002DCSharp_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CBepInEx_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CAdministrator_005CRiderProjects_005CBepinex_005CProjects_005CTerraTech_005Clibs_005CConfigurationManager_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: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:Int64 x:Key="/Default/Environment/Hierarchy/Build/BuildTool/MsbuildVersion/@EntryValue">262144</s:Int64>
|
||||
</wpf:ResourceDictionary>
|
6
Projects/HouseFlipper/libs/test.txt
Normal file
6
Projects/HouseFlipper/libs/test.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
0Harmony.dll*
|
||||
Assembly-CSharp.dll*
|
||||
BepInEx.dll*
|
||||
UnityEngine.CoreModule.dll*
|
||||
UnityEngine.dll*
|
||||
test.txt
|
Reference in New Issue
Block a user