Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CompanyCruiserConfig v0.1.0
Tomatobird.CompanyCruiserConfig.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using CompanyCruiserConfig.Patches; using CompanyCruiserConfig.Utils; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Tomatobird.CompanyCruiserConfig")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+6a54bd5b91816e4ece04c91230b70a6875b5dff7")] [assembly: AssemblyProduct("CompanyCruiserConfig")] [assembly: AssemblyTitle("Tomatobird.CompanyCruiserConfig")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [HarmonyPatch(typeof(NetworkManager))] internal static class RegisterNetworkPrefabPatch { private static readonly string MOD_GUID = "Tomatobird.CompanyCruiserConfig"; [HarmonyPatch("SetSingleton")] [HarmonyPostfix] private static void RegisterPrefab() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(MOD_GUID + " Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject obj = val.AddComponent<NetworkObject>(); FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(obj, GetHash(MOD_GUID)); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } namespace CompanyCruiserConfig { [BepInPlugin("Tomatobird.CompanyCruiserConfig", "CompanyCruiserConfig", "0.1.0")] public class CompanyCruiserConfig : BaseUnityPlugin { public static bool editRigidbody; public static bool despawnInVoid; public static float despawnHeightThreshold; public static bool editEnemyCollisionDamage; public static int baseCarHP; public static float brakeSpeed; public static float carAcceleration; public static float carFragility; public static float carHitPlayerForceFraction; public static float carMaxSpeed; public static float carReactToPlayerHitMultiplier; public static float engineIntensityPercentage; public static float engineTorque; public static float idleSpeed; public static float jumpForce; public static float maxEngineRPM; public static float maximumBumpForce; public static float mediumBumpForce; public static float minEngineRPM; public static float minimalBumpForce; public static int movingAverageLength; public static float pushForceMultiplier; public static float pushVerticalOffsetAmount; public static float radioSignalDecreaseThreshold; public static float radioSignalQuality; public static float radioSignalTurbulence; public static float speed; public static float springForce; public static float stability; public static float steeringWheelTurnSpeed; public static float syncRotationSpeed; public static float syncSpeedMultiplier; public static float torqueForce; public static float turboBoostForce; public static float turboBoostUpwardForce; public static float angularDrag; public static float drag; public static float mass; public static float maxAngularVelocity; public static float maxDepenetrationVelocity; public static float maxLinearVelocity; public static float sleepThreshold; public static int solverIterations; public static int solverVelocityIterations; public static int smallHit; public static int largeHit; public static CompanyCruiserConfig Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; InitializeConfigs(); Patch(); Logger.LogInfo((object)"Tomatobird.CompanyCruiserConfig v0.1.0 has loaded!"); } internal void InitializeConfigs() { editRigidbody = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Edit Rigidbody", false, "Should configuration for the main rigidbody in VehicleController be enabled?").Value; despawnInVoid = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Despawn In Void", true, "Should any VehicleController object that goes below Despawn Height Threshold be despawned? This check runs in FixedUpdate()").Value; despawnHeightThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Despawn Height Threshold", -500f, "Threshold where any VehicleController object below this height will be despawned.").Value; editEnemyCollisionDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Edit Enemy Collision Damage", false, "Should configuration of enemy collision damage values be enabled?").Value; baseCarHP = ((BaseUnityPlugin)this).Config.Bind<int>("VehicleController", "Base Car HP", 30, "Initial car hp.").Value; brakeSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Brake Speed", 500f, "Vehicle braking speed.").Value; carAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Car Acceleration", 250f, "").Value; carFragility = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Car Fragility", 1f, "").Value; carHitPlayerForceFraction = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Car Hit Player Force Fraction", 30f, "").Value; carMaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Car Max Speed", 600f, "").Value; carReactToPlayerHitMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Car React To Player Hit Multiplier", 2850f, "").Value; engineIntensityPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Engine Intensity Percentage", 180f, "").Value; engineTorque = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Engine Torque", 1100f, "").Value; idleSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Idle Speed", 15f, "").Value; jumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Jump Force", 600f, "").Value; maxEngineRPM = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Max Engine RPM", 3000f, "").Value; maximumBumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Maximum Bump Force", 75000f, "").Value; mediumBumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Medium Bump Force", 30000f, "").Value; minEngineRPM = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Min Engine RPM", 1000f, "").Value; minimalBumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Minimal Bump Force", 9000f, "").Value; movingAverageLength = ((BaseUnityPlugin)this).Config.Bind<int>("VehicleController", "Moving Average Length", 20, "").Value; pushForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Push Force Multiplier", 27f, "Multiplier of the force to push the cruiser.").Value; pushVerticalOffsetAmount = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Push Vertical Offset Amount", 1f, "").Value; radioSignalDecreaseThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Radio Signal Decrease Threshold", 50f, "").Value; radioSignalQuality = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Radio Signal Quality", 3f, "").Value; radioSignalTurbulence = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Radio Signal Turbulence", 4f, "").Value; speed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Speed", 50f, "").Value; springForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Spring Force", 130f, "").Value; stability = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Stability", 0.4f, "").Value; steeringWheelTurnSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Steering Wheel Turn Speed", 4f, "").Value; syncRotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Sync Rotation Speed", 0.2f, "").Value; syncSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Sync Speed Multiplier", 10f, "").Value; torqueForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Torque Force", 2.5f, "").Value; turboBoostForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Turbo Boost Force", 3000f, "").Value; turboBoostUpwardForce = ((BaseUnityPlugin)this).Config.Bind<float>("VehicleController", "Turbo Boost Upward Force", 7200f, "").Value; angularDrag = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Angular Drag", 0.5f, "").Value; drag = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Drag", 0.01f, "").Value; mass = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Mass", 200f, "").Value; maxAngularVelocity = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Max Angular Velocity", 4f, "").Value; maxDepenetrationVelocity = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Max Depenetration Velocity", 1f, "").Value; maxLinearVelocity = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Max Linear Velocity", 50f, "").Value; sleepThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Rigidbody", "Sleep Threshold", 0.005f, "").Value; solverIterations = ((BaseUnityPlugin)this).Config.Bind<int>("Rigidbody", "Solver Iterations", 16, "").Value; solverVelocityIterations = ((BaseUnityPlugin)this).Config.Bind<int>("Rigidbody", "Solver Velocity Iterations", 2, "").Value; smallHit = ((BaseUnityPlugin)this).Config.Bind<int>("Collision", "Small Hit", 2, "").Value; largeHit = ((BaseUnityPlugin)this).Config.Bind<int>("Collision", "Large Hit", 12, "").Value; } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Tomatobird.CompanyCruiserConfig"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(typeof(VehicleControllerPatch)); Harmony.PatchAll(typeof(RegisterNetworkPrefabPatch)); if (despawnInVoid) { Harmony.PatchAll(typeof(VehicleControllerDestroyCruiserPatch)); } if (editEnemyCollisionDamage) { Harmony.PatchAll(typeof(CarReactToObstaclePatch)); } Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.CompanyCruiserConfig"; public const string PLUGIN_NAME = "CompanyCruiserConfig"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace CompanyCruiserConfig.Utils { internal class DestroyObject : MonoBehaviour { private void Awake() { Object.Destroy((Object)(object)((Component)this).gameObject); } } } namespace CompanyCruiserConfig.Patches { [HarmonyPatch(typeof(VehicleController))] internal class CarReactToObstaclePatch { [HarmonyPatch("CarReactToObstacle")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> CarReactToObstacleTranspiler(IEnumerable<CodeInstruction> instructions) { CompanyCruiserConfig.Logger.LogDebug((object)"Running CarReactToObstacleTranspiler to patch damage values."); int num = -1; int num2 = 150; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = num2; i < list.Count; i++) { if (list[i - 2].opcode == OpCodes.Ldarg_S && list[i - 1].opcode == OpCodes.Ldc_I4_2 && list[i].opcode == OpCodes.Ldarg_0) { num = i - 1; num2 = num; break; } } if (num > -1) { list[num].opcode = OpCodes.Ldc_I4_S; list[num].operand = (sbyte)CompanyCruiserConfig.smallHit; CompanyCruiserConfig.Logger.LogDebug((object)$"opcode at index {num} replaced"); } else { CompanyCruiserConfig.Logger.LogError((object)"CarReactToObstacleTranspiler failed on first inject."); } num = -1; for (int j = num2; j < list.Count; j++) { if (list[j - 2].opcode == OpCodes.Ldarg_S && list[j - 1].opcode == OpCodes.Ldc_I4_S && list[j].opcode == OpCodes.Ldloc_3) { num = j - 1; break; } } if (num > -1) { list[num].operand = (sbyte)CompanyCruiserConfig.largeHit; CompanyCruiserConfig.Logger.LogDebug((object)$"opcode at index {num} replaced"); } else { CompanyCruiserConfig.Logger.LogError((object)"CarReactToObstacleTranspiler failed on second inject."); } return list.AsEnumerable(); } } [HarmonyPatch(typeof(VehicleController))] internal class VehicleControllerDestroyCruiserPatch { [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void FixedUpdatePostfix(VehicleController __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (((Component)__instance).transform.position.y < CompanyCruiserConfig.despawnHeightThreshold) { __instance.OnDisable(); ((Component)__instance).gameObject.AddComponent<DestroyObject>(); } } } [HarmonyPatch(typeof(VehicleController))] internal class VehicleControllerPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPrefix(VehicleController __instance) { __instance.baseCarHP = CompanyCruiserConfig.baseCarHP; } [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(VehicleController __instance) { __instance.brakeSpeed = CompanyCruiserConfig.brakeSpeed; __instance.carAcceleration = CompanyCruiserConfig.carAcceleration; __instance.carFragility = CompanyCruiserConfig.carFragility; __instance.carHitPlayerForceFraction = CompanyCruiserConfig.carHitPlayerForceFraction; __instance.carMaxSpeed = CompanyCruiserConfig.carMaxSpeed; __instance.carReactToPlayerHitMultiplier = CompanyCruiserConfig.carReactToPlayerHitMultiplier; __instance.engineIntensityPercentage = CompanyCruiserConfig.engineIntensityPercentage; __instance.EngineTorque = CompanyCruiserConfig.engineTorque; __instance.idleSpeed = CompanyCruiserConfig.idleSpeed; __instance.jumpForce = CompanyCruiserConfig.jumpForce; __instance.MaxEngineRPM = CompanyCruiserConfig.maxEngineRPM; __instance.maximumBumpForce = CompanyCruiserConfig.maximumBumpForce; __instance.mediumBumpForce = CompanyCruiserConfig.mediumBumpForce; __instance.MinEngineRPM = CompanyCruiserConfig.minEngineRPM; __instance.minimalBumpForce = CompanyCruiserConfig.minimalBumpForce; __instance.movingAverageLength = CompanyCruiserConfig.movingAverageLength; __instance.pushForceMultiplier = CompanyCruiserConfig.pushForceMultiplier; __instance.pushVerticalOffsetAmount = CompanyCruiserConfig.pushVerticalOffsetAmount; __instance.radioSignalDecreaseThreshold = CompanyCruiserConfig.radioSignalDecreaseThreshold; __instance.radioSignalQuality = CompanyCruiserConfig.radioSignalQuality; __instance.radioSignalTurbulence = CompanyCruiserConfig.radioSignalTurbulence; __instance.speed = CompanyCruiserConfig.speed; __instance.springForce = CompanyCruiserConfig.springForce; __instance.stability = CompanyCruiserConfig.stability; __instance.steeringWheelTurnSpeed = CompanyCruiserConfig.steeringWheelTurnSpeed; __instance.syncRotationSpeed = CompanyCruiserConfig.syncRotationSpeed; __instance.syncSpeedMultiplier = CompanyCruiserConfig.syncSpeedMultiplier; __instance.torqueForce = CompanyCruiserConfig.torqueForce; __instance.turboBoostForce = CompanyCruiserConfig.turboBoostForce; __instance.turboBoostUpwardForce = CompanyCruiserConfig.turboBoostUpwardForce; if (CompanyCruiserConfig.editRigidbody) { __instance.mainRigidbody.angularDrag = CompanyCruiserConfig.angularDrag; __instance.mainRigidbody.drag = CompanyCruiserConfig.drag; __instance.mainRigidbody.mass = CompanyCruiserConfig.mass; __instance.mainRigidbody.maxAngularVelocity = CompanyCruiserConfig.maxAngularVelocity; __instance.mainRigidbody.maxDepenetrationVelocity = CompanyCruiserConfig.maxDepenetrationVelocity; __instance.mainRigidbody.maxLinearVelocity = CompanyCruiserConfig.maxLinearVelocity; __instance.mainRigidbody.sleepThreshold = CompanyCruiserConfig.sleepThreshold; __instance.mainRigidbody.solverIterations = CompanyCruiserConfig.solverIterations; __instance.mainRigidbody.solverVelocityIterations = CompanyCruiserConfig.solverVelocityIterations; } } [HarmonyPatch("PushTruckWithArms")] [HarmonyPrefix] private static void PushTruckWithForcePatch(VehicleController __instance) { __instance.pushForceMultiplier = CompanyCruiserConfig.pushForceMultiplier; } [HarmonyPatch("PushTruckClientRpc")] [HarmonyPrefix] private static void PushTruckClientRpcPatch(VehicleController __instance) { __instance.pushForceMultiplier = CompanyCruiserConfig.pushForceMultiplier; } } }