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 MaliciousHeads v0.1.5
MaliciousHeads.dll
Decompiled 5 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using MaliciousHeads.Manager; using MaliciousHeads.Util; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Xepos")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.5.0")] [assembly: AssemblyInformationalVersion("0.1.5+320538a009a269ad87e5d790886a4251b50dd7ed")] [assembly: AssemblyProduct("MaliciousHeads")] [assembly: AssemblyTitle("MaliciousHeads")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.5.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; } } } namespace MaliciousHeads { [BepInPlugin("Xepos.MaliciousHeads", "MaliciousHeads", "0.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class MaliciousHeads : BaseUnityPlugin { internal static MaliciousHeads Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Settings.Initialize(((BaseUnityPlugin)this).Config); Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0025: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal class Settings { public static ConfigEntry<byte> MaxHeadSpawnsPerLevel { get; private set; } public static ConfigEntry<byte> SpawnChanceOnPlayeDeath { get; private set; } public static ConfigEntry<float> HoldThreshold { get; private set; } public static ConfigEntry<bool> FlashEyesOnPickUp { get; private set; } public static ConfigEntry<bool> FlashEyesOnDetonate { get; private set; } public static void Initialize(ConfigFile config) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown MaxHeadSpawnsPerLevel = config.Bind<byte>("Heads", "Maximum Head Spawns", (byte)2, new ConfigDescription("Maximum amount of heads that can spawn per level", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>())); SpawnChanceOnPlayeDeath = config.Bind<byte>("Heads", "Spawn Chance", (byte)50, new ConfigDescription("Percentage chance of spawning a head when a player dies", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, (byte)100), Array.Empty<object>())); HoldThreshold = config.Bind<float>("Self-Destruct", "Hold Timer", 2f, new ConfigDescription("Maximum time to hold until self-destruct", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); FlashEyesOnPickUp = config.Bind<bool>("Heads", "Pickup - Flash Eyes", true, new ConfigDescription("If true, the eyes of the Malicious Head will briefly flash red when picking it up", (AcceptableValueBase)null, Array.Empty<object>())); FlashEyesOnDetonate = config.Bind<bool>("Heads", "Detonate - Flash Eyes", true, new ConfigDescription("If true, the eyes of the Malicious Head will briefly flash red when killing a player", (AcceptableValueBase)null, Array.Empty<object>())); } } } namespace MaliciousHeads.XEnemy { internal class EnemyMaliciousHead : MonoBehaviour { public enum State { Spawn, Idle, Despawn } [CompilerGenerated] private sealed class <Setup>d__42 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyMaliciousHead <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Setup>d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown int num = <>1__state; EnemyMaliciousHead enemyMaliciousHead = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (!LevelGenerator.Instance.Generated) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { string randomPlayerSteamID = enemyMaliciousHead.GetRandomPlayerSteamID(); if (GameManager.Multiplayer()) { enemyMaliciousHead.photonView.RPC("SetupRPC", (RpcTarget)4, new object[4] { randomPlayerSteamID, Settings.HoldThreshold.Value, Settings.FlashEyesOnPickUp.Value, Settings.FlashEyesOnDetonate.Value }); } enemyMaliciousHead.SetupDone(randomPlayerSteamID, enemyMaliciousHead.holdThreshold, enemyMaliciousHead.eyeFlashOnPickup, enemyMaliciousHead.eyeFlashOnDetonate); if (SemiFunc.RunIsArena()) { enemyMaliciousHead.physGrabObject.impactDetector.destroyDisable = false; } enemyMaliciousHead.setup = true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SetupClient>d__45 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyMaliciousHead <>4__this; public string steamID; public float holdThreshold; public bool flashOnPickup; public bool flashOnDetonate; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SetupClient>d__45(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown int num = <>1__state; EnemyMaliciousHead enemyMaliciousHead = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; goto IL_005e; case 1: <>1__state = -1; goto IL_005e; case 2: <>1__state = -1; goto IL_009c; case 3: { <>1__state = -1; break; } IL_005e: if (!Object.op_Implicit((Object)(object)enemyMaliciousHead.physGrabObject)) { MaliciousHeads.Logger.LogWarning((object)"No Phys Grab Object"); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } goto IL_009c; IL_009c: if (!Object.op_Implicit((Object)(object)enemyMaliciousHead.physGrabObject.impactDetector)) { MaliciousHeads.Logger.LogWarning((object)"No Impact Detector"); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } break; } if (!Object.op_Implicit((Object)(object)enemyMaliciousHead.physGrabObject.impactDetector.particles)) { MaliciousHeads.Logger.LogWarning((object)"No Impact Detector Particles"); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 3; return true; } MaliciousHeads.Logger.LogDebug((object)("SetupClient finished: " + steamID)); enemyMaliciousHead.SetupDone(steamID, holdThreshold, flashOnPickup, flashOnDetonate); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <Wrap>d__56 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator ie; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Wrap>d__56(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; try { ie.MoveNext(); } catch (Exception ex) { MaliciousHeads.Logger.LogError((object)ex.ToString()); } } else { <>1__state = -1; } <>2__current = ie.Current; <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public bool debugSpawn; [Space] public State currentState; private bool stateImpulse; internal float stateTimer; [Space] public Rigidbody rigidbody; [Space] public Enemy enemy; public PhysGrabObject physGrabObject; private PhotonView photonView; [Space] public MapCustom mapCustom; [Space] public float holdThreshold; private float _holdStartTime; private bool _hasSelfDestructed; private bool wasHoldingLastFrame; private AnimationCurve eyeFlashCurve; public Light eyeFlashLight; public float eyeFlashLightIntensity; private Material eyeMaterial; private int eyeMaterialAmount; private int eyeMaterialColor; private bool eyeFlash; private bool eyeFlashOnPickup; private bool eyeFlashOnDetonate; private float eyeFlashLerp; [Space] public MeshRenderer headRenderer; [Space] public MeshRenderer[] eyeRenderers; [Space] public Color eyeFlashPositiveColor; public Color eyeFlashNegativeColor; [Space] public Sound eyeFlashPositiveSound; public Sound eyeFlashNegativeSound; [Space] public AudioClip seenSound; private float seenCooldownTime = 2f; private float seenCooldownTimer; private bool localSeen; private bool localSeenEffect; private float localSeenEffectTime = 2f; private float localSeenEffectTimer; public bool serverSeen; private bool setup; private void Awake() { holdThreshold = Settings.HoldThreshold.Value; eyeFlashOnPickup = Settings.FlashEyesOnPickUp.Value; eyeFlashOnDetonate = Settings.FlashEyesOnDetonate.Value; photonView = ((Component)this).GetComponent<PhotonView>(); if (!Application.isEditor || (SemiFunc.IsMultiplayer() && !GameManager.instance.localTest)) { debugSpawn = false; } MeshRenderer[] array = eyeRenderers; foreach (MeshRenderer val in array) { if (!Object.op_Implicit((Object)(object)eyeMaterial)) { eyeMaterial = ((Renderer)val).material; } ((Renderer)val).material = eyeMaterial; } eyeMaterialAmount = Shader.PropertyToID("_ColorOverlayAmount"); eyeMaterialColor = Shader.PropertyToID("_ColorOverlay"); eyeFlashCurve = AssetManager.instance.animationCurveImpact; localSeenEffectTimer = localSeenEffectTime; } private void Start() { ((MonoBehaviour)this).StartCoroutine(Setup()); } private void Update() { //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a2: 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_00bf: 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) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { switch (currentState) { case State.Spawn: StateSpawn(); break; case State.Idle: StateIdle(); break; case State.Despawn: StateDespawn(); break; } } if (!localSeen && !PlayerController.instance.playerAvatarScript.isDisabled) { if (seenCooldownTimer > 0f) { seenCooldownTimer -= Time.deltaTime; } else { Vector3 position = ((Component)PlayerController.instance.playerAvatarScript.localCamera).transform.position; float num = Vector3.Distance(((Component)this).transform.position, position); if (num <= 10f && SemiFunc.OnScreen(((Component)this).transform.position, -0.15f, -0.15f)) { Vector3 val = position - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(physGrabObject.centerPoint, normalized, ref val2, num, LayerMask.GetMask(new string[1] { "Default" }))) { localSeen = true; TutorialDirector.instance.playerSawHead = true; if (!serverSeen && SemiFunc.RunIsLevel()) { if (SemiFunc.IsMultiplayer()) { photonView.RPC("SeenSetRPC", (RpcTarget)0, new object[1] { true }); } else { SeenSetRPC(seen: true); } if (PlayerController.instance.deathSeenTimer <= 0f) { localSeenEffect = true; PlayerController.instance.deathSeenTimer = 30f; GameDirector.instance.CameraImpact.Shake(2f, 0.5f); GameDirector.instance.CameraShake.Shake(2f, 1f); AudioScare.instance.PlayCustom(seenSound, 0.3f, 60f); ValuableDiscover.instance.New(physGrabObject, (State)2); } } } } } } if (localSeenEffect) { localSeenEffectTimer -= Time.deltaTime; CameraZoom.Instance.OverrideZoomSet(75f, 0.1f, 0.25f, 0.25f, ((Component)this).gameObject, 150); PostProcessing.Instance.VignetteOverride(Color.black, 0.4f, 1f, 1f, 0.5f, 0.1f, ((Component)this).gameObject); PostProcessing.Instance.SaturationOverride(-50f, 1f, 0.5f, 0.1f, ((Component)this).gameObject); PostProcessing.Instance.ContrastOverride(5f, 1f, 0.5f, 0.1f, ((Component)this).gameObject); GameDirector.instance.CameraImpact.Shake(10f * Time.deltaTime, 0.1f); GameDirector.instance.CameraShake.Shake(10f * Time.deltaTime, 1f); if (localSeenEffectTimer <= 0f) { localSeenEffect = false; } } bool flag = false; foreach (PhysGrabber item in physGrabObject.playerGrabbing) { if (SemiFunc.PlayerGetSteamID(item.playerAvatar) == SemiFunc.PlayerGetSteamID(PlayerAvatar.instance)) { flag = true; break; } } if (eyeFlash) { eyeFlashLerp += holdThreshold * Time.deltaTime; eyeFlashLerp = Mathf.Clamp01(eyeFlashLerp); eyeMaterial.SetFloat(eyeMaterialAmount, eyeFlashCurve.Evaluate(eyeFlashLerp)); eyeFlashLight.intensity = eyeFlashCurve.Evaluate(eyeFlashLerp) * eyeFlashLightIntensity; if (eyeFlashLerp > 1f) { eyeFlash = false; eyeMaterial.SetFloat(eyeMaterialAmount, 0f); ((Component)eyeFlashLight).gameObject.SetActive(false); } } if (flag) { if (!wasHoldingLastFrame) { _holdStartTime = Time.time; _hasSelfDestructed = false; if (eyeFlashOnPickup) { FlashEye(); } } float num2 = Time.time - _holdStartTime; if (!_hasSelfDestructed && num2 >= holdThreshold) { if (eyeFlashOnDetonate) { FlashEye(); } ChatManager.instance.PossessSelfDestruction(); _hasSelfDestructed = true; } } else { _holdStartTime = -1f; _hasSelfDestructed = false; } wasHoldingLastFrame = flag; } [IteratorStateMachine(typeof(<Setup>d__42))] private IEnumerator Setup() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Setup>d__42(0) { <>4__this = this }; } public void UpdateState(State _state) { if (currentState != _state) { currentState = _state; stateImpulse = true; stateTimer = 0f; if (GameManager.Multiplayer()) { photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState }); } else { UpdateStateRPC(currentState); } } } [PunRPC] public void SetupRPC(string steamID, float holdThreshold, bool flashOnPickup, bool flashOnDetonate) { MaliciousHeads.Logger.LogDebug((object)("[RPC] SetupRPC called with parameter steamID: " + steamID)); ((MonoBehaviour)this).StartCoroutine(Wrap(SetupClient(steamID, holdThreshold, flashOnPickup, flashOnDetonate))); } [IteratorStateMachine(typeof(<SetupClient>d__45))] private IEnumerator SetupClient(string steamID, float holdThreshold, bool flashOnPickup, bool flashOnDetonate) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SetupClient>d__45(0) { <>4__this = this, steamID = steamID, holdThreshold = holdThreshold, flashOnPickup = flashOnPickup, flashOnDetonate = flashOnDetonate }; } private string GetRandomPlayerSteamID() { PlayerAvatar val = GameDirector.instance.PlayerList[Random.Range(0, GameDirector.instance.PlayerList.Count)]; return SemiFunc.PlayerGetSteamID(val); } private void SetupDone(string steamID, float holdThreshold, bool flashOnPickup, bool flashOnDetonate) { this.holdThreshold = holdThreshold; eyeFlashOnPickup = flashOnPickup; eyeFlashOnDetonate = flashOnDetonate; if (steamID == null) { Debug.LogError((object)"Failed to set Malicious Head color"); return; } PlayerAvatar val = SemiFunc.PlayerGetFromSteamID(steamID); if (steamID == null) { Debug.LogError((object)"Failed to set Malicious Head color: No player avatar"); return; } ((Renderer)headRenderer).material = val.playerHealth.bodyMaterial; ((Renderer)headRenderer).material.SetFloat(Shader.PropertyToID("_ColorOverlayAmount"), 0f); } public void FlashEye() { if (SemiFunc.IsMultiplayer()) { photonView.RPC("FlashEyeRPC", (RpcTarget)0, new object[1] { false }); } FlashEyeRPC(_positive: false); } [PunRPC] public void FlashEyeRPC(bool _positive) { //IL_0065: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (_positive) { eyeMaterial.SetColor(eyeMaterialColor, eyeFlashPositiveColor); eyeFlashPositiveSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); eyeFlashLight.color = eyeFlashPositiveColor; } else { eyeMaterial.SetColor(eyeMaterialColor, eyeFlashNegativeColor); eyeFlashNegativeSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); eyeFlashLight.color = eyeFlashNegativeColor; } eyeFlash = true; eyeFlashLerp = 0f; ((Component)eyeFlashLight).gameObject.SetActive(true); GameDirector.instance.CameraImpact.ShakeDistance(1f, 2f, 8f, ((Component)this).transform.position, 0.25f); GameDirector.instance.CameraShake.ShakeDistance(1f, 2f, 8f, ((Component)this).transform.position, 0.5f); } private void StateSpawn() { if (stateImpulse) { stateImpulse = false; stateTimer = 1f; ApplyVelocity(); ApplyAngularVelocity(); seenCooldownTimer = seenCooldownTime; localSeen = false; localSeenEffect = false; serverSeen = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.Idle); } } private void StateIdle() { if (stateImpulse) { stateImpulse = false; stateTimer = 60f; } if (physGrabObject.playerGrabbing.Count == 0) { stateTimer -= Time.deltaTime; } else if (stateTimer < 2f) { stateTimer = 2f; } if (stateTimer <= 0f) { UpdateState(State.Despawn); } } private void StateDespawn() { if (stateImpulse) { stateImpulse = false; enemy.EnemyParent.Despawn(); } } public void OnSpawn() { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(enemy)) { UpdateState(State.Spawn); } } [PunRPC] private void UpdateStateRPC(State _state) { currentState = _state; _ = currentState; } [PunRPC] private void SeenSetRPC(bool seen) { MaliciousHeads.Logger.LogDebug((object)$"[RPC] Setting server seen to {seen}"); serverSeen = seen; } [IteratorStateMachine(typeof(<Wrap>d__56))] private static IEnumerator Wrap(IEnumerator ie) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Wrap>d__56(0) { ie = ie }; } private void ApplyVelocity() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(-3f, 3f); float num2 = Random.Range(5f, 10f); float num3 = Random.Range(-3f, 3f); rigidbody.velocity = new Vector3(num, num2, num3); } private void ApplyAngularVelocity() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) float num = Random.Range(-2f, 2f); float num2 = Random.Range(-2f, 2f); float num3 = Random.Range(-2f, 2f); rigidbody.angularVelocity = new Vector3(num, num2, num3); } } internal class MaliciousHeadMapController : MonoBehaviour { public MapCustom mapCustom; public GameObject enableObject; public EnemyMaliciousHead enemyMaliciousHead; public void Update() { if (!enemyMaliciousHead.serverSeen || !enableObject.activeSelf) { mapCustom.Hide(); } } } } namespace MaliciousHeads.Util { internal static class REPOLibUtils { internal static List<EnemyParent>? SpawnEnemyNowInVanillaManner(EnemySetup enemySetup) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) List<EnemyParent> list = Enemies.SpawnEnemy(enemySetup, Vector3.zero, Quaternion.identity, true); if (list != null) { foreach (EnemyParent item in list) { item.DespawnedTimer = 1f; } } return list; } } } namespace MaliciousHeads.Patch { [HarmonyPatch(typeof(EnemyDirector))] internal class EnemyDirectorPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void EnemyDirectorStartPostfix() { if (SemiFunc.IsNotMasterClient() || !SemiFunc.RunIsLevel()) { return; } EnemyDirector instance = EnemyDirector.instance; EnemyManager instance2 = EnemyManager.Instance; MaliciousHeads.Logger.LogDebug((object)"Level changed, setting SpawnedHeads count back to 0"); instance2.SpawnedHeads = 0; IList<EnemySetup> list = instance.enemiesDifficulty1.Concat(instance.enemiesDifficulty2).Concat(instance.enemiesDifficulty3).Where(instance2.IsSupported) .ToList(); foreach (EnemySetup item in list) { MaliciousHeads.Logger.LogDebug((object)("Removing setup: " + ((Object)item).name)); instance2.RememberEnemy(item); RemoveFromDirector(item); } } private static void RemoveFromDirector(EnemySetup enemy) { EnemyDirector.instance.enemiesDifficulty1.Remove(enemy); EnemyDirector.instance.enemiesDifficulty2.Remove(enemy); EnemyDirector.instance.enemiesDifficulty3.Remove(enemy); } } [HarmonyPatch(typeof(PlayerHealth))] internal class PlayerHealthPatch { [HarmonyPostfix] [HarmonyPatch("Death")] private static void PlayerHealthDeathPostfix() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) MaliciousHeads.Logger.LogDebug((object)"Player died"); if (!SemiFunc.IsMultiplayer() || !SemiFunc.IsMasterClient() || !SemiFunc.RunIsLevel()) { return; } EnemyManager instance = EnemyManager.Instance; if (instance.HasEnemiesToRelease()) { foreach (EnemySetup item in instance.ReleaseRememberedEnemies()) { Difficulty? difficulty = GetDifficulty(GetEnemyParent(item)); if (difficulty.HasValue) { MaliciousHeads.Logger.LogDebug((object)$"Added {((Object)item).name} to {difficulty}"); AssignEnemyToDifficulty(item, difficulty.Value); } } } if (instance.SpawnedHeads < Settings.MaxHeadSpawnsPerLevel.Value && Random.Range(0, 100) < Settings.SpawnChanceOnPlayeDeath.Value) { EnemySetup val = Enemies.RegisteredEnemies.Where((EnemySetup enemySetup) => ((Object)enemySetup).name == "Enemy - Malicious Head").FirstOrDefault(); if (Object.op_Implicit((Object)(object)val)) { REPOLibUtils.SpawnEnemyNowInVanillaManner(val); instance.SpawnedHeads++; } } } private static EnemyParent? GetEnemyParent(EnemySetup enemySetup) { EnemyParent result = default(EnemyParent); foreach (PrefabRef spawnObject in enemySetup.spawnObjects) { if (spawnObject.Prefab.TryGetComponent<EnemyParent>(ref result)) { return result; } } return null; } private static Difficulty? GetDifficulty(EnemyParent? enemyParent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemyParent == (Object)null) { return null; } return enemyParent.difficulty; } private static void AssignEnemyToDifficulty(EnemySetup enemySetup, Difficulty difficulty) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown switch ((int)difficulty) { case 0: EnemyDirector.instance.enemiesDifficulty1.Add(enemySetup); break; case 1: EnemyDirector.instance.enemiesDifficulty2.Add(enemySetup); break; case 2: EnemyDirector.instance.enemiesDifficulty3.Add(enemySetup); break; } } } } namespace MaliciousHeads.Manager { internal class EnemyManager { private static readonly ISet<string> _supportedEnemyNames = new HashSet<string> { "Enemy - Malicious Head" }; private static ISet<EnemySetup> _enemySetups = new HashSet<EnemySetup>(); internal static EnemyManager Instance { get; private set; } = new EnemyManager(); public byte SpawnedHeads { get; set; } public bool IsSupported(EnemySetup enemySetup) { return _supportedEnemyNames.Contains(((Object)enemySetup).name); } public void RememberEnemy(EnemySetup enemySetup) { _enemySetups.Add(enemySetup); MaliciousHeads.Logger.LogDebug((object)("Currently remembering: " + string.Join(", ", _enemySetups))); } public ISet<EnemySetup> ReleaseRememberedEnemies() { ISet<EnemySetup> enemySetups = _enemySetups; _enemySetups = new HashSet<EnemySetup>(); return enemySetups; } public bool HasEnemiesToRelease() { return _enemySetups.Count > 0; } } }