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 Weeping Angel Enemy v1.1.0
WeepingAngel.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.AI; [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("Josh Aaron")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("WeepingAngel")] [assembly: AssemblyTitle("WeepingAngel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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; } } } namespace me.joshaaron.mods.weepingangel { public class EnemyAngel : MonoBehaviour { public enum State { Spawn, Idle, Roam, Investigate, SeekPlayer, Attack, Despawn, TargetPlayer } private PhotonView photonView; public Enemy enemy; public State currentState; internal bool attackImpulse = false; private bool stateImpulse = true; private float stateTimer; private Vector3 agentDestination = Vector3.zero; private Vector3 targetPosition = Vector3.zero; private PlayerAvatar targetPlayer; private float sightingTimer = 0f; public AudioSource sightingSoundSource; public AudioClip[] sightingSounds; public float angelFindDistance = 400f; public float angelCloseThreshold = 4f; private void Awake() { photonView = ((Component)this).GetComponent<PhotonView>(); } private void Update() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Invalid comparison between Unknown and I4 if (sightingTimer <= 0f && enemy.OnScreen.OnScreenLocal && enemy.PlayerDistance.PlayerDistanceLocal <= 10f) { PlaySightingAudio(); } if (!enemy.OnScreen.OnScreenLocal) { sightingTimer -= Time.deltaTime; } if (SemiFunc.IsMasterClientOrSingleplayer()) { if ((int)enemy.CurrentState == 11 && !enemy.IsStunned()) { UpdateState(State.Despawn); } if (enemy.OnScreen.OnScreenAny) { UpdateState(State.Idle); } switch (currentState) { case State.Spawn: StateSpawn(); break; case State.Idle: StateIdle(); break; case State.Roam: StateRoam(); break; case State.Investigate: StateInvestigate(); break; case State.TargetPlayer: MoveTowardPlayer(); StateTargetPlayer(); break; case State.SeekPlayer: StateSeekPlayer(); break; case State.Attack: StateAttack(); break; case State.Despawn: break; } } } private void PlaySightingAudio() { GameDirector.instance.CameraImpact.Shake(2f, 0.1f); GameDirector.instance.CameraShake.Shake(2f, 1f); sightingSoundSource.clip = sightingSounds[Random.Range(0, sightingSounds.Length)]; sightingSoundSource.Play(); sightingTimer = 20f; } public void StateSpawn() { if (stateImpulse) { stateTimer = 3f; stateImpulse = false; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.Idle); } } private void StateIdle() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { stateImpulse = false; stateTimer = 0.5f; enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position); enemy.NavMeshAgent.ResetPath(); } if (!SemiFunc.EnemySpawnIdlePause() && !enemy.OnScreen.OnScreenAny) { stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.Roam); } } } private void StateRoam() { //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { float num = 999f; PlayerAvatar val = null; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { float num2 = Vector3.Distance(enemy.PlayerDistance.CheckTransform.position, player.PlayerVisionTarget.VisionTransform.position); if (!player.isDisabled && num2 < num && num2 <= angelFindDistance) { num = num2; val = player; } } enemy.NavMeshAgent.ResetPath(); enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position); stateImpulse = false; stateTimer = 5f; LevelPoint val2 = ((!((Object)(object)val == (Object)null) && !val.isDisabled) ? SemiFunc.LevelPointGet(val.playerTransform.position, 5f, 15f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 15f)); if (!Object.op_Implicit((Object)(object)val2)) { val2 = ((!((Object)(object)val == (Object)null) && !val.isDisabled) ? SemiFunc.LevelPointGet(val.playerTransform.position, 0f, 999f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f)); } NavMeshHit val3 = default(NavMeshHit); if (Object.op_Implicit((Object)(object)val2) && NavMesh.SamplePosition(((Component)val2).transform.position + Random.insideUnitSphere * 3f, ref val3, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val3)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" }))) { agentDestination = ((NavMeshHit)(ref val3)).position; } } enemy.NavMeshAgent.SetDestination(agentDestination); if (enemy.Rigidbody.notMovingTimer > 1f) { stateTimer -= Time.deltaTime; } if (stateTimer <= 0f) { UpdateState(State.Idle); } else if (Vector3.Distance(((Component)this).transform.position, agentDestination) < 2f) { UpdateState(State.Idle); } } private void StateInvestigate() { //IL_0046: 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_00ab: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { stateTimer = 5f; enemy.Rigidbody.notMovingTimer = 0f; stateImpulse = false; return; } enemy.NavMeshAgent.SetDestination(agentDestination); if (enemy.Rigidbody.notMovingTimer > 2f) { stateTimer -= Time.deltaTime; } if (stateTimer <= 0f) { UpdateState(State.Idle); } else if (Vector3.Distance(((Component)this).transform.position, agentDestination) < 2f) { UpdateState(State.Idle); } } private void StateTargetPlayer() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { stateTimer = 2f; stateImpulse = false; } enemy.Rigidbody.OverrideFollowPosition(0.2f, 5f, 30f); if (Vector3.Distance(enemy.CenterTransform.position, ((Component)targetPlayer).transform.position) < 2f) { UpdateState(State.Attack); return; } stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.SeekPlayer); } else if (enemy.Rigidbody.notMovingTimer > 3f) { enemy.Vision.DisableVision(2f); UpdateState(State.SeekPlayer); } } private void StateSeekPlayer() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { stateTimer = 20f; stateImpulse = false; LevelPoint levelPointAhead = enemy.GetLevelPointAhead(targetPosition); if (Object.op_Implicit((Object)(object)levelPointAhead)) { targetPosition = ((Component)levelPointAhead).transform.position; } enemy.Rigidbody.notMovingTimer = 0f; } enemy.NavMeshAgent.OverrideAgent(3f, 3f, 0.2f); enemy.Rigidbody.OverrideFollowPosition(0.2f, 3f, -1f); if (Vector3.Distance(((Component)this).transform.position, targetPosition) < 2f) { LevelPoint levelPointAhead2 = enemy.GetLevelPointAhead(targetPosition); if (Object.op_Implicit((Object)(object)levelPointAhead2)) { targetPosition = ((Component)levelPointAhead2).transform.position; } } if (enemy.Rigidbody.notMovingTimer >= 3f) { UpdateState(State.Idle); return; } enemy.NavMeshAgent.SetDestination(targetPosition); stateTimer -= Time.deltaTime; if (stateTimer <= 0f || enemy.Rigidbody.notMovingTimer > 3f) { UpdateState(State.Roam); } } private void MoveTowardPlayer() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!enemy.OnScreen.OnScreenAny) { targetPosition = ((Component)targetPlayer).transform.position; enemy.NavMeshAgent.SetDestination(targetPosition); } } private void StateAttack() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (stateImpulse) { attackImpulse = true; if (GameManager.Multiplayer()) { photonView.RPC("AttackImpulseRPC", (RpcTarget)1, Array.Empty<object>()); } enemy.NavMeshAgent.ResetPath(); enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position); stateTimer = 2f; stateImpulse = false; } else { enemy.NavMeshAgent.Stop(0.2f); stateTimer -= Time.deltaTime; if (stateTimer <= 0f) { UpdateState(State.SeekPlayer); } } } [PunRPC] private void AttackImpulseRPC() { attackImpulse = true; } private void UpdateState(State _state) { if (currentState != _state) { enemy.Rigidbody.notMovingTimer = 0f; currentState = _state; stateImpulse = true; stateTimer = 0f; if (GameManager.Multiplayer()) { photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState }); } else { UpdateStateRPC(currentState); } } } [PunRPC] private void UpdateStateRPC(State _state) { currentState = _state; } [PunRPC] private void TargetPlayerRPC(int _playerID) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (player.photonView.ViewID == _playerID) { targetPlayer = player; } } } public void OnSpawn() { Debug.Log((object)"Angel Spawned"); if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(enemy)) { UpdateState(State.Spawn); } } public void OnHurt() { } public void OnDeath() { } public void OnVision() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)enemy.CurrentState == 11) { return; } State state = currentState; if ((uint)(state - 1) <= 3u) { targetPlayer = enemy.Vision.onVisionTriggeredPlayer; UpdateState(State.TargetPlayer); if (GameManager.Multiplayer()) { photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { targetPlayer.photonView.ViewID }); } } else if (currentState == State.TargetPlayer && (Object)(object)targetPlayer == (Object)(object)enemy.Vision.onVisionTriggeredPlayer) { stateTimer = Mathf.Max(stateTimer, 1f); } } public void OnInvestigate() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { State state = currentState; if ((uint)(state - 1) <= 2u) { agentDestination = enemy.StateInvestigate.onInvestigateTriggeredPosition; UpdateState(State.Investigate); } else if (currentState == State.SeekPlayer) { targetPosition = enemy.StateInvestigate.onInvestigateTriggeredPosition; } } } public void OnGrabbed() { } } public class EnemyAngelAnim : MonoBehaviour { public EnemyAngel controller; internal Animator animator; private void Awake() { animator = ((Component)this).GetComponent<Animator>(); animator.keepAnimatorStateOnDisable = true; } private void Update() { if (controller.attackImpulse) { controller.attackImpulse = false; animator.SetTrigger("Attack"); } if (!controller.enemy.OnScreen.OnScreenAny) { animator.SetBool("IsClose", controller.enemy.PlayerDistance.PlayerDistanceClosest <= controller.angelCloseThreshold); } } } [BepInPlugin("WeepingAngel", "WeepingAngel", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static Plugin 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; Patch(); } internal void Patch() { //IL_001a: 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) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Logger.LogInfo((object)"Patching Weeping Angel Enemy..."); LoadAssets(); Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static void LoadAssets() { AssetBundle val = LoadAssetBundle("angel"); Logger.LogInfo((object)"Loading Weeping Angel enemy setup..."); EnemySetup val2 = val.LoadAsset<EnemySetup>("Assets/REPO/Mods/plugins/WeepingAngel/Enemy - Angel.asset"); Enemies.RegisterEnemy(val2); Logger.LogDebug((object)"Loaded Angel enemy!"); } public static AssetBundle LoadAssetBundle(string name) { Logger.LogDebug((object)("Loading Asset Bundle: " + name)); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, name); return AssetBundle.LoadFromFile(text); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "WeepingAngel"; public const string PLUGIN_NAME = "WeepingAngel"; public const string PLUGIN_VERSION = "1.1.0"; } }