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 SAMMICompany v0.4.0
BepInEx/plugins/SAMMICompany.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Backrooms; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalThings; using Mimics; using SAMMICompany.ModdedPatches.Backrooms; using SAMMICompany.ModdedPatches.LethalThings; using SAMMICompany.ModdedPatches.Mimics; using SAMMICompany.Patches; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SAMMICompany")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SAMMICompany")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("958b4e11-6e96-43be-aa60-7bcb2e490c8f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace SAMMICompany { public static class PrefixClones { } public static class Data { public enum SourceOfDamage { Unknown, BaboonBird, LassoMan, Puffer, SandSpider, SandWorm, Quicksand, Landmine, Thunder, Jetpack, Turret, Blob, Centipede, Crawler, RedLocustBees, HoarderBug, SpringMan, Falling, Shotgun, StunGrenade, Player, Nutcracker, DressGirl, MaskedPlayer, MouthDog, Jester, HauntedMask, ForestGiant, Flowerman, CompanyMonster, Space, Water, Boomba, RocketLauncher, Mimic } public static SourceOfDamage lastKnownExplosionSource = SourceOfDamage.Unknown; public static bool emotingOld = false; public static float noiseGate = 0.1f; public static float voipDistance = 50f; public static float lowVol = 20f; public static float highVol = 70f; public static string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "..", "LocalLow", "ZeekerssRBLX", "Lethal Company"); public static string logPath = Path.Combine(appPath, "sammi.log"); private static StreamWriter logWriter = new StreamWriter(logPath, append: true); public static float killCooldown = 10f; private static ManualLogSource Logger { get; set; } public static Dictionary<ulong, SourceOfDamage> crewmatesLastDamageSource { get; set; } = new Dictionary<ulong, SourceOfDamage>(); public static float killCurrentCooldown { get; set; } = 0f; public static float fearLevelOld { get; set; } public static bool fearLevelHighOld { get; set; } public static string fireStatsOld { get; set; } = "none"; public static bool shipEarlyAlertOld { get; set; } = false; public static bool isInElevatorOld { get; set; } = false; public static bool isInHangarShipRoomOld { get; set; } = false; public static bool isInsideFactoryOld { get; set; } = false; public static Dictionary<ulong, bool> crewmatesWithinRangeOld { get; set; } = new Dictionary<ulong, bool>(); public static Dictionary<ulong, bool> crewmatesSpeakingOld { get; set; } = new Dictionary<ulong, bool>(); public static Dictionary<ulong, string> crewmatesSpeakingIntensityOld { get; set; } = new Dictionary<ulong, string>(); public static void Init(ManualLogSource logger) { Logger = logger; } public static void SetPlayerDamageSource(PlayerControllerB player, SourceOfDamage sourceOfDamage) { if (GetPlayerDamageSource(player.playerClientId) != sourceOfDamage) { crewmatesLastDamageSource[player.playerClientId] = sourceOfDamage; Logger.LogDebug((object)$"{player.playerUsername}'s source of damage changed: {sourceOfDamage}"); } } public static SourceOfDamage GetPlayerDamageSource(ulong playerClientId) { CheckPlayerDamageSource(playerClientId); return crewmatesLastDamageSource[playerClientId]; } public static void CheckPlayerDamageSource(ulong playerClientId) { if (!crewmatesLastDamageSource.ContainsKey(playerClientId)) { crewmatesLastDamageSource[playerClientId] = SourceOfDamage.Unknown; } } public static void writeToSAMMI(string message) { logWriter.WriteLine(message); logWriter.Flush(); } public static string GetAmplitudeIntensity(float amplitude) { if (amplitude < lowVol) { return "low"; } if (amplitude > highVol) { return "high"; } return "mid"; } public static bool IsLocalPlayer(PlayerControllerB player) { return player.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId; } } [BepInPlugin("Landie.SAMMICompany", "SAMMICompany", "0.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SAMMICompanyMain : BaseUnityPlugin { private const string modGUID = "Landie.SAMMICompany"; private const string modName = "SAMMICompany"; private const string modVersion = "0.4.0"; private readonly Harmony harmony = new Harmony("Landie.SAMMICompany"); private static SAMMICompanyMain Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Landie.SAMMICompany"); mls.LogInfo((object)"SAMMICompany is loaded. vers.0.4.0"); Data.Init(((BaseUnityPlugin)this).Logger); PlayerControllerBPatches.Init(((BaseUnityPlugin)this).Logger); GrabbableObjectPatches.Init(((BaseUnityPlugin)this).Logger); StartOfRoundPatches.Init(((BaseUnityPlugin)this).Logger); UnlockableSuitPatches.Init(((BaseUnityPlugin)this).Logger); FlashlightItemPatches.Init(((BaseUnityPlugin)this).Logger); ShovelPatches.Init(((BaseUnityPlugin)this).Logger); IngamePlayerSettingsPatches.Init(((BaseUnityPlugin)this).Logger); TimeOfDayPatches.Init(((BaseUnityPlugin)this).Logger); HUDManagerPatches.Init(((BaseUnityPlugin)this).Logger); TerminalPatches.Init(((BaseUnityPlugin)this).Logger); SandWormAIPatches.Init(((BaseUnityPlugin)this).Logger); LandminePatches.Init(((BaseUnityPlugin)this).Logger); TurretPatches.Init(((BaseUnityPlugin)this).Logger); JetpackItemPatches.Init(((BaseUnityPlugin)this).Logger); FlowermanAIPatches.Init(((BaseUnityPlugin)this).Logger); SandSpiderAIPatches.Init(((BaseUnityPlugin)this).Logger); PufferAIPatches.Init(((BaseUnityPlugin)this).Logger); LassoManAIPatches.Init(((BaseUnityPlugin)this).Logger); BaboonBirdAIPatches.Init(((BaseUnityPlugin)this).Logger); BlobAIPatches.Init(((BaseUnityPlugin)this).Logger); CentipedeAIPatches.Init(((BaseUnityPlugin)this).Logger); CrawlerAIPatches.Init(((BaseUnityPlugin)this).Logger); RedLocustBeesPatches.Init(((BaseUnityPlugin)this).Logger); HoarderBugAIPatches.Init(((BaseUnityPlugin)this).Logger); SpringManAIPatches.Init(((BaseUnityPlugin)this).Logger); ShotgunItemPatches.Init(((BaseUnityPlugin)this).Logger); StunGrenadeItemPatches.Init(((BaseUnityPlugin)this).Logger); NutcrackerEnemyAIPatches.Init(((BaseUnityPlugin)this).Logger); DressGirlAIPatches.Init(((BaseUnityPlugin)this).Logger); MaskedPlayerEnemyPatches.Init(((BaseUnityPlugin)this).Logger); MouthDogAIPatches.Init(((BaseUnityPlugin)this).Logger); JesterAIPatches.Init(((BaseUnityPlugin)this).Logger); HauntedMaskItemPatches.Init(((BaseUnityPlugin)this).Logger); ForestGiantAIPatches.Init(((BaseUnityPlugin)this).Logger); DepositItemsDeskPatches.Init(((BaseUnityPlugin)this).Logger); harmony.PatchAll(typeof(SAMMICompanyMain)); harmony.PatchAll(typeof(PlayerControllerBPatches)); harmony.PatchAll(typeof(GrabbableObjectPatches)); harmony.PatchAll(typeof(StartOfRoundPatches)); harmony.PatchAll(typeof(UnlockableSuitPatches)); harmony.PatchAll(typeof(FlashlightItemPatches)); harmony.PatchAll(typeof(ShovelPatches)); harmony.PatchAll(typeof(IngamePlayerSettingsPatches)); harmony.PatchAll(typeof(TimeOfDayPatches)); harmony.PatchAll(typeof(HUDManagerPatches)); harmony.PatchAll(typeof(TerminalPatches)); harmony.PatchAll(typeof(SandWormAIPatches)); harmony.PatchAll(typeof(LandminePatches)); harmony.PatchAll(typeof(TurretPatches)); harmony.PatchAll(typeof(JetpackItemPatches)); harmony.PatchAll(typeof(FlowermanAIPatches)); harmony.PatchAll(typeof(SandSpiderAIPatches)); harmony.PatchAll(typeof(PufferAIPatches)); harmony.PatchAll(typeof(LassoManAIPatches)); harmony.PatchAll(typeof(BaboonBirdAIPatches)); harmony.PatchAll(typeof(BlobAIPatches)); harmony.PatchAll(typeof(CentipedeAIPatches)); harmony.PatchAll(typeof(CrawlerAIPatches)); harmony.PatchAll(typeof(RedLocustBeesPatches)); harmony.PatchAll(typeof(HoarderBugAIPatches)); harmony.PatchAll(typeof(SpringManAIPatches)); harmony.PatchAll(typeof(ShotgunItemPatches)); harmony.PatchAll(typeof(StunGrenadeItemPatches)); harmony.PatchAll(typeof(NutcrackerEnemyAIPatches)); harmony.PatchAll(typeof(DressGirlAIPatches)); harmony.PatchAll(typeof(MaskedPlayerEnemyPatches)); harmony.PatchAll(typeof(MouthDogAIPatches)); harmony.PatchAll(typeof(JesterAIPatches)); harmony.PatchAll(typeof(HauntedMaskItemPatches)); harmony.PatchAll(typeof(ForestGiantAIPatches)); harmony.PatchAll(typeof(DepositItemsDeskPatches)); if (Chainloader.PluginInfos.ContainsKey("Neekhaulas.Backrooms")) { mls.LogDebug((object)"Backrooms found, patching..."); BackroomsGeneratorPatches.Init(((BaseUnityPlugin)this).Logger); harmony.PatchAll(typeof(BackroomsGeneratorPatches)); } if (Chainloader.PluginInfos.ContainsKey("x753.Mimics")) { mls.LogDebug((object)"Mimics found, patching..."); MimicDoorPatches.Init(((BaseUnityPlugin)this).Logger); harmony.PatchAll(typeof(MimicDoorPatches)); } if (Chainloader.PluginInfos.ContainsKey("evaisa.lethalthings")) { mls.LogDebug((object)"Lethalthings found, patching..."); UtilitiesPatches.Init(((BaseUnityPlugin)this).Logger); harmony.PatchAll(typeof(UtilitiesPatches)); } } } } namespace SAMMICompany.Patches { [HarmonyPatch(typeof(DressGirlAI))] internal class DressGirlAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(DressGirlAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(DressGirlAI __instance, Collider other) { if (!__instance.hauntingLocalPlayer) { return true; } PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, true); if (!((Object)(object)val != (Object)null)) { return true; } if ((Object)(object)val == (Object)(object)__instance.hauntingPlayer && (!__instance.staringInHaunt || ((EnemyAI)__instance).currentBehaviourStateIndex != 0) && ((EnemyAI)__instance).currentBehaviourStateIndex == 1) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.DressGirl); } return true; } } [HarmonyPatch(typeof(HauntedMaskItem))] internal class HauntedMaskItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(HauntedMaskItem), "FinishAttaching")] [HarmonyPrefix] private static bool FinishAttachingPatch(HauntedMaskItem __instance) { if (((NetworkBehaviour)__instance).IsOwner && !__instance.finishedAttaching) { if (!__instance.previousPlayerHeldBy.AllowPlayerDeath()) { return true; } Data.SetPlayerDamageSource(__instance.previousPlayerHeldBy, Data.SourceOfDamage.HauntedMask); } return true; } } [HarmonyPatch(typeof(ForestGiantAI))] internal class ForestGiantAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(ForestGiantAI), "EatPlayerAnimation")] [HarmonyPrefix] private static void EatPlayerAnimationPatch(PlayerControllerB playerBeingEaten) { Data.SetPlayerDamageSource(playerBeingEaten, Data.SourceOfDamage.ForestGiant); } } [HarmonyPatch(typeof(DepositItemsDesk))] internal class DepositItemsDeskPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(DepositItemsDesk), "AnimationGrabPlayer")] [HarmonyPrefix] private static void AnimationGrabPlayerPatch(int playerID) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID]; if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.CompanyMonster); } } } [HarmonyPatch(typeof(MaskedPlayerEnemy))] internal class MaskedPlayerEnemyPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(MaskedPlayerEnemy), "killAnimation")] [HarmonyPrefix] private static void killAnimationPatch(MaskedPlayerEnemy __instance) { Data.SetPlayerDamageSource(((EnemyAI)__instance).inSpecialAnimationWithPlayer, Data.SourceOfDamage.MaskedPlayer); if (Data.IsLocalPlayer(((EnemyAI)__instance).inSpecialAnimationWithPlayer)) { Logger.LogInfo((object)"MaskedPlayerCatch"); Data.writeToSAMMI("MaskedPlayerCatch"); } } } [HarmonyPatch(typeof(JesterAI))] internal class JesterAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(JesterAI), "killPlayerAnimation")] [HarmonyPrefix] private static void killPlayerAnimationPatch(int playerId) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.Jester); } } } [HarmonyPatch(typeof(NutcrackerEnemyAI))] internal class NutcrackerEnemyAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(NutcrackerEnemyAI), "LegKickPlayer")] [HarmonyPrefix] private static bool LegKickPlayerPatch(int playerId) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.Nutcracker); } return true; } } [HarmonyPatch(typeof(MouthDogAI))] internal class MouthDogAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(MouthDogAI), "KillPlayer")] [HarmonyPrefix] private static void KillPlayerPatch(MouthDogAI __instance, int playerId) { PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId]; if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)val) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.MouthDog); } } } [HarmonyPatch(typeof(StunGrenadeItem))] internal class StunGrenadeItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(StunGrenadeItem), "StunExplosion")] [HarmonyPrefix] private static bool StunExplosionPatch(bool isHeldItem, PlayerControllerB playerHeldBy) { PlayerControllerB player = GameNetworkManager.Instance.localPlayerController; if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && (Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null) { player = GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript; } if (isHeldItem && (Object)(object)playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController) { Data.SetPlayerDamageSource(player, Data.SourceOfDamage.StunGrenade); } return true; } } [HarmonyPatch(typeof(ShotgunItem))] internal class ShotgunItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(ShotgunItem), "ShootGun")] [HarmonyPrefix] private static bool ShootGunPatch(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (((GrabbableObject)__instance).isHeld && (Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController) { flag = true; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { return true; } bool flag2 = false; Vector3 val = localPlayerController.playerCollider.ClosestPoint(shotgunPosition); if (!flag && !Physics.Linecast(shotgunPosition, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && Vector3.Angle(shotgunForward, val - shotgunPosition) < 30f) { flag2 = true; } if (flag2) { Data.SetPlayerDamageSource(localPlayerController, Data.SourceOfDamage.Shotgun); } return true; } } [HarmonyPatch(typeof(SpringManAI))] internal class SpringManAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(SpringManAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(SpringManAI __instance, Collider other) { if (!__instance.stoppingMovement && ((EnemyAI)__instance).currentBehaviourStateIndex == 1 && !(__instance.timeSinceHittingPlayer >= 0f)) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.SpringMan); } } return true; } } [HarmonyPatch(typeof(HoarderBugAI))] internal class HoarderBugAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(HoarderBugAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(HoarderBugAI __instance, Collider other) { if (!__instance.inChase) { return true; } if (!(__instance.timeSinceHittingPlayer < 0.5f)) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.HoarderBug); } } return true; } } [HarmonyPatch(typeof(RedLocustBees))] internal class RedLocustBeesPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(RedLocustBees), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(RedLocustBees __instance, Collider other) { if (__instance.timeSinceHittingPlayer < 0.4f) { return true; } PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.RedLocustBees); return true; } return true; } } [HarmonyPatch(typeof(CrawlerAI))] internal class CrawlerAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(CrawlerAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(CrawlerAI __instance, Collider other) { if (!(__instance.timeSinceHittingPlayer < 0.65f)) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.Crawler); return true; } } return true; } } [HarmonyPatch(typeof(CentipedeAI))] internal class CentipedeAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(CentipedeAI), "DamagePlayerOnIntervals")] [HarmonyPrefix] private static bool DamagePlayerOnIntervalsPatch(CentipedeAI __instance) { if (__instance.damagePlayerInterval <= 0f && !__instance.inDroppingOffPlayerAnim && !(((EnemyAI)__instance).stunNormalizedTimer > 0f) && (StartOfRound.Instance.connectedPlayersAmount > 0 || __instance.clingingToPlayer.health > 15 || __instance.singlePlayerSecondChanceGiven)) { Data.SetPlayerDamageSource(__instance.clingingToPlayer, Data.SourceOfDamage.Centipede); return true; } return true; } } [HarmonyPatch(typeof(BlobAI))] internal class BlobAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(BlobAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(BlobAI __instance, Collider other) { if (__instance.timeSinceHittingLocalPlayer < 0.25f || (__instance.tamedTimer > 0f && __instance.angeredTimer < 0f)) { return true; } PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.Blob); return true; } return true; } } [HarmonyPatch(typeof(BaboonBirdAI))] internal class BaboonBirdAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(BaboonBirdAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static bool OnCollideWithPlayerPatch(BaboonBirdAI __instance, Collider other) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (__instance.timeSinceHitting < 0.5f) { return true; } Vector3 val = Vector3.Normalize(((Component)__instance).transform.position + Vector3.up * 0.7f - (((Component)other).transform.position + Vector3.up * 0.4f)) * 0.5f; if (Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.7f + val, ((Component)other).transform.position + Vector3.up * 0.4f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { return true; } PlayerControllerB val2 = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, ((EnemyAI)__instance).inSpecialAnimation || __instance.doingKillAnimation, false); if ((Object)(object)val2 != (Object)null) { Data.SetPlayerDamageSource(val2, Data.SourceOfDamage.BaboonBird); return true; } return true; } } [HarmonyPatch(typeof(LassoManAI))] internal class LassoManAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(LassoManAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static void OnCollideWithPlayerPatch(LassoManAI __instance, Collider other) { PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>(); if (!((EnemyAI)__instance).isEnemyDead && (Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)component.inAnimationWithEnemy == (Object)null && !component.isPlayerDead && __instance.timeSinceHittingPlayer > 0.5f) { Data.SetPlayerDamageSource(component, Data.SourceOfDamage.LassoMan); } } } [HarmonyPatch(typeof(PufferAI))] internal class PufferAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(PufferAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static void OnCollideWithPlayerPatch(PufferAI __instance, Collider other) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val != (Object)null && __instance.timeSinceHittingPlayer > 1f) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.Puffer); } } } [HarmonyPatch(typeof(SandSpiderAI))] internal class SandSpiderAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(SandSpiderAI), "OnCollideWithPlayer")] [HarmonyPrefix] private static void OnCollideWithPlayerPatch(SandSpiderAI __instance, Collider other) { if (!((EnemyAI)__instance).isEnemyDead && !__instance.onWall) { PlayerControllerB val = ((EnemyAI)__instance).MeetsStandardPlayerCollisionConditions(other, __instance.spoolingPlayerBody, false); if ((Object)(object)val != (Object)null && __instance.timeSinceHittingPlayer > 1f) { Data.SetPlayerDamageSource(val, Data.SourceOfDamage.SandSpider); } } } } [HarmonyPatch(typeof(FlowermanAI))] internal class FlowermanAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(FlowermanAI), "killAnimation")] [HarmonyPrefix] private static void killAnimationPatch(FlowermanAI __instance) { if ((Object)(object)((EnemyAI)__instance).inSpecialAnimationWithPlayer != (Object)null) { Data.SetPlayerDamageSource(((EnemyAI)__instance).inSpecialAnimationWithPlayer, Data.SourceOfDamage.Flowerman); } } } [HarmonyPatch(typeof(JetpackItem))] internal class JetpackItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(JetpackItem), "Update")] [HarmonyPrefix] private static bool UpdatePatch(JetpackItem __instance) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return true; } if (!Data.IsLocalPlayer(((GrabbableObject)__instance).playerHeldBy)) { return true; } if (!((GrabbableObject)__instance).playerHeldBy.isPlayerDead && Physics.Raycast(((Component)((GrabbableObject)__instance).playerHeldBy).transform.position, __instance.forces, ref __instance.rayHit, 25f, StartOfRound.Instance.allPlayersCollideWithMask) && ((Vector3)(ref __instance.forces)).magnitude - ((RaycastHit)(ref __instance.rayHit)).distance > 50f && ((RaycastHit)(ref __instance.rayHit)).distance < 4f) { Data.SetPlayerDamageSource(((GrabbableObject)__instance).playerHeldBy, Data.SourceOfDamage.Jetpack); } return true; } } [HarmonyPatch(typeof(Turret))] internal class TurretPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(Turret), "Update")] [HarmonyPrefix] private static bool UpdatePatch(Turret __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_0057: Unknown result type (might be due to invalid IL or missing references) bool turretActive = __instance.turretActive; bool wasTargetingPlayerLastFrame = __instance.wasTargetingPlayerLastFrame; PlayerControllerB targetPlayerWithRotation = __instance.targetPlayerWithRotation; TurretMode val = __instance.turretMode; if (!turretActive) { return true; } if ((Object)(object)targetPlayerWithRotation != (Object)null) { if (!wasTargetingPlayerLastFrame) { wasTargetingPlayerLastFrame = true; if ((int)val == 0) { val = (TurretMode)1; } } __instance.SetTargetToPlayerBody(); __instance.TurnTowardsTargetIfHasLOS(); } else if (wasTargetingPlayerLastFrame) { wasTargetingPlayerLastFrame = false; val = (TurretMode)0; } TurretMode val2 = val; TurretMode val3 = val2; if ((int)val3 == 2 && __instance.turretInterval >= 0.21f && (Object)(object)__instance.CheckForPlayersInLineOfSight(3f, false) == (Object)(object)GameNetworkManager.Instance.localPlayerController) { Data.SetPlayerDamageSource(GameNetworkManager.Instance.localPlayerController, Data.SourceOfDamage.Turret); } return true; } } [HarmonyPatch(typeof(Landmine))] internal class LandminePatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(Landmine), "Detonate")] [HarmonyPrefix] private static void DetonatePatch() { Data.lastKnownExplosionSource = Data.SourceOfDamage.Landmine; } [HarmonyPatch(typeof(Landmine), "SpawnExplosion")] [HarmonyPrefix] private static void SpawnExplosionPatch(Vector3 explosionPosition, float killRange, float damageRange) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) Data.SourceOfDamage sourceOfDamage = Data.SourceOfDamage.Unknown; Logger.LogDebug((object)$"SpawnExplosionPatch {killRange} {damageRange}"); if (killRange == 5.7f && damageRange == 6.4f) { sourceOfDamage = Data.SourceOfDamage.Landmine; } else if (killRange == 2.4f && damageRange == 5f) { sourceOfDamage = Data.SourceOfDamage.Thunder; } else if (killRange == 5f && damageRange == 7f) { sourceOfDamage = Data.SourceOfDamage.Jetpack; } Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2); PlayerControllerB val = null; for (int i = 0; i < array.Length; i++) { float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position); if ((!(num > 4f) || !Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) && ((Component)array[i]).gameObject.layer == 3) { val = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner && (num < killRange || num < damageRange)) { Data.SetPlayerDamageSource(val, sourceOfDamage); } } } } } [HarmonyPatch(typeof(SandWormAI))] internal class SandWormAIPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(SandWormAI), "EatPlayer")] [HarmonyPrefix] private static void EatPlayerPatch(PlayerControllerB playerScript) { Data.SetPlayerDamageSource(playerScript, Data.SourceOfDamage.SandWorm); } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(Terminal), "RemovePunctuation")] [HarmonyPostfix] private static void RemovePunctuationPatch(ref string __result) { if (GameNetworkManager.Instance.localPlayerController.inTerminalMenu) { Logger.LogInfo((object)("TerminalMsg|||" + __result)); Data.writeToSAMMI("TerminalMsg|||" + __result); } } } [HarmonyPatch(typeof(HUDManager))] internal class HUDManagerPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(HUDManager), "DisplayNewDeadline")] [HarmonyPostfix] private static void DisplayNewDealinePatch(int overtimeBonus) { int profitQuota = TimeOfDay.Instance.profitQuota; int timesFulfilledQuota = TimeOfDay.Instance.timesFulfilledQuota; Logger.LogInfo((object)$"NewQuota|||{profitQuota}|||{timesFulfilledQuota}|||{overtimeBonus}"); Data.writeToSAMMI($"NewQuota|||{profitQuota}|||{timesFulfilledQuota}|||{overtimeBonus}"); } [HarmonyPatch(typeof(HUDManager), "DisplaySignalTranslatorMessage")] [HarmonyPostfix] private static void DisplaySignalTranslatorMessagePatch(string signalMessage) { Logger.LogInfo((object)("SigTransMsg|||" + signalMessage)); Data.writeToSAMMI("SigTransMsg|||" + signalMessage); } } [HarmonyPatch(typeof(TimeOfDay))] internal class TimeOfDayPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(TimeOfDay), "Update")] [HarmonyPostfix] private static void UpdatePatch(TimeOfDay __instance) { if (__instance.shipLeavingAlertCalled != Data.shipEarlyAlertOld) { Data.shipEarlyAlertOld = __instance.shipLeavingAlertCalled; if (__instance.shipLeavingAlertCalled) { Logger.LogInfo((object)"ShipLE"); Data.writeToSAMMI("ShipLE"); } } } } [HarmonyPatch(typeof(GiftBoxItem))] internal class GiftBoxItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(GiftBoxItem), "OpenGiftBoxClientRpc")] [HarmonyPostfix] private static void SwitchFlashlightPatch(GiftBoxItem __instance) { if (((GrabbableObject)__instance).playerHeldBy.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)$"SFlash|||{__instance}"); } } } [HarmonyPatch(typeof(IngamePlayerSettings))] internal class IngamePlayerSettingsPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(IngamePlayerSettings), "OnSceneLoaded")] [HarmonyPostfix] private static void OnSceneLoadedPatch(Scene scene) { Logger.LogInfo((object)("SceneLoaded|||" + ((Scene)(ref scene)).name)); Data.writeToSAMMI("SceneLoaded|||" + ((Scene)(ref scene)).name); } } [HarmonyPatch(typeof(Shovel))] internal class ShovelPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(Shovel), "SwingShovel")] [HarmonyPostfix] private static void SwingShovelPatch(Shovel __instance) { if (((GrabbableObject)__instance).playerHeldBy.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)"SShovel"); Data.writeToSAMMI("SShovel"); } } } [HarmonyPatch(typeof(FlashlightItem))] internal class FlashlightItemPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(FlashlightItem), "SwitchFlashlight")] [HarmonyPostfix] private static void SwitchFlashlightPatch(FlashlightItem __instance, bool on) { if (((GrabbableObject)__instance).playerHeldBy.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)$"SFlash|||{on}"); Data.writeToSAMMI($"SFlash|||{on}"); } } } [HarmonyPatch(typeof(UnlockableSuit))] internal class UnlockableSuitPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(UnlockableSuit), "SwitchSuitForPlayer")] [HarmonyPostfix] private static void SwitchSuitForPlayerPatch(PlayerControllerB player, int suitID) { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && player.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)$"SSFP|||{suitID}"); Data.writeToSAMMI($"SSFP|||{suitID}"); } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(StartOfRound), "Update")] [HarmonyPostfix] private static void UpdatePatch(StartOfRound __instance) { } [HarmonyPatch(typeof(StartOfRound), "LateUpdate")] [HarmonyPrefix] private static bool LateUpdatePatch(StartOfRound __instance) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { return true; } if (!__instance.inShipPhase && __instance.shipDoorsEnabled && !__instance.suckingPlayersOutOfShip && ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.y < -600f) { Data.SetPlayerDamageSource(GameNetworkManager.Instance.localPlayerController, Data.SourceOfDamage.Space); } return true; } [HarmonyPatch(typeof(StartOfRound), "FirePlayersAfterDeadlineClientRpc")] [HarmonyPostfix] private static void FirePlayersAfterDeadlineClientRpcPatch(StartOfRound __instance, int[] endGameStats) { string text = $"{endGameStats[0]}|||{endGameStats[1]}|||{endGameStats[2]}|||{endGameStats[3]}"; if (text != Data.fireStatsOld) { Data.fireStatsOld = text; Logger.LogInfo((object)("FPADCR|||" + text)); Data.writeToSAMMI("FPADCR|||" + text); } } [HarmonyPatch(typeof(StartOfRound), "ReviveDeadPlayers")] [HarmonyPostfix] private static void ReviveDeadPlayersPatch(StartOfRound __instance) { for (int i = 0; i < __instance.allPlayerScripts.Length; i++) { PlayerControllerB val = __instance.allPlayerScripts[i]; if (val.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId && (val.isPlayerDead || val.isPlayerControlled) && val.isPlayerDead) { Logger.LogInfo((object)"RP"); Data.writeToSAMMI("RP"); break; } } } } [HarmonyPatch(typeof(GrabbableObject))] internal class GrabbableObjectPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(GrabbableObject), "GrabItemOnClient")] [HarmonyPostfix] private static void GrabItemOnClientPatch(GrabbableObject __instance) { Logger.LogInfo((object)"GIOC"); Data.writeToSAMMI("GIOC"); } [HarmonyPatch(typeof(GrabbableObject), "ItemActivate")] [HarmonyPostfix] private static void ItemActivatePatch(GrabbableObject __instance, bool used) { if (__instance.playerHeldBy.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)$"ItemActivate|||{used}"); Data.writeToSAMMI($"ItemActivate|||{used}"); } } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void updatePatch2(PlayerControllerB __instance) { if (__instance.isSinking && __instance.sinkingValue >= 1f) { Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Quicksand); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] private static void updatePatch(PlayerControllerB __instance) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || __instance.playerClientId != GameNetworkManager.Instance.localPlayerController.playerClientId) { return; } if (__instance.performingEmote != Data.emotingOld) { Data.emotingOld = __instance.performingEmote; Logger.LogInfo((object)string.Format("PerfEmote|||{0}|||{1}", __instance.performingEmote, __instance.playerBodyAnimator.GetInteger("emoteNumber"))); Data.writeToSAMMI(string.Format("PerfEmote|||{0}|||{1}", __instance.performingEmote, __instance.playerBodyAnimator.GetInteger("emoteNumber"))); } float fearLevel = __instance.playersManager.fearLevel; if (fearLevel != Data.fearLevelOld) { Data.fearLevelOld = fearLevel; bool flag = false; if (fearLevel > 0.704f) { flag = true; } if (flag != Data.fearLevelHighOld) { Data.fearLevelHighOld = flag; Logger.LogInfo((object)$"FLHigh|||{flag}"); Data.writeToSAMMI($"FLHigh|||{flag}"); } } if (__instance.isInElevator != Data.isInElevatorOld) { Data.isInElevatorOld = __instance.isInElevator; Logger.LogInfo((object)$"inElevator|||{__instance.isInElevator}"); Data.writeToSAMMI($"inElevator|||{__instance.isInElevator}"); } if (__instance.isInHangarShipRoom != Data.isInHangarShipRoomOld) { Data.isInHangarShipRoomOld = __instance.isInHangarShipRoom; Logger.LogInfo((object)$"inHangar|||{__instance.isInHangarShipRoom}"); Data.writeToSAMMI($"inHangar|||{__instance.isInHangarShipRoom}"); } if (__instance.isInsideFactory != Data.isInsideFactoryOld) { Data.isInsideFactoryOld = __instance.isInsideFactory; Logger.LogInfo((object)$"inFactory|||{__instance.isInsideFactory}"); Data.writeToSAMMI($"inFactory|||{__instance.isInsideFactory}"); } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyPrefix] private static void DamagePlayerPatch2(PlayerControllerB __instance) { if (__instance.takingFallDamage) { Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Falling); } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] [HarmonyPostfix] private static void DamagePlayerPatch(PlayerControllerB __instance, int damageNumber) { if (__instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId && !__instance.isPlayerDead && __instance.AllowPlayerDeath()) { float num = damageNumber; string arg = Data.GetPlayerDamageSource(__instance.playerClientId).ToString(); Logger.LogInfo((object)$"DP|||{num}|||{__instance.health}|||{arg}"); Data.writeToSAMMI($"DP|||{num}|||{__instance.health}|||{arg}"); Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Unknown); } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] [HarmonyPrefix] private static void KillPlayerPatch(PlayerControllerB __instance, CauseOfDeath causeOfDeath) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isPlayerDead && __instance.AllowPlayerDeath() && __instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { string arg = Data.GetPlayerDamageSource(__instance.playerClientId).ToString(); Logger.LogInfo((object)$"KP|||{causeOfDeath}|||{arg}"); Data.writeToSAMMI($"KP|||{causeOfDeath}|||{arg}"); Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Unknown); } } [HarmonyPatch(typeof(PlayerControllerB), "SwitchToItemSlot")] [HarmonyPostfix] private static void SwitchToItemSlotPatch(PlayerControllerB __instance, int slot) { if (__instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { int num = slot + 1; if ((Object)(object)__instance.ItemSlots[slot] == (Object)null) { Logger.LogInfo((object)$"STIS|||false|||{num}"); Data.writeToSAMMI($"STIS|||false|||{num}"); return; } GrabbableObject val = __instance.ItemSlots[slot]; Logger.LogInfo((object)$"STIS|||true|||{num}|||{val.itemProperties.itemName}|||{val.itemProperties.isScrap}|||{val.itemProperties.isConductiveMetal}|||{val.itemProperties.twoHanded}|||{val.itemProperties.twoHandedAnimation}"); Data.writeToSAMMI($"STIS|||true|||{num}|||{val.itemProperties.itemName}|||{val.itemProperties.isScrap}|||{val.itemProperties.isConductiveMetal}|||{val.itemProperties.twoHanded}|||{val.itemProperties.twoHandedAnimation}"); } } [HarmonyPatch(typeof(PlayerControllerB), "SetObjectAsNoLongerHeld")] [HarmonyPostfix] private static void SetObjectAsNoLongerHeldPatch(PlayerControllerB __instance, bool droppedInElevator, bool droppedInShipRoom, GrabbableObject dropObject) { if (__instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Logger.LogInfo((object)"SOANLH"); Data.writeToSAMMI("SOANLH"); } } [HarmonyPatch(typeof(PlayerControllerB), "MakeCriticallyInjured")] [HarmonyPostfix] private static void MakeCriticallyInjuredPatch(PlayerControllerB __instance, bool enable) { if (__instance.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId) { Data.writeToSAMMI($"MCI|||{enable}"); } } [HarmonyPatch(typeof(PlayerControllerB), "SetFaceUnderwaterFilters")] [HarmonyPrefix] private static void SetFaceUnderwaterFiltersPatch(PlayerControllerB __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!__instance.isPlayerDead && __instance.isUnderwater && (Object)(object)__instance.underwaterCollider != (Object)null) { Bounds bounds = __instance.underwaterCollider.bounds; if (((Bounds)(ref bounds)).Contains(((Component)__instance.gameplayCamera).transform.position)) { Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Water); } } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientClientRpc")] [HarmonyPrefix] private static bool DamagePlayerFromOtherClientClientRpcPatch(PlayerControllerB __instance) { if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled) { Data.SetPlayerDamageSource(__instance, Data.SourceOfDamage.Player); } return true; } } } namespace SAMMICompany.ModdedPatches.Backrooms { [HarmonyPatch(typeof(BackroomsGenerator))] internal class BackroomsGeneratorPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(BackroomsGenerator), "TeleportToBackroomsClientRpc")] [HarmonyPostfix] private static void TeleportToBackroomsClientRpcPatch(BackroomsGenerator __instance, int client) { PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[client]; if (Data.IsLocalPlayer(player)) { Logger.LogDebug((object)"inBackrooms"); } } } } namespace SAMMICompany.ModdedPatches.Mimics { [HarmonyPatch(typeof(MimicDoor))] internal class MimicDoorPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(MimicDoor), "Attack")] [HarmonyPrefix] private static void AttackPatch(MimicDoor __instance, int playerId) { PlayerControllerB player = StartOfRound.Instance.allPlayerScripts[playerId]; if (Data.IsLocalPlayer(player)) { Data.SetPlayerDamageSource(player, Data.SourceOfDamage.Mimic); } } } } namespace SAMMICompany.ModdedPatches.LethalThings { [HarmonyPatch(typeof(Utilities))] internal class UtilitiesPatches { private static ManualLogSource Logger { get; set; } public static void Init(ManualLogSource logger) { Logger = logger; } [HarmonyPatch(typeof(Utilities), "CreateExplosion")] [HarmonyPrefix] private static void CreateExplosionPatch(Vector3 explosionPosition, int damage, float minDamageRange, float maxDamageRange) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Data.SourceOfDamage sourceOfDamage = Data.SourceOfDamage.Unknown; switch (damage) { case 50: sourceOfDamage = Data.SourceOfDamage.RocketLauncher; break; case 100: sourceOfDamage = Data.SourceOfDamage.Boomba; break; } Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2); PlayerControllerB val = null; for (int i = 0; i < array.Length; i++) { float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position); if ((!(num > 4f) || !Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) && ((Component)array[i]).gameObject.layer == 3) { val = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>(); if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner) { Data.SetPlayerDamageSource(val, sourceOfDamage); } } } } } }