using 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.Text; using BecomeTheMonster.Movesets; using BepInEx; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BecomeTheMonster")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+882043fd2fa93ea0552cebab729507d08efef7c9")] [assembly: AssemblyProduct("BecomeTheMonster")] [assembly: AssemblyTitle("BecomeTheMonster")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BecomeTheMonster { [BepInPlugin("jordan.martin.becomethemonster", "Become The Monster", "1.1.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "jordan.martin.becomethemonster"; public const string PluginName = "Become The Monster"; public const string PluginVersion = "1.1.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("jordan.martin.becomethemonster").PatchAll(); Log.LogInfo((object)"Become The Monster v1.1.0 loaded."); } } internal static class GameFieldAccess { private static readonly FieldRef PlayerNameRef = AccessTools.FieldRefAccess("playerName"); private static readonly FieldRef IsLocalRef = AccessTools.FieldRefAccess("isLocal"); private static readonly FieldRef RbVelocityRef = AccessTools.FieldRefAccess("rbVelocity"); private static readonly FieldRef TumbleRef = AccessTools.FieldRefAccess("tumble"); private static readonly FieldRef HealthRef = AccessTools.FieldRefAccess("health"); private static readonly FieldRef MaxHealthRef = AccessTools.FieldRefAccess("maxHealth"); public static string GetPlayerName(PlayerAvatar avatar) { return PlayerNameRef.Invoke(avatar); } public static bool GetIsLocal(PlayerAvatar avatar) { return IsLocalRef.Invoke(avatar); } public static Vector3 GetRbVelocity(PlayerAvatar avatar) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return RbVelocityRef.Invoke(avatar); } public static PlayerTumble GetTumble(PlayerAvatar avatar) { return TumbleRef.Invoke(avatar); } public static int GetHealth(PlayerHealth h) { return HealthRef.Invoke(h); } public static void SetHealth(PlayerHealth h, int value) { HealthRef.Invoke(h) = value; } public static int GetMaxHealth(PlayerHealth h) { return MaxHealthRef.Invoke(h); } public static void SetMaxHealth(PlayerHealth h, int value) { MaxHealthRef.Invoke(h) = value; } } [DefaultExecutionOrder(-100)] [RequireComponent(typeof(MonsterPossession))] public class MonsterAttackController : MonoBehaviour { private PlayerAvatar _avatar; private MonsterMoveset _moveset; private GameObject _hud; private MonsterMoveset _hudMoveset; private TextMeshProUGUI _formLabel; private Image _cooldownFill; private RectTransform _cooldownFillRect; private Image _cooldownBg; private Color _cooldownFillColor; private Color _cooldownBgColor; private TextMeshProUGUI _secondaryLabel; private Image _secondaryFill; private RectTransform _secondaryFillRect; private void Awake() { _avatar = ((Component)this).GetComponent(); _moveset = ((Component)this).GetComponent(); } private void BuildHud() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0276: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) _hud = new GameObject("BecomeTheMonster_AttackHud"); Canvas obj = _hud.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32766; _secondaryLabel = null; _secondaryFill = null; _secondaryFillRect = null; Color val = (Color)(((Object)(object)_moveset != (Object)null) ? _moveset.HudColor : new Color(0.9f, 0.1f, 0.1f)); GameObject val2 = new GameObject("Crosshair"); val2.transform.SetParent(_hud.transform, false); RectTransform obj2 = val2.AddComponent(); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); obj2.anchorMax = val3; obj2.anchorMin = val3; obj2.sizeDelta = new Vector2(36f, 36f); obj2.anchoredPosition = Vector2.zero; AddCrosshairBar(val2.transform, new Vector2(36f, 4f), val); AddCrosshairBar(val2.transform, new Vector2(4f, 36f), val); GameObject val4 = new GameObject("FormLabel"); val4.transform.SetParent(_hud.transform, false); RectTransform obj3 = val4.AddComponent(); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); obj3.anchorMax = val3; obj3.anchorMin = val3; obj3.anchoredPosition = new Vector2(0f, 70f); obj3.sizeDelta = new Vector2(500f, 50f); _formLabel = val4.AddComponent(); ((TMP_Text)_formLabel).alignment = (TextAlignmentOptions)514; ((TMP_Text)_formLabel).fontSize = 36f; ((TMP_Text)_formLabel).fontStyle = (FontStyles)1; ((Graphic)_formLabel).color = val; ((TMP_Text)_formLabel).text = BuildActionLabel("LMB", ((Object)(object)_moveset != (Object)null) ? _moveset.AttackDisplayName : "Attack"); _cooldownBgColor = new Color(0.08f, 0.08f, 0.08f, 0.85f); _cooldownFillColor = val; GameObject val5 = new GameObject("CooldownBarBg"); val5.transform.SetParent(_hud.transform, false); RectTransform obj4 = val5.AddComponent(); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); obj4.anchorMax = val3; obj4.anchorMin = val3; obj4.anchoredPosition = new Vector2(0f, -70f); obj4.sizeDelta = new Vector2(260f, 28f); _cooldownBg = val5.AddComponent(); ((Graphic)_cooldownBg).color = _cooldownBgColor; _cooldownFillRect = CreateFillBar(val5.transform, "CooldownBarFill", _cooldownFillColor, out _cooldownFill); if ((Object)(object)_moveset != (Object)null && _moveset.HasSecondaryAction) { BuildSecondaryHud(val); } } private RectTransform CreateFillBar(Transform parent, string name, Color color, out Image image) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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) //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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(0f, 1f); obj.pivot = new Vector2(0f, 0.5f); obj.anchoredPosition = Vector2.zero; obj.sizeDelta = Vector2.zero; image = val.AddComponent(); ((Graphic)image).color = color; return obj; } private static void SetFillFraction(RectTransform fillRect, float fraction) { //IL_000b: 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_001f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fillRect == (Object)null)) { Vector2 anchorMax = fillRect.anchorMax; anchorMax.x = Mathf.Clamp01(fraction); fillRect.anchorMax = anchorMax; } } private static string BuildActionLabel(string control, string displayName) { return "[" + control + "] " + displayName; } private void BuildSecondaryHud(Color hudColor) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SecondaryLabel"); val.transform.SetParent(_hud.transform, false); RectTransform obj = val.AddComponent(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj.anchorMax = val2; obj.anchorMin = val2; obj.anchoredPosition = new Vector2(0f, -110f); obj.sizeDelta = new Vector2(260f, 26f); _secondaryLabel = val.AddComponent(); ((TMP_Text)_secondaryLabel).alignment = (TextAlignmentOptions)514; ((TMP_Text)_secondaryLabel).fontSize = 16f; ((TMP_Text)_secondaryLabel).fontStyle = (FontStyles)1; ((Graphic)_secondaryLabel).color = hudColor; ((TMP_Text)_secondaryLabel).text = BuildActionLabel("RMB", _moveset.SecondaryActionDisplayName); GameObject val3 = new GameObject("SecondaryBarBg"); val3.transform.SetParent(_hud.transform, false); RectTransform obj2 = val3.AddComponent(); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj2.anchorMax = val2; obj2.anchorMin = val2; obj2.anchoredPosition = new Vector2(0f, -138f); obj2.sizeDelta = new Vector2(180f, 16f); ((Graphic)val3.AddComponent()).color = _cooldownBgColor; _secondaryFillRect = CreateFillBar(val3.transform, "SecondaryBarFill", _cooldownFillColor, out _secondaryFill); } private void AddCrosshairBar(Transform parent, Vector2 size, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Bar"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); obj.anchorMax = val2; obj.anchorMin = val2; obj.sizeDelta = size; obj.anchoredPosition = Vector2.zero; ((Graphic)val.AddComponent()).color = color; } private void Update() { if ((Object)(object)_avatar == (Object)null || !GameFieldAccess.GetIsLocal(_avatar)) { return; } if ((Object)(object)_moveset == (Object)null) { _moveset = ((Component)this).GetComponent(); } if ((Object)(object)_moveset == (Object)null) { return; } if ((Object)(object)_hud == (Object)null || (Object)(object)_hudMoveset != (Object)(object)_moveset) { if ((Object)(object)_hud != (Object)null) { Object.Destroy((Object)(object)_hud); } BuildHud(); _hudMoveset = _moveset; } _moveset.TickInput(); SetFillFraction(_cooldownFillRect, _moveset.CooldownFraction); SetFillFraction(_secondaryFillRect, _moveset.SecondaryCooldownFraction); } private void OnDestroy() { if ((Object)(object)_hud != (Object)null) { Object.Destroy((Object)(object)_hud); } } } public static class MonsterDeathOrbEffect { private const float Duration = 0.8f; public static void Spawn(Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) GameObject val = new GameObject("BecomeTheMonster_DeathOrb"); val.transform.position = position + Vector3.up; Light val2 = val.AddComponent(); val2.type = (LightType)2; Color val3 = default(Color); ((Color)(ref val3))..ctor(0.65f, 0.85f, 1f); val2.color = val3; val2.range = 8f; val2.intensity = 6f; GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)0); val4.transform.SetParent(val.transform, false); val4.transform.localScale = Vector3.one * 0.2f; Object.Destroy((Object)(object)val4.GetComponent()); Material material = (val4.GetComponent().material = VfxMaterial.CreateUnlit(val3)); val.AddComponent().Init(val2, val4.transform, material, val3, 0.8f); } } internal class MonsterDeathOrbBehaviour : MonoBehaviour { private Light _light; private Transform _sphere; private Material _material; private Color _baseColor; private float _duration; private float _timer; private float _initialIntensity; private Vector3 _initialScale; public void Init(Light light, Transform sphere, Material material, Color baseColor, float duration) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) _light = light; _sphere = sphere; _material = material; _baseColor = baseColor; _duration = duration; _initialIntensity = light.intensity; _initialScale = sphere.localScale; } private void Update() { //IL_0048: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) _timer += Time.deltaTime; float num = Mathf.Clamp01(_timer / _duration); _light.intensity = Mathf.Lerp(_initialIntensity, 0f, num); _sphere.localScale = Vector3.Lerp(_initialScale, _initialScale * 5f, num); if ((Object)(object)_material != (Object)null) { _material.color = Color.Lerp(_baseColor, Color.black, num); } if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class MonsterDirector : MonoBehaviourPunCallbacks, IOnEventCallback { public const byte MonsterSelectionEventCode = 199; public static MonsterDirector instance; public MonsterFormPool formPool; public static readonly bool ForceLocalPlayerAsMonster = Environment.GetEnvironmentVariable("BECOMETHEMONSTER_FORCE_LOCAL") == "1"; private void Awake() { instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); MonsterRevealUI.EnsureInstance(); if ((Object)(object)formPool == (Object)null) { Debug.LogWarning((object)"[BecomeTheMonster] No MonsterFormPool assigned to MonsterDirector — using default pool with unassigned prefabs. Assign real Enemy prefabs in the Inspector (see README)."); formPool = MonsterFormPool.CreateDefault(); } } public override void OnEnable() { ((MonoBehaviourPunCallbacks)this).OnEnable(); PhotonNetwork.AddCallbackTarget((object)this); } public override void OnDisable() { ((MonoBehaviourPunCallbacks)this).OnDisable(); PhotonNetwork.RemoveCallbackTarget((object)this); } public void SelectAndAssignMonsters() { ((MonoBehaviour)this).StartCoroutine(SelectAndAssignMonstersRoutine()); } private IEnumerator SelectAndAssignMonstersRoutine() { yield return (object)new WaitForSeconds(1.5f); DoSelectAndAssignMonsters(); } private void DoSelectAndAssignMonsters() { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || (!SemiFunc.RunIsLevel() && !SemiFunc.RunIsTutorial())) { return; } List list = SemiFunc.PlayerGetList(); if (list == null || list.Count == 0) { return; } int num = Mathf.Max(1, list.Count / 5); num = Mathf.Min(num, list.Count); List list2 = list.OrderBy((PlayerAvatar _) => Random.value).ToList().Take(num) .ToList(); if (ForceLocalPlayerAsMonster) { PlayerAvatar val = ((IEnumerable)list).FirstOrDefault((Func)GameFieldAccess.GetIsLocal); if ((Object)(object)val != (Object)null && !list2.Contains(val)) { list2.Insert(0, val); if (list2.Count > num) { list2.RemoveAt(list2.Count - 1); } } } string[] array = new string[list2.Count]; for (int num2 = 0; num2 < list2.Count; num2++) { MonsterFormEntry nextForm = formPool.GetNextForm(); array[num2] = ((nextForm != null) ? nextForm.displayName : string.Empty); } if (!PhotonNetwork.InRoom) { ApplySelectionDirect(list2, array); return; } int[] array2 = list2.Select((PlayerAvatar p) => p.photonView.ViewID).ToArray(); object[] array3 = new object[2] { array2, array }; RaiseEventOptions val2 = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; SendOptions val3 = default(SendOptions); ((SendOptions)(ref val3)).Reliability = true; SendOptions val4 = val3; PhotonNetwork.RaiseEvent((byte)199, (object)array3, val2, val4); } public void RespawnAsNewForm(PlayerAvatar avatar) { //IL_0076: 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_0084: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { MonsterFormEntry nextForm = formPool.GetNextForm(); string text = ((nextForm != null) ? nextForm.displayName : string.Empty); if (!PhotonNetwork.InRoom) { ApplySelectionDirect(new List { avatar }, new string[1] { text }); return; } int[] array = new int[1] { avatar.photonView.ViewID }; object[] array2 = new object[2] { array, new string[1] { text } }; RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; SendOptions val2 = default(SendOptions); ((SendOptions)(ref val2)).Reliability = true; SendOptions val3 = val2; PhotonNetwork.RaiseEvent((byte)199, (object)array2, val, val3); } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 199) { object[] obj = (object[])photonEvent.CustomData; int[] viewIds = (int[])obj[0]; string[] formNames = (string[])obj[1]; ApplySelection(viewIds, formNames); } } private void ApplySelection(int[] viewIds, string[] formNames) { List list = new List(viewIds.Length); foreach (int num in viewIds) { PhotonView val = PhotonView.Find(num); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)$"[BecomeTheMonster] Could not resolve PhotonView {num} for monster selection."); continue; } PlayerAvatar component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { list.Add(component); } } ApplySelectionDirect(list, formNames); } private void ApplySelectionDirect(List avatars, string[] formNames) { List<(string, string)> list = new List<(string, string)>(); bool localIsMonster = false; string localFormName = null; for (int i = 0; i < avatars.Count; i++) { PlayerAvatar val = avatars[i]; if (!((Object)(object)val == (Object)null)) { MonsterFormEntry formByName = formPool.GetFormByName(formNames[i]); MonsterPossession component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.RespawnAs(formByName); } else { component = ((Component)val).gameObject.AddComponent(); component.Apply(val, formByName); } list.Add((GameFieldAccess.GetPlayerName(val), formNames[i])); if (GameFieldAccess.GetIsLocal(val)) { localIsMonster = true; localFormName = formNames[i]; } } } if (list.Count > 0 && (Object)(object)MonsterRevealUI.instance != (Object)null) { MonsterRevealUI.instance.Show(list, localIsMonster, localFormName); } } } [Serializable] public class MonsterFormEntry { public string displayName; public GameObject enemyPrefab; } [CreateAssetMenu(fileName = "MonsterFormPool", menuName = "Become The Monster/Monster Form Pool")] public class MonsterFormPool : ScriptableObject { public MonsterFormEntry[] forms = Array.Empty(); private int _sequentialIndex = -1; private static readonly (string displayName, string resourceFileName)[] DefaultForms = new(string, string)[12] { ("Gnome", "Enemy - Gnome"), ("Bang", "Enemy - Bang"), ("Runner", "Enemy - Runner"), ("Duck", "Enemy - Duck"), ("Bowtie", "Enemy - Bowtie"), ("Robe", "Enemy - Robe"), ("Beamer", "Enemy - Beamer"), ("Floater", "Enemy - Floater"), ("Spinny", "Enemy - Spinny"), ("Slow Walker", "Enemy - Slow Walker"), ("Birthday Boy", "Enemy - Birthday boy"), ("Hidden", "Enemy - Hidden") }; public MonsterFormEntry GetRandomForm(string excludeDisplayName = null) { if (forms == null || forms.Length == 0) { Debug.LogError((object)"[BecomeTheMonster] MonsterFormPool has no forms configured."); return null; } if (forms.Length == 1 || excludeDisplayName == null) { return forms[Random.Range(0, forms.Length)]; } List list = new List(forms.Length - 1); MonsterFormEntry[] array = forms; foreach (MonsterFormEntry monsterFormEntry in array) { if (monsterFormEntry.displayName != excludeDisplayName) { list.Add(monsterFormEntry); } } if (list.Count == 0) { return forms[Random.Range(0, forms.Length)]; } return list[Random.Range(0, list.Count)]; } public MonsterFormEntry GetNextForm() { if (forms == null || forms.Length == 0) { Debug.LogError((object)"[BecomeTheMonster] MonsterFormPool has no forms configured."); return null; } _sequentialIndex = (_sequentialIndex + 1) % forms.Length; return forms[_sequentialIndex]; } public MonsterFormEntry GetFormByName(string name) { if (forms == null) { return null; } MonsterFormEntry[] array = forms; foreach (MonsterFormEntry monsterFormEntry in array) { if (monsterFormEntry.displayName == name) { return monsterFormEntry; } } return null; } public static MonsterFormPool CreateDefault() { MonsterFormPool monsterFormPool = ScriptableObject.CreateInstance(); List list = new List(DefaultForms.Length); (string, string)[] defaultForms = DefaultForms; for (int i = 0; i < defaultForms.Length; i++) { (string, string) tuple = defaultForms[i]; string item = tuple.Item1; string item2 = tuple.Item2; GameObject val = Resources.Load("enemies/" + item2); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("[BecomeTheMonster] Could not load enemy prefab \"enemies/" + item2 + "\" for form \"" + item + "\" — skipping.")); } else { list.Add(new MonsterFormEntry { displayName = item, enemyPrefab = val }); } } monsterFormPool.forms = list.ToArray(); return monsterFormPool; } } public class MonsterPossession : MonoBehaviour { public PlayerAvatar avatar; public string formName; public GameObject enemyPrefab; public Animator monsterAnimator; public MonsterMoveset moveset; private GameObject _monsterVisual; private readonly List _bodyRenderers = new List(); private readonly List _movementFloatParams = new List(); private readonly List _movementBoolParams = new List(); private float _normalCameraHeight; private Vector3 _originalCameraPlayerOffset; private bool _cameraPlayerOffsetCaptured; private bool _cameraOffsetReady; private float _originalJumpForce; private bool _jumpForceCaptured; private float _originalSprintSpeed; private bool _sprintSpeedCaptured; private bool _originalDebugEnergy; private bool _debugEnergyCaptured; private int _originalMaxHealth; private bool _healthApplied; public GameObject MonsterVisual => _monsterVisual; public void Apply(PlayerAvatar targetAvatar, MonsterFormEntry form) { //IL_0036: 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_006e: 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) avatar = targetAvatar; _normalCameraHeight = 1.6f; if ((Object)(object)avatar.localCamera != (Object)null) { _normalCameraHeight = ((Component)avatar.localCamera).transform.position.y - ((Component)avatar).transform.position.y; } if ((Object)(object)CameraPosition.instance != (Object)null) { _originalCameraPlayerOffset = CameraPosition.instance.playerOffset; } _cameraPlayerOffsetCaptured = true; SetPlayerVisualsVisible(visible: false); SetFlashlightActive(active: false); SetInventoryHudVisible(visible: false); SetEnergyHudVisible(visible: false); ApplyForm(form); ((Component)this).gameObject.AddComponent(); } public void OnMonsterDeath() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) MonsterDeathOrbEffect.Spawn(((Component)avatar).transform.position); if ((Object)(object)MonsterDirector.instance != (Object)null) { MonsterDirector.instance.RespawnAsNewForm(avatar); } } public void RespawnAs(MonsterFormEntry form) { if ((Object)(object)_monsterVisual != (Object)null) { Object.Destroy((Object)(object)_monsterVisual); } if ((Object)(object)moveset != (Object)null) { Object.Destroy((Object)(object)moveset); } monsterAnimator = null; moveset = null; _bodyRenderers.Clear(); _movementFloatParams.Clear(); _movementBoolParams.Clear(); _cameraOffsetReady = false; ApplyForm(form); } private void ApplyForm(MonsterFormEntry form) { //IL_0050: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) formName = ((form != null) ? form.displayName : "Monster"); enemyPrefab = form?.enemyPrefab; if (form != null && (Object)(object)form.enemyPrefab != (Object)null) { SpawnMonsterVisual(form.enemyPrefab); } Vector3 randomNonTruckPosition = GetRandomNonTruckPosition(((Component)avatar).transform.position); avatar.Spawn(randomNonTruckPosition, Quaternion.identity); } private void SetFlashlightActive(bool active) { if (!((Object)(object)avatar.flashlightController == (Object)null)) { ((Component)avatar.flashlightController).gameObject.SetActive(active); } } private void SetInventoryHudVisible(bool visible) { if (GameFieldAccess.GetIsLocal(avatar) && !((Object)(object)InventoryUI.instance == (Object)null)) { if (visible) { ((SemiUI)InventoryUI.instance).Show(); } else { ((SemiUI)InventoryUI.instance).Hide(); } } } private void SetEnergyHudVisible(bool visible) { if (GameFieldAccess.GetIsLocal(avatar) && !((Object)(object)EnergyUI.instance == (Object)null)) { if (visible) { ((SemiUI)EnergyUI.instance).Show(); } else { ((SemiUI)EnergyUI.instance).Hide(); } } } private void SetPlayerVisualsVisible(bool visible) { PlayerAvatarVisuals component = ((Component)avatar).GetComponent(); if (!((Object)(object)component == (Object)null)) { Renderer[] componentsInChildren = ((Component)component).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = visible; } } } private void SpawnMonsterVisual(GameObject enemyPrefab) { //IL_003e: 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) _monsterVisual = Object.Instantiate(enemyPrefab, ((Component)avatar).transform); _monsterVisual.transform.SetParent(((Component)avatar).transform, false); _monsterVisual.transform.localPosition = Vector3.zero; _monsterVisual.transform.localRotation = Quaternion.identity; ((MonoBehaviour)this).StartCoroutine(StripAiAfterOwnSetup()); } private IEnumerator StripAiAfterOwnSetup() { yield return null; if ((Object)(object)_monsterVisual == (Object)null) { yield break; } Behaviour[] componentsInChildren = _monsterVisual.GetComponentsInChildren(true); foreach (Behaviour val in componentsInChildren) { if (!(val is Animator)) { val.enabled = false; } } Renderer[] componentsInChildren2 = _monsterVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = true; } Collider[] componentsInChildren3 = _monsterVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].enabled = false; } Rigidbody[] componentsInChildren4 = _monsterVisual.GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren4) { if (!val2.isKinematic) { val2.velocity = Vector3.zero; val2.angularVelocity = Vector3.zero; val2.isKinematic = true; } } monsterAnimator = _monsterVisual.GetComponentInChildren(); CacheMovementAnimatorParams(); if ((Object)(object)monsterAnimator != (Object)null) { monsterAnimator.applyRootMotion = false; } Type movesetType = MonsterMovesetRegistry.GetMovesetType(formName); moveset = (MonsterMoveset)(object)((Component)this).gameObject.AddComponent(movesetType); moveset.Init(avatar, monsterAnimator, this); CacheBodyRenderers(); ApplyMonsterHealth(); } private void ApplyMonsterHealth() { if (!((Object)(object)avatar.playerHealth == (Object)null) && !((Object)(object)moveset == (Object)null)) { if (!_healthApplied) { _originalMaxHealth = GameFieldAccess.GetMaxHealth(avatar.playerHealth); _healthApplied = true; } int monsterMaxHealth = moveset.MonsterMaxHealth; GameFieldAccess.SetMaxHealth(avatar.playerHealth, monsterMaxHealth); GameFieldAccess.SetHealth(avatar.playerHealth, monsterMaxHealth); } } private void CacheBodyRenderers() { _bodyRenderers.Clear(); Renderer[] componentsInChildren = _monsterVisual.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if (val2 != null) { val2.updateWhenOffscreen = true; _bodyRenderers.Add(val); } else if (val is MeshRenderer) { _bodyRenderers.Add(val); } } _cameraOffsetReady = true; } private void CacheMovementAnimatorParams() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 _movementFloatParams.Clear(); _movementBoolParams.Clear(); if ((Object)(object)monsterAnimator == (Object)null) { return; } AnimatorControllerParameter[] parameters = monsterAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { string text = val.name.ToLowerInvariant(); if ((int)val.type == 1) { switch (text) { case "speed": case "movespeed": case "velocity": _movementFloatParams.Add(val.name); continue; } } if ((int)val.type == 4) { switch (text) { case "moving": case "ismoving": case "walking": _movementBoolParams.Add(val.name); break; } } } } private void Update() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00d1: Unknown result type (might be due to invalid IL or missing references) SetPlayerVisualsVisible(visible: false); if ((Object)(object)_monsterVisual != (Object)null) { if ((Object)(object)_monsterVisual.transform.parent != (Object)(object)((Component)avatar).transform) { _monsterVisual.transform.SetParent(((Component)avatar).transform, false); _monsterVisual.transform.localPosition = Vector3.zero; _monsterVisual.transform.localRotation = Quaternion.identity; } Renderer[] componentsInChildren = _monsterVisual.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = true; } } if ((Object)(object)monsterAnimator != (Object)null && (Object)(object)avatar != (Object)null) { Vector3 rbVelocity = GameFieldAccess.GetRbVelocity(avatar); float magnitude = ((Vector3)(ref rbVelocity)).magnitude; bool flag = (Object)(object)moveset != (Object)null && moveset.SuppressMovingAnimation; bool flag2 = magnitude > 0.15f && !flag; foreach (string movementFloatParam in _movementFloatParams) { monsterAnimator.SetFloat(movementFloatParam, magnitude); } foreach (string movementBoolParam in _movementBoolParams) { monsterAnimator.SetBool(movementBoolParam, flag2); } } if ((Object)(object)avatar != (Object)null && GameFieldAccess.GetIsLocal(avatar) && (Object)(object)PlayerController.instance != (Object)null) { if (!_jumpForceCaptured) { _originalJumpForce = PlayerController.instance.JumpForce; _jumpForceCaptured = true; } bool flag3 = (Object)(object)moveset != (Object)null && moveset.AllowJump; bool num = (Object)(object)moveset != (Object)null && moveset.AllowCrouch; float num2 = (((Object)(object)moveset != (Object)null) ? moveset.MoveSpeedMultiplier : 1f); PlayerController.instance.JumpForce = (flag3 ? _originalJumpForce : 0f); if (!num) { PlayerController.instance.CrouchDisable(0.5f); } if (!Mathf.Approximately(num2, 1f)) { PlayerController.instance.MoveMult(num2, 0.5f); } if (!_sprintSpeedCaptured) { _originalSprintSpeed = PlayerController.instance.SprintSpeed; _sprintSpeedCaptured = true; } PlayerController.instance.SprintSpeed = PlayerController.instance.MoveSpeed; if (!_debugEnergyCaptured) { _originalDebugEnergy = PlayerController.instance.DebugEnergy; _debugEnergyCaptured = true; } PlayerController.instance.DebugEnergy = true; if ((Object)(object)PhysGrabber.instance != (Object)null) { PhysGrabber.instance.OverrideGrabDisable(0.5f); } } } private void LateUpdate() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (!_cameraOffsetReady || (Object)(object)avatar == (Object)null || !GameFieldAccess.GetIsLocal(avatar) || (Object)(object)avatar.localCamera == (Object)null) { return; } float num = 1.6f; float num2 = 10f; if (_bodyRenderers.Count > 0) { Bounds bounds = _bodyRenderers[0].bounds; foreach (Renderer bodyRenderer in _bodyRenderers) { ((Bounds)(ref bounds)).Encapsulate(bodyRenderer.bounds); } num = Mathf.Max(0.5f, ((Bounds)(ref bounds)).max.y - ((Component)avatar).transform.position.y); Vector2 val = new Vector2(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z); num2 = Mathf.Max(12f, ((Vector2)(ref val)).magnitude + 11f); } Vector3 position = ((Component)avatar).transform.position; position.y += num; position -= ((Component)avatar).transform.forward * num2; if ((Object)(object)CameraPosition.instance != (Object)null) { Vector3 originalCameraPlayerOffset = _originalCameraPlayerOffset; originalCameraPlayerOffset.y = position.y - ((Component)avatar).transform.position.y; CameraPosition.instance.playerOffset = originalCameraPlayerOffset; } ((Component)avatar.localCamera).transform.position = position; } public static Vector3 GetRandomNonTruckPosition(Vector3? avoidNear = null) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) List list = (from p in SemiFunc.LevelPointsGetAll() where !p.Truck select p).ToList(); if (list.Count == 0) { Debug.LogWarning((object)"[BecomeTheMonster] No non-truck level points found, falling back to origin."); return Vector3.zero; } if (avoidNear.HasValue && list.Count > 1) { LevelPoint val = list[0]; float num = Vector3.Distance(((Component)val).transform.position, avoidNear.Value); foreach (LevelPoint item in list) { float num2 = Vector3.Distance(((Component)item).transform.position, avoidNear.Value); if (num2 < num) { val = item; num = num2; } } list.Remove(val); } return ((Component)list[Random.Range(0, list.Count)]).transform.position; } private void OnDestroy() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_monsterVisual != (Object)null) { Object.Destroy((Object)(object)_monsterVisual); } if (!((Object)(object)avatar != (Object)null)) { return; } SetPlayerVisualsVisible(visible: true); SetInventoryHudVisible(visible: true); SetFlashlightActive(active: true); SetEnergyHudVisible(visible: true); if (GameFieldAccess.GetIsLocal(avatar) && (Object)(object)PlayerController.instance != (Object)null) { if (_jumpForceCaptured) { PlayerController.instance.JumpForce = _originalJumpForce; } if (_sprintSpeedCaptured) { PlayerController.instance.SprintSpeed = _originalSprintSpeed; } if (_debugEnergyCaptured) { PlayerController.instance.DebugEnergy = _originalDebugEnergy; } } if (_cameraPlayerOffsetCaptured && (Object)(object)CameraPosition.instance != (Object)null) { CameraPosition.instance.playerOffset = _originalCameraPlayerOffset; } if (_healthApplied && (Object)(object)avatar.playerHealth != (Object)null) { int health = GameFieldAccess.GetHealth(avatar.playerHealth); int num = (((Object)(object)moveset != (Object)null) ? moveset.MonsterMaxHealth : health); float num2 = ((num > 0) ? ((float)health / (float)num) : 1f); GameFieldAccess.SetMaxHealth(avatar.playerHealth, _originalMaxHealth); GameFieldAccess.SetHealth(avatar.playerHealth, Mathf.Clamp(Mathf.RoundToInt((float)_originalMaxHealth * num2), 1, _originalMaxHealth)); } } } public class MonsterRevealUI : MonoBehaviour { private enum State { Hidden, FadingIn, Visible, FadingOut } public static MonsterRevealUI instance; public float displayDuration = 4f; public float fadeDuration = 0.5f; private CanvasGroup _canvasGroup; private Image _background; private TextMeshProUGUI _text; private float _timer; private State _state; public static void EnsureInstance() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)instance != (Object)null)) { GameObject val = new GameObject("BecomeTheMonster_RevealUI"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent(); instance.BuildUI(); } } private void BuildUI() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_006d: 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_0083: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) Canvas obj = ((Component)this).gameObject.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32767; _canvasGroup = ((Component)this).gameObject.AddComponent(); _canvasGroup.alpha = 0f; _canvasGroup.blocksRaycasts = false; GameObject val = new GameObject("Background"); val.transform.SetParent(((Component)this).transform, false); RectTransform obj2 = val.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = Vector2.zero; obj2.offsetMax = Vector2.zero; _background = val.AddComponent(); ((Graphic)_background).color = Color.black; GameObject val2 = new GameObject("RevealText"); val2.transform.SetParent(((Component)this).transform, false); RectTransform obj3 = val2.AddComponent(); obj3.anchorMin = new Vector2(0.5f, 0.5f); obj3.anchorMax = new Vector2(0.5f, 0.5f); obj3.sizeDelta = new Vector2(1600f, 400f); obj3.anchoredPosition = Vector2.zero; _text = val2.AddComponent(); ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((TMP_Text)_text).fontSize = 90f; ((TMP_Text)_text).fontStyle = (FontStyles)1; ((Graphic)_text).color = new Color(0.9f, 0.05f, 0.05f); ((TMP_Text)_text).enableAutoSizing = true; ((TMP_Text)_text).fontSizeMin = 24f; ((TMP_Text)_text).fontSizeMax = 120f; } public void Show(List<(string playerName, string formName)> revealed, bool localIsMonster, string localFormName) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (localIsMonster) { ((Behaviour)_background).enabled = true; ((Graphic)_background).color = Color.black; ((TMP_Text)_text).fontSize = 90f; ((TMP_Text)_text).text = "YOU ARE THE " + localFormName.ToUpperInvariant(); } else { ((Behaviour)_background).enabled = false; ((TMP_Text)_text).fontSize = 48f; StringBuilder stringBuilder = new StringBuilder(); foreach (var item in revealed) { stringBuilder.AppendLine(item.playerName + " has become " + item.formName); } ((TMP_Text)_text).text = stringBuilder.ToString().TrimEnd(); } _timer = 0f; _state = State.FadingIn; } private void Update() { if (_state == State.Hidden) { return; } _timer += Time.deltaTime; switch (_state) { case State.FadingIn: _canvasGroup.alpha = Mathf.Clamp01(_timer / fadeDuration); if (_timer >= fadeDuration) { _timer = 0f; _state = State.Visible; } break; case State.Visible: if (_timer >= displayDuration) { _timer = 0f; _state = State.FadingOut; } break; case State.FadingOut: _canvasGroup.alpha = 1f - Mathf.Clamp01(_timer / fadeDuration); if (_timer >= fadeDuration) { _canvasGroup.alpha = 0f; _state = State.Hidden; } break; } } } public static class VfxMaterial { private static Shader _cachedShader; public static Material CreateUnlit(Color color) { //IL_0013: 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) Shader safeShader = GetSafeShader(); Material val = ((!((Object)(object)safeShader != (Object)null)) ? ((Material)null) : new Material(safeShader)); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[BecomeTheMonster] No usable shader found for VFX material — skipping this effect."); return null; } val.color = color; return val; } private static Shader GetSafeShader() { if ((Object)(object)_cachedShader != (Object)null) { return _cachedShader; } Shader val = Shader.Find("Universal Render Pipeline/Unlit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Universal Render Pipeline/Lit"); } if ((Object)(object)val == (Object)null) { Renderer val2 = Object.FindObjectOfType(); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMaterial != (Object)null) { val = val2.sharedMaterial.shader; } } _cachedShader = val; return val; } } } namespace BecomeTheMonster.Movesets { public class BangMoveset : MonsterMoveset { public float explosionRadius = 5f; public int explosionDamage = 35; public float fuseDuration = 1.5f; private const float FlashDuration = 0.25f; private GameObject _flash; private float _flashTimer; private bool _fuseLit; private float _fuseTimer; private Light _fuseGlow; public override bool AllowJump => true; public override bool AllowCrouch => true; public override float MoveSpeedMultiplier => 1.15f; public override float AttackCooldown => 4f; public override string AttackDisplayName => "Light Fuse"; public override Color HudColor => new Color(1f, 0.55f, 0.1f); public override int MonsterMaxHealth => 50; protected override void OnInit() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) _flash = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_flash).name = "BangExplosionFlash"; Collider component = _flash.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = _flash.GetComponent(); ((Renderer)component2).material = VfxMaterial.CreateUnlit(HudColor); ((Renderer)component2).enabled = false; GameObject val = new GameObject("FuseGlow"); val.transform.SetParent(((Component)this).transform, false); _fuseGlow = val.AddComponent(); _fuseGlow.type = (LightType)2; _fuseGlow.color = HudColor; _fuseGlow.range = 4f; _fuseGlow.intensity = 0f; ((Behaviour)_fuseGlow).enabled = false; } protected override void OnTick() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007d: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (_flashTimer > 0f) { _flashTimer -= Time.deltaTime; float num = 1f - Mathf.Clamp01(_flashTimer / 0.25f); MeshRenderer component = _flash.GetComponent(); _flash.transform.localScale = Vector3.one * Mathf.Lerp(0.4f, explosionRadius * 2f, num); Color hudColor = HudColor; hudColor.a = Mathf.Lerp(0.9f, 0f, num); ((Renderer)component).material.color = hudColor; if (_flashTimer <= 0f) { ((Renderer)component).enabled = false; } } if (_fuseLit) { _fuseTimer -= Time.deltaTime; ((Component)_fuseGlow).transform.position = ((Component)base.Avatar).transform.position + Vector3.up; float num2 = 1f - Mathf.Clamp01(_fuseTimer / fuseDuration); _fuseGlow.intensity = Mathf.Lerp(1f, 8f, num2) * (0.7f + 0.3f * Mathf.Sin(Time.time * Mathf.Lerp(4f, 20f, num2))); if (_fuseTimer <= 0f) { _fuseLit = false; ((Behaviour)_fuseGlow).enabled = false; Detonate(); } } } protected override void PerformAttack() { if (!_fuseLit) { _fuseLit = true; _fuseTimer = fuseDuration; ((Behaviour)_fuseGlow).enabled = true; if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("fuse"); } } } private void Detonate() { //IL_000b: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)base.Avatar).transform.position + Vector3.up; List list = new List(); List list2 = new List(); Collider[] array = Physics.OverlapSphere(val, explosionRadius); foreach (Collider val2 in array) { PlayerAvatar componentInParent = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar && !list.Contains(componentInParent)) { list.Add(componentInParent); continue; } PhysGrabObject componentInParent2 = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && !list2.Contains(componentInParent2)) { list2.Add(componentInParent2); } } foreach (PlayerAvatar item in list) { DamagePlayer(item, explosionDamage, ((Component)item).transform.position); } foreach (PhysGrabObject item2 in list2) { Vector3 val3 = ((Component)item2).transform.position - val; SmashObject(item2, ((Vector3)(ref val3)).normalized, 50f); } _flash.transform.position = val; _flash.transform.localScale = Vector3.one * 0.4f; ((Renderer)_flash.GetComponent()).enabled = true; _flashTimer = 0.25f; ((MonoBehaviour)this).StartCoroutine(SelfDestructAfterFlash()); } private IEnumerator SelfDestructAfterFlash() { yield return (object)new WaitForSeconds(0.25f); if ((Object)(object)base.Avatar != (Object)null && (Object)(object)base.Avatar.playerHealth != (Object)null) { base.Avatar.playerHealth.Hurt(9999, false, -1, false); } } private void OnDestroy() { if ((Object)(object)_flash != (Object)null) { Object.Destroy((Object)(object)_flash); } if ((Object)(object)_fuseGlow != (Object)null) { Object.Destroy((Object)(object)((Component)_fuseGlow).gameObject); } } } public class BeamerMoveset : DefaultMoveset { private const float AttackAnimHoldTime = 0.15f; private float _attackAnimTimer; private SemiLaser _realLaser; private Transform _laserStartTransform; public override float AttackCooldown => 0.3f; public override string AttackDisplayName => "Laser Beam"; public override Color HudColor => new Color(1f, 0.35f, 0.05f); public override int MonsterMaxHealth => 250; protected override void OnInit() { attackRange = 10f; attackDamage = 12; tracerDuration = 0.15f; base.OnInit(); EnemyBeamer val = (((Object)(object)base.Possession != (Object)null && (Object)(object)base.Possession.MonsterVisual != (Object)null) ? base.Possession.MonsterVisual.GetComponentInChildren(true) : null); if ((Object)(object)val != (Object)null && (Object)(object)val.laser != (Object)null) { _realLaser = val.laser; ((Behaviour)_realLaser).enabled = true; _laserStartTransform = val.laserStartTransform; } } protected override void OnTick() { base.OnTick(); if (!(_attackAnimTimer <= 0f)) { _attackAnimTimer -= Time.deltaTime; if (_attackAnimTimer <= 0f && (Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("attacking", false); } } } protected override void PerformAttack() { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("attack"); base.MonsterAnimator.SetBool("attacking", true); } _attackAnimTimer = 0.15f; if ((Object)(object)_realLaser == (Object)null) { base.PerformAttack(); return; } var (val, val2) = RaycastFromCamera(attackRange); if ((Object)(object)val != (Object)null) { DamagePlayer(val, attackDamage, val2); } Vector3 val3 = (((Object)(object)_laserStartTransform != (Object)null) ? _laserStartTransform.position : (((Object)(object)base.Cam != (Object)null) ? ((Component)base.Cam).transform.position : ((Component)this).transform.position)); _realLaser.LaserActive(val3, val2, (Object)(object)val != (Object)null); } } public class BirthdayBoyMoveset : MonsterMoveset { private class Balloon { public GameObject visual; public float lifeRemaining; } public float attackRange = 2.2f; public float attackRadius = 1.3f; public int attackDamage = 25; public float lungeForce = 5f; public float lungeTime = 0.15f; [Header("Balloon")] public float balloonPlaceDistance = 3f; public float balloonPopRadius = 1.3f; public float balloonLifetime = 25f; public int maxActiveBalloons = 3; public int balloonAmbushDamage = 30; public float balloonAmbushRadius = 2f; private readonly List _balloons = new List(); private GameObject _balloonPrefab; private const float PunchDuration = 0.15f; private float _punchTimer; private Vector3 _originalScale = Vector3.one; private bool _scaleCaptured; public override bool HasSecondaryAction => true; public override float SecondaryActionCooldown => 3f; public override string SecondaryActionDisplayName => "Place Balloon"; public override bool AllowJump => false; public override bool AllowCrouch => true; public override float MoveSpeedMultiplier => 1.15f; public override float AttackCooldown => 1f; public override string AttackDisplayName => "Swipe"; public override Color HudColor => new Color(1f, 0.35f, 0.65f); public override int MonsterMaxHealth => 150; protected override void OnInit() { EnemyBirthdayBoy val = (((Object)(object)base.Possession != (Object)null && (Object)(object)base.Possession.MonsterVisual != (Object)null) ? base.Possession.MonsterVisual.GetComponentInChildren(true) : null); _balloonPrefab = (((Object)(object)val != (Object)null) ? val.balloonPrefab : null); } protected override void OnTick() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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 (_punchTimer > 0f && (Object)(object)base.MonsterAnimator != (Object)null) { if (!_scaleCaptured) { _originalScale = ((Component)base.MonsterAnimator).transform.localScale; _scaleCaptured = true; } _punchTimer -= Time.deltaTime; float num = Mathf.Clamp01(_punchTimer / 0.15f); ((Component)base.MonsterAnimator).transform.localScale = _originalScale * (1f + num * 0.15f); if (_punchTimer <= 0f) { ((Component)base.MonsterAnimator).transform.localScale = _originalScale; } } TickBalloons(); } private void TickBalloons() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00d3: 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) for (int num = _balloons.Count - 1; num >= 0; num--) { Balloon balloon = _balloons[num]; if ((Object)(object)balloon.visual == (Object)null) { _balloons.RemoveAt(num); } else { Transform transform = balloon.visual.transform; transform.position += Vector3.up * Mathf.Sin(Time.time * 2f + (float)num) * 0.15f * Time.deltaTime; balloon.lifeRemaining -= Time.deltaTime; if (balloon.lifeRemaining <= 0f) { Object.Destroy((Object)(object)balloon.visual); _balloons.RemoveAt(num); } else { bool flag = false; Collider[] array = Physics.OverlapSphere(balloon.visual.transform.position, balloonPopRadius); for (int i = 0; i < array.Length; i++) { PlayerAvatar componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar) { flag = true; break; } } if (flag) { AmbushAtBalloon(balloon.visual.transform.position); Object.Destroy((Object)(object)balloon.visual); _balloons.RemoveAt(num); } } } } } private void AmbushAtBalloon(Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0084: Unknown result type (might be due to invalid IL or missing references) base.Avatar.Spawn(position, ((Component)base.Avatar).transform.rotation); _punchTimer = 0.15f; if ((Object)(object)base.MonsterAnimator != (Object)null) { _originalScale = ((Component)base.MonsterAnimator).transform.localScale; } Collider[] array = Physics.OverlapSphere(position, balloonAmbushRadius); for (int i = 0; i < array.Length; i++) { PlayerAvatar componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar) { DamagePlayer(componentInParent, balloonAmbushDamage, position); } } } protected override void PerformSecondaryAction() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (_balloons.Count >= maxActiveBalloons) { Balloon balloon = _balloons[0]; if ((Object)(object)balloon.visual != (Object)null) { Object.Destroy((Object)(object)balloon.visual); } _balloons.RemoveAt(0); } Vector3 placePos = ((Component)base.Avatar).transform.position + Vector3.up * 1.2f + ((Component)base.Avatar).transform.forward * balloonPlaceDistance; GameObject visual = SpawnBalloonVisual(placePos); _balloons.Add(new Balloon { visual = visual, lifeRemaining = balloonLifetime }); } private GameObject SpawnBalloonVisual(Vector3 placePos) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_balloonPrefab == (Object)null) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "BirthdayBoyBalloon"; obj.transform.position = placePos; obj.transform.localScale = Vector3.one * 0.5f; Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } ((Renderer)obj.GetComponent()).material = VfxMaterial.CreateUnlit(HudColor); return obj; } GameObject val = Object.Instantiate(_balloonPrefab, placePos, Quaternion.identity); ((Object)val).name = "BirthdayBoyBalloon"; BirthdayBoyBalloon component2 = val.GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.moveTransform != (Object)null) { component2.moveTransform.localPosition = Vector3.zero; component2.moveTransform.localScale = Vector3.one; } Behaviour[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } return val; } private void OnDestroy() { foreach (Balloon balloon in _balloons) { if ((Object)(object)balloon.visual != (Object)null) { Object.Destroy((Object)(object)balloon.visual); } } _balloons.Clear(); } protected override void PerformAttack() { //IL_0028: 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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) _punchTimer = 0.15f; List list = OverlapPlayersInFront(attackRange, attackRadius); Vector3 hitPosition = ((Component)base.Avatar).transform.position + ((Component)base.Avatar).transform.forward * attackRange; foreach (PlayerAvatar item in list) { DamagePlayer(item, attackDamage, hitPosition); } if ((Object)(object)PlayerController.instance != (Object)null) { PlayerController.instance.MoveForce(((Component)base.Avatar).transform.forward, lungeForce, lungeTime); } } } public class BowtieMoveset : MonsterMoveset { public float yellRange = 5f; public float yellRadius = 3.5f; public int yellDamage = 24; public float yellAnimHoldTime = 0.5f; private float _yellAnimTimer; public override float AttackCooldown => 2.2f; public override string AttackDisplayName => "Yell"; public override Color HudColor => new Color(0.95f, 0.55f, 0.05f); public override int MonsterMaxHealth => 200; public override float MoveSpeedMultiplier => 0.9f; protected override void OnTick() { if (!(_yellAnimTimer <= 0f)) { _yellAnimTimer -= Time.deltaTime; if (_yellAnimTimer <= 0f && (Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("yell", false); } } } protected override void PerformAttack() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Notice"); base.MonsterAnimator.SetBool("yell", true); } _yellAnimTimer = yellAnimHoldTime; foreach (PlayerAvatar item in OverlapPlayersInFront(yellRange, yellRadius)) { DamagePlayer(item, yellDamage, ((Component)item).transform.position); } } } public class DefaultMoveset : MonsterMoveset { public float attackRange = 40f; public int attackDamage = 20; public float tracerDuration = 0.14f; private LineRenderer _tracer; private float _tracerTimer; public override float AttackCooldown => 0.6f; public override string AttackDisplayName => "Shoot"; protected override void OnInit() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_005c: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Tracer"); val.transform.SetParent(((Component)this).transform, false); _tracer = val.AddComponent(); _tracer.positionCount = 2; _tracer.startWidth = 0.05f; _tracer.endWidth = 0.02f; ((Renderer)_tracer).material = VfxMaterial.CreateUnlit(HudColor); _tracer.startColor = HudColor; _tracer.endColor = new Color(HudColor.r, HudColor.g, HudColor.b, 0.2f); ((Renderer)_tracer).enabled = false; } protected override void OnTick() { if (!(_tracerTimer <= 0f)) { _tracerTimer -= Time.deltaTime; if (_tracerTimer <= 0f) { ((Renderer)_tracer).enabled = false; } } } protected override void PerformAttack() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) var (val, val2) = RaycastFromCamera(attackRange); if ((Object)(object)val != (Object)null) { DamagePlayer(val, attackDamage, val2); } _tracer.SetPosition(0, ((Object)(object)base.Cam != (Object)null) ? ((Component)base.Cam).transform.position : ((Component)this).transform.position); _tracer.SetPosition(1, val2); ((Renderer)_tracer).enabled = true; _tracerTimer = tracerDuration; } } public class DuckMoveset : MonsterMoveset { public float attackRange = 2.2f; public float attackRadius = 1.1f; public int attackDamage = 25; public float lungeForce = 6f; public float lungeTime = 0.15f; public override bool AllowJump => true; public override float MoveSpeedMultiplier => 1.15f; public override float AttackCooldown => 1f; public override string AttackDisplayName => "Bite"; public override Color HudColor => new Color(1f, 0.82f, 0.1f); public override int MonsterMaxHealth => 150; protected override void PerformAttack() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("transform"); } List list = OverlapPlayersInFront(attackRange, attackRadius); PlayerAvatar val = null; float num = float.MaxValue; foreach (PlayerAvatar item in list) { float num2 = Vector3.Distance(((Component)base.Avatar).transform.position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } if ((Object)(object)val != (Object)null) { DamagePlayer(val, attackDamage, ((Component)val).transform.position); } if ((Object)(object)PlayerController.instance != (Object)null) { PlayerController.instance.MoveForce(((Component)base.Avatar).transform.forward, lungeForce, lungeTime); } } } public class ElsaMoveset : MonsterMoveset { private const float MaulRange = 2.2f; private const float MaulRadius = 1.5f; private const int MaulDamage = 32; private const float AngryTimerMax = 15f; private const float PetRadius = 2.5f; private float _angryTimer; private bool _isBig; private int _lastHealth = -1; private bool _lastHealthCaptured; public override bool AllowJump => _isBig; public override float MoveSpeedMultiplier { get { if (!_isBig) { return 0.9f; } return 1.1f; } } public override float AttackCooldown => 1.2f; public override string AttackDisplayName { get { if (!_isBig) { return "Calm"; } return "Maul"; } } public override Color HudColor => new Color(1f, 0.15f, 0.05f); public override int MonsterMaxHealth => 600; protected override void OnTick() { if ((Object)(object)base.Avatar != (Object)null && (Object)(object)base.Avatar.playerHealth != (Object)null) { int health = GameFieldAccess.GetHealth(base.Avatar.playerHealth); if (_lastHealthCaptured && health < _lastHealth) { _angryTimer = 15f; } _lastHealth = health; _lastHealthCaptured = true; } if (!_isBig) { if (IsBeingPetted()) { _angryTimer = 0f; } else { _angryTimer += Time.deltaTime; } if (_angryTimer >= 15f) { TransformToBig(); } } } private bool IsBeingPetted() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.Avatar == (Object)null) { return false; } Collider[] array = Physics.OverlapSphere(((Component)base.Avatar).transform.position, 2.5f); for (int i = 0; i < array.Length; i++) { PlayerAvatar componentInParent = ((Component)array[i]).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar) { return true; } } return false; } private void TransformToBig() { _isBig = true; if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("isBig", true); base.MonsterAnimator.SetTrigger("TransformSmallToBig"); } } protected override void PerformAttack() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!_isBig) { return; } foreach (PlayerAvatar item in OverlapPlayersInFront(2.2f, 1.5f)) { DamagePlayer(item, 32, ((Component)item).transform.position); } } } public class FloaterMoveset : MonsterMoveset { public float attackRange = 4f; public int attackDamage = 45; public float pulseDuration = 0.35f; [Header("Force Field")] public float fieldRadius = 5f; public float fieldPushForce = 18f; public float fieldUpwardBias = 0.25f; public float fieldPulseDuration = 0.4f; private GameObject _pulseVisual; private MeshRenderer _pulseRenderer; private float _pulseTimer; private GameObject _fieldVisual; private MeshRenderer _fieldRenderer; private float _fieldTimer; private const float ChargeDuration = 0.5f; private const float DelayDuration = 0.4f; private bool _windingUp; private float _windupTimer; private int _windupStage; private static readonly Color FieldColor = new Color(0.75f, 0.95f, 1f); public override float AttackCooldown => 3.5f; public override string AttackDisplayName => "Telekinetic Slam"; public override Color HudColor => new Color(0.55f, 0.85f, 1f); public override int MonsterMaxHealth => 150; public override bool AllowJump => false; public override bool AllowCrouch => false; public override float MoveSpeedMultiplier => 0.85f; public override bool HasSecondaryAction => true; public override float SecondaryActionCooldown => 5f; public override string SecondaryActionDisplayName => "Force Field"; protected override void OnInit() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) _pulseVisual = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)_pulseVisual.GetComponent()); _pulseVisual.transform.SetParent(((Component)this).transform, false); _pulseRenderer = _pulseVisual.GetComponent(); ((Renderer)_pulseRenderer).material = VfxMaterial.CreateUnlit(HudColor); _pulseVisual.SetActive(false); _fieldVisual = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)_fieldVisual.GetComponent()); _fieldVisual.transform.SetParent(((Component)this).transform, false); _fieldRenderer = _fieldVisual.GetComponent(); ((Renderer)_fieldRenderer).material = VfxMaterial.CreateUnlit(FieldColor); _fieldVisual.SetActive(false); } protected override void OnTick() { //IL_0051: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) if (_pulseTimer > 0f) { _pulseTimer -= Time.deltaTime; float num = 1f - Mathf.Clamp01(_pulseTimer / pulseDuration); _pulseVisual.transform.position = ((Component)base.Avatar).transform.position + Vector3.up; _pulseVisual.transform.localScale = Vector3.one * Mathf.Lerp(0.5f, attackRange * 2f, num); Color hudColor = HudColor; hudColor.a = Mathf.Lerp(0.7f, 0f, num); ((Renderer)_pulseRenderer).material.color = hudColor; if (_pulseTimer <= 0f) { _pulseVisual.SetActive(false); } } if (_fieldTimer > 0f) { _fieldTimer -= Time.deltaTime; float num2 = 1f - Mathf.Clamp01(_fieldTimer / fieldPulseDuration); _fieldVisual.transform.position = ((Component)base.Avatar).transform.position + Vector3.up; _fieldVisual.transform.localScale = Vector3.one * Mathf.Lerp(0.5f, fieldRadius * 2f, num2); Color fieldColor = FieldColor; fieldColor.a = Mathf.Lerp(0.6f, 0f, num2); ((Renderer)_fieldRenderer).material.color = fieldColor; if (_fieldTimer <= 0f) { _fieldVisual.SetActive(false); } } if (!_windingUp) { return; } _windupTimer -= Time.deltaTime; if (_windupTimer > 0f) { return; } if (_windupStage == 0) { if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("DelayAttack"); } _windupStage = 1; _windupTimer = 0.4f; } else { _windingUp = false; ResolveSlam(); } } protected override void PerformAttack() { _windingUp = true; _windupStage = 0; _windupTimer = 0.5f; if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("ChargeAttack"); } } private void ResolveSlam() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Attack"); } Vector3 val = ((Component)base.Avatar).transform.position + Vector3.up; List list = new List(); List list2 = new List(); Collider[] array = Physics.OverlapSphere(val, attackRange); foreach (Collider val2 in array) { PlayerAvatar componentInParent = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar && !list.Contains(componentInParent)) { list.Add(componentInParent); DamagePlayer(componentInParent, attackDamage, ((Component)componentInParent).transform.position); continue; } PhysGrabObject componentInParent2 = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && !list2.Contains(componentInParent2)) { list2.Add(componentInParent2); } } foreach (PhysGrabObject item in list2) { Vector3 up = Vector3.up; Vector3 val3 = ((Component)item).transform.position - val; SmashObject(item, up + ((Vector3)(ref val3)).normalized, 37.5f); } _pulseVisual.transform.position = val; _pulseVisual.SetActive(true); _pulseTimer = pulseDuration; } protected override void PerformSecondaryAction() { //IL_000b: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)base.Avatar).transform.position + Vector3.up; Collider[] array = Physics.OverlapSphere(val, fieldRadius); foreach (Collider val2 in array) { PlayerAvatar componentInParent = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)base.Avatar) { PushPlayer(componentInParent, val); continue; } PhysGrabObject componentInParent2 = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { Vector3 val3 = Vector3.up * fieldUpwardBias; Vector3 val4 = ((Component)componentInParent2).transform.position - val; SmashObject(componentInParent2, val3 + ((Vector3)(ref val4)).normalized, fieldPushForce); } } _fieldVisual.transform.position = val; _fieldVisual.SetActive(true); _fieldTimer = fieldPulseDuration; } private void PushPlayer(PlayerAvatar target, Vector3 center) { //IL_0011: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004b: 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) PlayerTumble tumble = GameFieldAccess.GetTumble(target); if (!((Object)(object)tumble == (Object)null)) { Vector3 val = Vector3.up * fieldUpwardBias; Vector3 val2 = ((Component)target).transform.position - center; Vector3 val3 = val + ((Vector3)(ref val2)).normalized; tumble.TumbleRequest(true, false); tumble.TumbleForce(((Vector3)(ref val3)).normalized * fieldPushForce); tumble.TumbleOverrideTime(0.6f); } } } public class GnomeMoveset : MonsterMoveset { public float attackRange = 1.6f; public float attackRadius = 1.1f; public int attackDamage = 22; public override bool AllowJump => false; public override bool AllowCrouch => false; public override float MoveSpeedMultiplier => 0.75f; public override float AttackCooldown => 1.8f; public override string AttackDisplayName => "Pickaxe Swing"; public override Color HudColor => new Color(0.45f, 0.75f, 0.25f); public override int MonsterMaxHealth => 20; protected override void PerformAttack() { //IL_003b: 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_0056: 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_0060: 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) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Attack"); } List list = OverlapPlayersInFront(attackRange, attackRadius); Vector3 hitPosition = ((Component)base.Avatar).transform.position + ((Component)base.Avatar).transform.forward * attackRange; foreach (PlayerAvatar item in list) { DamagePlayer(item, attackDamage, hitPosition); } } } public class HiddenMoveset : MonsterMoveset { public float grabRange = 2.2f; public float grabRadius = 1.3f; public int grabDamage = 28; public override bool AllowJump => true; public override float MoveSpeedMultiplier => 1.3f; public override float AttackCooldown => 1.4f; public override string AttackDisplayName => "Grab"; public override Color HudColor => new Color(0.62f, 0.5f, 0.36f); public override int MonsterMaxHealth => 100; protected override void PerformAttack() { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) List list = OverlapPlayersInFront(grabRange, grabRadius); if (list.Count == 0) { return; } PlayerAvatar val = null; float num = float.MaxValue; Vector3 position = ((Component)base.Avatar).transform.position; foreach (PlayerAvatar item in list) { float num2 = Vector3.Distance(position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } if ((Object)(object)val != (Object)null) { DamagePlayer(val, grabDamage, ((Component)val).transform.position); } } } public class HunterMoveset : DefaultMoveset { private const float ShootingAnimHoldTime = 1f; private float _shootingAnimTimer; private const float AimDuration = 0.4f; private bool _aiming; private float _aimTimer; public override float AttackCooldown => 1.8f; public override string AttackDisplayName => "Rifle Shot"; public override Color HudColor => new Color(1f, 0.5f, 0.05f); public override int MonsterMaxHealth => 250; protected override void OnInit() { attackRange = 45f; attackDamage = 35; tracerDuration = 0.18f; base.OnInit(); } protected override void OnTick() { base.OnTick(); if (_aiming) { _aimTimer -= Time.deltaTime; if (_aimTimer <= 0f) { _aiming = false; if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("Aiming", false); } FireShot(); } } if (!(_shootingAnimTimer <= 0f)) { _shootingAnimTimer -= Time.deltaTime; if (_shootingAnimTimer <= 0f && (Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("Shooting", false); } } } protected override void PerformAttack() { _aiming = true; _aimTimer = 0.4f; if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("Aiming", true); } } private void FireShot() { if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("Shooting", true); } _shootingAnimTimer = 1f; base.PerformAttack(); } } public abstract class MonsterMoveset : MonoBehaviour { private float _cooldownTimer; private float _secondaryCooldownTimer; private float _suppressMovingTimer; private const float SuppressMovingDuration = 0.5f; protected const float DefaultObjectSmashForce = 25f; protected PlayerAvatar Avatar { get; private set; } protected Animator MonsterAnimator { get; private set; } protected MonsterPossession Possession { get; private set; } protected Camera Cam => Camera.main; public virtual bool AllowJump => false; public virtual bool AllowCrouch => false; public virtual float MoveSpeedMultiplier => 1f; public virtual int MonsterMaxHealth => 150; public abstract float AttackCooldown { get; } public abstract string AttackDisplayName { get; } public virtual Color HudColor => new Color(0.9f, 0.1f, 0.1f); public float CooldownFraction { get { if (!(AttackCooldown > 0f)) { return 1f; } return Mathf.Clamp01(1f - _cooldownTimer / AttackCooldown); } } public virtual bool HasSecondaryAction => false; public virtual float SecondaryActionCooldown => 1f; public virtual string SecondaryActionDisplayName => ""; public float SecondaryCooldownFraction { get { if (!(SecondaryActionCooldown > 0f)) { return 1f; } return Mathf.Clamp01(1f - _secondaryCooldownTimer / SecondaryActionCooldown); } } internal bool SuppressMovingAnimation => _suppressMovingTimer > 0f; public void Init(PlayerAvatar avatar, Animator monsterAnimator, MonsterPossession possession) { Avatar = avatar; MonsterAnimator = monsterAnimator; Possession = possession; OnInit(); } protected virtual void OnInit() { } public void TickInput() { OnTick(); if (_suppressMovingTimer > 0f) { _suppressMovingTimer -= Time.deltaTime; } if (_cooldownTimer > 0f) { _cooldownTimer -= Time.deltaTime; } else if (Input.GetMouseButtonDown(0)) { PerformAttack(); _cooldownTimer = AttackCooldown; _suppressMovingTimer = 0.5f; } if (HasSecondaryAction) { if (_secondaryCooldownTimer > 0f) { _secondaryCooldownTimer -= Time.deltaTime; } else if (Input.GetMouseButtonDown(1)) { PerformSecondaryAction(); _secondaryCooldownTimer = SecondaryActionCooldown; _suppressMovingTimer = 0.5f; } } } protected virtual void OnTick() { } protected abstract void PerformAttack(); protected virtual void PerformSecondaryAction() { } protected void DamagePlayer(PlayerAvatar target, int damage, Vector3 hitPosition) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)null && (Object)(object)target != (Object)(object)Avatar) { target.playerHealth.HurtOther(damage, hitPosition, true, -1, false); } } protected void SmashObject(PhysGrabObject obj, Vector3 direction, float force = 25f) { //IL_0020: 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) if (!((Object)(object)obj == (Object)null) && !((Object)(object)obj.rb == (Object)null)) { obj.rb.AddForce(((Vector3)(ref direction)).normalized * force, (ForceMode)1); } } protected (PlayerAvatar target, Vector3 endPoint) RaycastFromCamera(float range) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002d: 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_0108: 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_00df: Unknown result type (might be due to invalid IL or missing references) Camera cam = Cam; if ((Object)(object)cam == (Object)null) { return (target: null, endPoint: ((Component)this).transform.position + ((Component)this).transform.forward * range); } Vector3 position = ((Component)cam).transform.position; Vector3 forward = ((Component)cam).transform.forward; Vector3 item = position + forward * range; RaycastHit[] array = Physics.RaycastAll(position, forward, range); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; PlayerAvatar componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)(object)Avatar) { continue; } if ((Object)(object)componentInParent == (Object)null) { PhysGrabObject componentInParent2 = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { SmashObject(componentInParent2, forward); } } return (target: componentInParent, endPoint: ((RaycastHit)(ref val)).point); } return (target: null, endPoint: item); } protected List OverlapPlayersInFront(float range, float radius) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 val = ((Component)Avatar).transform.position + Vector3.up + ((Component)Avatar).transform.forward * range; List list2 = new List(); Collider[] array = Physics.OverlapSphere(val, radius); foreach (Collider val2 in array) { PlayerAvatar componentInParent = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent != (Object)(object)Avatar && !list.Contains(componentInParent)) { list.Add(componentInParent); } else if ((Object)(object)componentInParent == (Object)null) { PhysGrabObject componentInParent2 = ((Component)val2).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null && !list2.Contains(componentInParent2)) { list2.Add(componentInParent2); SmashObject(componentInParent2, ((Component)Avatar).transform.forward); } } } return list; } } public static class MonsterMovesetRegistry { private static readonly Dictionary Movesets = new Dictionary { { "Gnome", typeof(GnomeMoveset) }, { "Bang", typeof(BangMoveset) }, { "Runner", typeof(RunnerMoveset) }, { "Hunter", typeof(HunterMoveset) }, { "Thin Man", typeof(ThinManMoveset) }, { "Upscream", typeof(UpscreamMoveset) }, { "Duck", typeof(DuckMoveset) }, { "Bowtie", typeof(BowtieMoveset) }, { "Elsa", typeof(ElsaMoveset) }, { "Robe", typeof(RobeMoveset) }, { "Beamer", typeof(BeamerMoveset) }, { "Floater", typeof(FloaterMoveset) }, { "Spinny", typeof(SpinnyMoveset) }, { "Slow Walker", typeof(SlowWalkerMoveset) }, { "Birthday Boy", typeof(BirthdayBoyMoveset) }, { "Hidden", typeof(HiddenMoveset) } }; public static Type GetMovesetType(string formDisplayName) { if (formDisplayName != null && Movesets.TryGetValue(formDisplayName, out var value)) { return value; } return typeof(DefaultMoveset); } } public class RobeMoveset : MonsterMoveset { public float attackRange = 2.5f; public float attackRadius = 1.4f; public int attackDamage = 32; public override float AttackCooldown => 1.8f; public override string AttackDisplayName => "Grasp"; public override Color HudColor => new Color(0.78f, 0.74f, 0.95f); public override int MonsterMaxHealth => 250; public override bool AllowJump => false; public override bool AllowCrouch => false; public override float MoveSpeedMultiplier => 1.15f; protected override void PerformAttack() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_0118: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("attack"); } foreach (PlayerAvatar item in OverlapPlayersInFront(attackRange, attackRadius)) { DamagePlayer(item, attackDamage, ((Component)item).transform.position); } Vector3 val = (((Object)(object)base.Avatar != (Object)null) ? ((Component)base.Avatar).transform.position : ((Component)this).transform.position); if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.CameraShake != (Object)null) { GameDirector.instance.CameraShake.ShakeDistance(4f, 3f, 8f, val, 0.35f); } if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.CameraImpact != (Object)null) { GameDirector.instance.CameraImpact.ShakeDistance(4f, 3f, 8f, val, 0.08f); } } } public class RunnerMoveset : MonsterMoveset { public float attackRange = 2f; public float attackRadius = 1.3f; public int attackDamage = 14; private const float AttackAnimHoldTime = 0.2f; private float _attackAnimTimer; public override bool AllowJump => true; public override float MoveSpeedMultiplier => 1.35f; public override float AttackCooldown => 0.4f; public override string AttackDisplayName => "Slash"; public override Color HudColor => new Color(0.82f, 0.62f, 0.25f); public override int MonsterMaxHealth => 250; protected override void OnTick() { if (!(_attackAnimTimer <= 0f)) { _attackAnimTimer -= Time.deltaTime; if (_attackAnimTimer <= 0f && (Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("attacking", false); } } } protected override void PerformAttack() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("attacking", true); } _attackAnimTimer = 0.2f; foreach (PlayerAvatar item in OverlapPlayersInFront(attackRange, attackRadius)) { DamagePlayer(item, attackDamage, ((Component)item).transform.position); } } } public class SlowWalkerMoveset : MonsterMoveset { [Header("Vacuum implosion")] public float windupDuration = 1f; public float impactRadius = 5f; public int impactDamage = 45; private bool _charging; private float _chargeTimer; private Light _vacuumGlow; public override float AttackCooldown => 3f; public override string AttackDisplayName => "Vacuum Crush"; public override bool AllowJump => false; public override bool AllowCrouch => false; public override float MoveSpeedMultiplier => 0.65f; public override Color HudColor => new Color(0.65f, 0.85f, 0.25f); public override int MonsterMaxHealth => 500; protected override void OnInit() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("VacuumGlow"); val.transform.SetParent(((Component)this).transform, false); _vacuumGlow = val.AddComponent(); _vacuumGlow.type = (LightType)2; _vacuumGlow.color = HudColor; _vacuumGlow.range = impactRadius * 2f; _vacuumGlow.intensity = 0f; ((Behaviour)_vacuumGlow).enabled = false; } protected override void OnTick() { //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_0049: Unknown result type (might be due to invalid IL or missing references) if (!_charging) { return; } _chargeTimer -= Time.deltaTime; if ((Object)(object)_vacuumGlow != (Object)null) { ((Component)_vacuumGlow).transform.position = ((Component)base.Avatar).transform.position + Vector3.up; float num = 1f - Mathf.Clamp01(_chargeTimer / windupDuration); _vacuumGlow.intensity = Mathf.Lerp(0.5f, 6f, num); } if (_chargeTimer <= 0f) { _charging = false; if ((Object)(object)_vacuumGlow != (Object)null) { ((Behaviour)_vacuumGlow).enabled = false; } ResolveImpact(); } } protected override void PerformAttack() { _charging = true; _chargeTimer = windupDuration; if ((Object)(object)_vacuumGlow != (Object)null) { ((Behaviour)_vacuumGlow).enabled = true; _vacuumGlow.intensity = 0.5f; } } private void ResolveImpact() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Attack"); } foreach (PlayerAvatar item in OverlapPlayersInFront(0f, impactRadius)) { DamagePlayer(item, impactDamage, ((Component)base.Avatar).transform.position); } } } public class SpinnyMoveset : MonsterMoveset { [Header("Roulette grab")] public float grabRange = 2.2f; public float grabRadius = 1.6f; private const float MouthOpenHoldTime = 1f; private float _mouthOpenTimer; public override float AttackCooldown => 3.8f; public override string AttackDisplayName => "Roulette"; public override Color HudColor => new Color(1f, 0.65f, 0.1f); public override float MoveSpeedMultiplier => 1.15f; public override int MonsterMaxHealth => 150; protected override void OnTick() { if (!(_mouthOpenTimer <= 0f)) { _mouthOpenTimer -= Time.deltaTime; if (_mouthOpenTimer <= 0f && (Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("open_mouth_bool", false); base.MonsterAnimator.SetBool("close_mouth_bool", true); } } } protected override void PerformAttack() { //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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) List list = OverlapPlayersInFront(grabRange, grabRadius); if (list.Count != 0) { if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetBool("close_mouth_bool", false); base.MonsterAnimator.SetBool("open_mouth_bool", true); } _mouthOpenTimer = 1f; PlayerAvatar val = list[0]; Vector3 position = ((Component)val).transform.position; int num = Random.Range(0, 9); if (num < 4) { DamagePlayer(val, 45, position); } else if (num < 6) { val.playerHealth.HealOther(25, true); } else if (num < 7) { val.playerHealth.HealOther(100, true); } else if (num < 8) { DamagePlayer(val, 60, position); } } } } public class ThinManMoveset : MonsterMoveset { private const float TentacleRange = 20f; private const int TentacleDamage = 50; private const float TentacleVisualDuration = 0.35f; private LineRenderer _tentacleVisual; private float _visualTimer; public override float AttackCooldown => 2.5f; public override string AttackDisplayName => "Tentacle Lash"; public override Color HudColor => new Color(0.72f, 0.88f, 0.58f); public override int MonsterMaxHealth => 150; public override bool AllowJump => false; public override bool AllowCrouch => false; public override float MoveSpeedMultiplier => 0.9f; protected override void OnInit() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_005c: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ThinManTentacleVisual"); val.transform.SetParent(((Component)this).transform, false); _tentacleVisual = val.AddComponent(); _tentacleVisual.positionCount = 2; _tentacleVisual.startWidth = 0.12f; _tentacleVisual.endWidth = 0.03f; ((Renderer)_tentacleVisual).material = VfxMaterial.CreateUnlit(HudColor); _tentacleVisual.startColor = HudColor; _tentacleVisual.endColor = new Color(HudColor.r, HudColor.g, HudColor.b, 0.1f); ((Renderer)_tentacleVisual).enabled = false; } protected override void OnTick() { if (!(_visualTimer <= 0f)) { _visualTimer -= Time.deltaTime; if (_visualTimer <= 0f) { ((Renderer)_tentacleVisual).enabled = false; } } } protected override void PerformAttack() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Scream"); } var (val, val2) = RaycastFromCamera(20f); if ((Object)(object)val != (Object)null) { DamagePlayer(val, 50, val2); } Vector3 val3 = (((Object)(object)base.Avatar != (Object)null) ? (((Component)base.Avatar).transform.position + Vector3.up) : ((Component)this).transform.position); _tentacleVisual.SetPosition(0, val3); _tentacleVisual.SetPosition(1, val2); ((Renderer)_tentacleVisual).enabled = true; _visualTimer = 0.35f; } } public class UpscreamMoveset : MonsterMoveset { public float attackRange = 1.8f; public float attackRadius = 1.4f; public int attackDamage = 20; public float launchForce = 40f; public float launchTorque = 30f; public float launchUpwardBias = 0.6f; public float tumbleDuration = 1.2f; public override float AttackCooldown => 1.2f; public override string AttackDisplayName => "Scream"; public override Color HudColor => new Color(0.55f, 0.05f, 0.1f); public override int MonsterMaxHealth => 50; public override float MoveSpeedMultiplier => 1.5f; protected override void PerformAttack() { //IL_0046: 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_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.MonsterAnimator != (Object)null) { base.MonsterAnimator.SetTrigger("Attack"); } foreach (PlayerAvatar item in OverlapPlayersInFront(attackRange, attackRadius)) { Vector3 position = ((Component)item).transform.position; DamagePlayer(item, attackDamage, position); LaunchPlayer(item); } } private void LaunchPlayer(PlayerAvatar target) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0039: 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_0049: 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_005a: 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_0070: 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) PlayerTumble tumble = GameFieldAccess.GetTumble(target); if (!((Object)(object)tumble == (Object)null)) { Vector3 val = ((Component)target).transform.position - ((Component)base.Avatar).transform.position; Vector3 val2 = Vector3.Lerp(((Vector3)(ref val)).normalized, Vector3.up, launchUpwardBias); tumble.TumbleRequest(true, false); tumble.TumbleForce(val2 * launchForce); tumble.TumbleTorque(-((Component)target).transform.right * launchTorque); tumble.TumbleOverrideTime(tumbleDuration); } } } } namespace BecomeTheMonster.Patches { [HarmonyPatch(typeof(EnemyDirector), "AmountSetup")] internal static class EnemyDirectorAmountSetupPatch { private static readonly FieldRef TotalAmountRef = AccessTools.FieldRefAccess("totalAmount"); private static bool Prefix(EnemyDirector __instance) { TotalAmountRef.Invoke(__instance) = 0; return false; } } [HarmonyPatch(typeof(EnemyParent), "Awake")] internal static class EnemyParentAwakePatch { private static bool Prefix() { return false; } } [HarmonyPatch(typeof(LevelGenerator), "EnemySpawn")] internal static class LevelGeneratorEnemySpawnPatch { private static bool Prefix() { return false; } } [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] internal static class LevelGeneratorGenerateDonePatch { private static void Postfix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if ((Object)(object)MonsterDirector.instance == (Object)null) { GameObject val = new GameObject("BecomeTheMonster_MonsterDirector"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); } MonsterDirector.instance.SelectAndAssignMonsters(); } } [HarmonyPatch(typeof(PlayerAvatarMenuHover), "Awake")] internal static class PlayerAvatarMenuHoverAwakePatch { private static void Postfix(PlayerAvatarMenuHover __instance) { //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_0051: 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_0077: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00f3: Unknown result type (might be due to invalid IL or missing references) PlayerAvatarMenu playerAvatarMenu = __instance.playerAvatarMenu; if (!((Object)(object)playerAvatarMenu == (Object)null) && !playerAvatarMenu.expressionAvatar && !playerAvatarMenu.iconMakerAvatar && !playerAvatarMenu.worldAvatar) { RectTransform component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { GameObject val = new GameObject("BecomeTheMonster_FormLabel"); val.transform.SetParent((Transform)(object)component, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(0.5f, 1f); obj.anchorMax = new Vector2(0.5f, 1f); obj.pivot = new Vector2(0.5f, 0f); obj.anchoredPosition = new Vector2(0f, 8f); obj.sizeDelta = new Vector2(400f, 40f); TextMeshProUGUI val2 = val.AddComponent(); ((TMP_Text)val2).alignment = (TextAlignmentOptions)514; ((TMP_Text)val2).fontSize = 22f; ((TMP_Text)val2).fontStyle = (FontStyles)1; ((Graphic)val2).color = new Color(0.9f, 0.1f, 0.1f); ((TMP_Text)val2).text = string.Empty; val.AddComponent().label = val2; } } } } internal class MonsterPreviewLabel : MonoBehaviour { public TextMeshProUGUI label; private void Update() { if (!((Object)(object)label == (Object)null)) { PlayerAvatar instance = PlayerAvatar.instance; MonsterPossession monsterPossession = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent() : null); ((TMP_Text)label).text = (((Object)(object)monsterPossession != (Object)null) ? monsterPossession.formName.ToUpperInvariant() : string.Empty); } } } [HarmonyPatch(typeof(MenuPlayerHead), "Update")] internal static class MenuPlayerHeadPatch { private static readonly Color MonsterTop = new Color(0.55f, 0f, 0f); private static readonly Color MonsterBottom = Color.black; private static readonly FieldRef PlayerAvatarRef = AccessTools.FieldRefAccess("playerAvatar"); private static void Postfix(MenuPlayerHead __instance) { //IL_0073: 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) PlayerAvatar val = PlayerAvatarRef.Invoke(__instance); if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).GetComponent() == (Object)null) { return; } RawImage[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); foreach (RawImage val2 in componentsInChildren) { if (!(((Object)val2).name == "Arena Crown") && !(((Object)val2).name == "Steam Icon")) { ((Graphic)val2).color = ((((Object)val2).name == "Jaw Sprite") ? MonsterBottom : MonsterTop); } } } } [HarmonyPatch(typeof(PlayerAvatar), "PlayerDeathRPC")] internal static class PlayerAvatarDeathPatch { private static bool Prefix(PlayerAvatar __instance) { MonsterPossession component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return true; } component.OnMonsterDeath(); return false; } } [HarmonyPatch(typeof(PlayerAvatarMenu), "Start")] internal static class PlayerAvatarMenuStartPatch { private static readonly FieldRef PlayerVisualsRef = AccessTools.FieldRefAccess("playerVisuals"); private static void Postfix(PlayerAvatarMenu __instance) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (__instance.expressionAvatar || __instance.iconMakerAvatar || __instance.worldAvatar) { return; } PlayerAvatar instance = PlayerAvatar.instance; MonsterPossession monsterPossession = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent() : null); if ((Object)(object)monsterPossession == (Object)null || (Object)(object)monsterPossession.enemyPrefab == (Object)null) { return; } PlayerAvatarVisuals val = PlayerVisualsRef.Invoke(__instance); if ((Object)(object)val == (Object)null) { return; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } GameObject val2 = Object.Instantiate(monsterPossession.enemyPrefab, ((Component)val).transform); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; Behaviour[] componentsInChildren2 = val2.GetComponentsInChildren(true); foreach (Behaviour val3 in componentsInChildren2) { if (!(val3 is Animator)) { val3.enabled = false; } } Collider[] componentsInChildren3 = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].enabled = false; } WidenPreviewFraming(__instance, val2); } private static void WidenPreviewFraming(PlayerAvatarMenu menu, GameObject preview) { //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) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)menu.cameraAndStuff == (Object)null) { return; } Camera componentInChildren = ((Component)menu.cameraAndStuff).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { return; } Bounds? val = null; Renderer[] componentsInChildren = preview.GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (val2 is MeshRenderer || val2 is SkinnedMeshRenderer) { if (!val.HasValue) { val = val2.bounds; continue; } Bounds value = val.Value; ((Bounds)(ref value)).Encapsulate(val2.bounds); val = value; } } if (val.HasValue) { Bounds value2 = val.Value; float y = ((Bounds)(ref value2)).size.y; float num = 60f * Mathf.Max(1f, y / 1.8f); componentInChildren.fieldOfView = Mathf.Min(num, 100f); } } } }