Decompiled source of ContentRepo v1.0.0
ContentRepo/ContentRepo.dll
Decompiled 7 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using DefaultNamespace; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using Unity.Mathematics; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Photon")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ContentRepo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ContentRepo")] [assembly: AssemblyTitle("ContentRepo")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 CWRepoMonsters { public static class BodyPose { public const int Pelvis = 0; public const int Stomach = 1; public const int Chest = 2; public const int Neck = 3; public const int Head = 4; public const int HeadTop = 5; public const int Nose = 6; public const int BicepL = 7; public const int ForearmL = 8; public const int PalmL = 9; public const int FingersL = 10; public const int BicepR = 11; public const int ForearmR = 12; public const int PalmR = 13; public const int FingersR = 14; public const int ThighL = 15; public const int KneeL = 16; public const int AnkleL = 17; public const int ToeL = 18; public const int ThighR = 19; public const int KneeR = 20; public const int AnkleR = 21; public const int ToeR = 22; public const int BoardRoot = 23; public const int BoardNose = 24; public const int BoardTail = 25; public const int Count = 26; private static readonly (BodypartType part, BodypartType parent, Vector3 local, Quaternion rest, int from, int to)[] Rig = new(BodypartType, BodypartType, Vector3, Quaternion, int, int)[15] { ((BodypartType)2, (BodypartType)0, new Vector3(0f, 0.4106f, 0f), Quaternion.identity, -1, -1), ((BodypartType)4, (BodypartType)2, new Vector3(0f, 0.3017f, 0f), Quaternion.identity, -1, -1), ((BodypartType)5, (BodypartType)2, new Vector3(-0.211f, 0.1387f, 0f), new Quaternion(0f, 0f, 0.7387f, 0.6741f), 7, 8), ((BodypartType)6, (BodypartType)5, new Vector3(0f, 0.4229f, 0f), new Quaternion(0.0875f, 0.0964f, 0.7344f, 0.6661f), 8, 9), ((BodypartType)7, (BodypartType)6, new Vector3(0f, 0.4151f, 0f), new Quaternion(0.0875f, 0.0964f, 0.7344f, 0.6661f), 9, 10), ((BodypartType)8, (BodypartType)2, new Vector3(0.2229f, 0.134f, 0f), new Quaternion(0f, 0f, -0.7359f, 0.677f), 11, 12), ((BodypartType)9, (BodypartType)8, new Vector3(0f, 0.4166f, 0f), new Quaternion(0.0847f, -0.094f, -0.737f, 0.6639f), 12, 13), ((BodypartType)10, (BodypartType)9, new Vector3(0f, 0.4123f, 0f), new Quaternion(0.0847f, -0.094f, -0.737f, 0.6639f), 13, 14), ((BodypartType)11, (BodypartType)0, new Vector3(-0.1375f, -0.0446f, 0f), new Quaternion(0.7071f, 0f, 0.7071f, 0f), 15, 16), ((BodypartType)12, (BodypartType)11, new Vector3(0f, 0.4424f, 0f), new Quaternion(0f, 0f, 1f, 0f), 16, 17), ((BodypartType)13, (BodypartType)12, new Vector3(0f, 0.4716f, 0f), new Quaternion(0.5f, 0.5f, 0.5f, 0.5f), 17, 18), ((BodypartType)14, (BodypartType)0, new Vector3(0.134f, -0.0446f, 0f), new Quaternion(0.7071f, 0f, 0.7071f, 0f), 19, 20), ((BodypartType)15, (BodypartType)14, new Vector3(0f, 0.4424f, 0f), new Quaternion(0f, 0f, 1f, 0f), 20, 21), ((BodypartType)16, (BodypartType)15, new Vector3(0f, 0.4716f, 0f), new Quaternion(0.5f, 0.5f, 0.5f, 0.5f), 21, 22), ((BodypartType)39, (BodypartType)0, new Vector3(0f, 0.1327f, -0.3622f), new Quaternion(-0.0286f, 0f, 0f, 0.9996f), -1, -1) }; private static readonly Dictionary<BodypartType, Quaternion> _rot = new Dictionary<BodypartType, Quaternion>(); private static readonly Dictionary<BodypartType, Vector3> _pos = new Dictionary<BodypartType, Vector3>(); public static void Place(Player p, Vector3[] J, Vector3 at, Quaternion root) { //IL_001e: 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_0061: 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_006d: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009c: 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_00a4: 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_00c8: 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_00d0: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f9: Invalid comparison between Unknown and I4 //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Invalid comparison between Unknown and I4 //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //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_0112: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_016a: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: 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) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) ((Behaviour)p.refs.animator).enabled = false; p.data.rotationOvveride = Quaternion.Euler(0f, ((Quaternion)(ref root)).eulerAngles.y, 0f); p.data.rotationOvverideStr = 1f; Dictionary<BodypartType, Quaternion> rot = _rot; Dictionary<BodypartType, Vector3> pos = _pos; rot.Clear(); pos.Clear(); rot[(BodypartType)0] = root * Frame(J[19] - J[15], J[1] - J[0]); pos[(BodypartType)0] = at + root * J[0]; (BodypartType, BodypartType, Vector3, Quaternion, int, int)[] rig = Rig; BodypartType val; BodypartType key; Vector3 val2; Quaternion value; for (int i = 0; i < rig.Length; rot[val] = value, pos[val] = pos[key] + rot[key] * val2, i++) { Quaternion val3; int num; int num2; (val, key, val2, val3, num, num2) = rig[i]; if ((int)val == 2) { value = root * Frame(J[11] - J[7], J[3] - J[2]); continue; } Vector3 val4; if ((int)val == 4) { val4 = J[5] - J[4]; Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = Vector3.ProjectOnPlane(J[6] - J[4], normalized); value = ((((Vector3)(ref val5)).sqrMagnitude > 1E-06f) ? (root * Quaternion.LookRotation(((Vector3)(ref val5)).normalized, normalized)) : rot[key]); continue; } if (num >= 0) { val4 = J[num2] - J[num]; if (((Vector3)(ref val4)).sqrMagnitude > 1E-08f) { Quaternion val6 = root; Vector3 val7 = val3 * Vector3.up; val4 = J[num2] - J[num]; value = val6 * (Quaternion.FromToRotation(val7, ((Vector3)(ref val4)).normalized) * val3); continue; } } value = rot[key] * val3; } foreach (Bodypart bodypart in p.refs.ragdoll.bodypartList) { if (!((Object)(object)bodypart == (Object)null) && !((Object)(object)bodypart.rig == (Object)null) && pos.TryGetValue(bodypart.bodypartType, out var value2)) { bodypart.rig.isKinematic = true; ((Component)bodypart.rig).transform.SetPositionAndRotation(value2, rot[bodypart.bodypartType]); if ((Object)(object)bodypart.animationTarget != (Object)null) { ((Component)bodypart.animationTarget).transform.SetPositionAndRotation(value2, rot[bodypart.bodypartType]); } } } static Quaternion Frame(Vector3 right, Vector3 upv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_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) Vector3 val8 = Vector3.Cross(right, upv); return Quaternion.LookRotation(((Vector3)(ref val8)).normalized, ((Vector3)(ref upv)).normalized); } } public static void Release(Player p, Vector3 velocity) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null) { return; } ((Behaviour)p.refs.animator).enabled = true; p.data.rotationOvverideStr = 0f; foreach (Rigidbody rig in p.refs.ragdoll.rigList) { if ((Object)(object)rig != (Object)null) { rig.isKinematic = false; rig.linearVelocity = velocity; } } } } public class DangerEntry : MonoBehaviour, IBudgetCost, IHasPatrolGroup { public MonsterDef Def; public int Points; public int Tier; public int Troop = 1; public float Weight = 1f; public int Cost => Points; public float Rarity => Weight; public List<PatrolGroup> GetGroup() { return Enum.GetValues(typeof(PatrolGroup)).Cast<PatrolGroup>().ToList(); } GameObject IBudgetCost.get_gameObject() { return ((Component)this).gameObject; } } public static class DangerTiers { [HarmonyPatch(typeof(RoundSpawner), "GetMonster")] private static class GetMonsterPatch { private static bool Prefix(RoundSpawner __instance, ref int budget, int biggestPurchase, ref IBudgetCost __result) { try { if (__instance != _forSpawner) { _forSpawner = __instance; _bigOnes = 0; _bosses = 0; _secret = 0; List<IBudgetCost> list = ((IEnumerable<IBudgetCost>)(((object)__instance.spawnBudgetCosts) ?? ((object)new IBudgetCost[0]))).Where((IBudgetCost x) => !(x is DangerEntry)).ToList(); list.AddRange((IEnumerable<IBudgetCost>)Entries()); __instance.spawnBudgetCosts = list.ToArray(); Log.Info(string.Format("Danger tiers: day {0}, {1} ContentRepo monsters join CW's budget; tier 3+ allowed {2}, bosses {3}", Day, Entries().Count, BigOnesAllowed(), (Day >= (int)Cfg["boss_from_day"]) ? ((int)Cfg["boss_max"]) : 0)); } bool flag = Day >= (int)Cfg["boss_from_day"] && _bosses < (int)Cfg["boss_max"]; bool flag2 = _bigOnes < BigOnesAllowed(); int num = ((!PhotonNetwork.InRoom) ? 1 : PhotonNetwork.CurrentRoom.PlayerCount) + TestDummy.All.Count((TestDummy d) => (Object)(object)d != (Object)null && !d.Dead); bool flag3 = Day >= (int)Cfg["boss_from_day"] && _secret == 0 && num >= 2; int b = budget; bool flag4 = flag3 && __instance.spawnBudgetCosts.Any((IBudgetCost m) => m != null && TierOf(m) == 5 && m.Cost <= biggestPurchase && m.Cost <= b); List<(IBudgetCost, float)> list2 = new List<(IBudgetCost, float)>(); float num2 = 0f; IBudgetCost[] spawnBudgetCosts = __instance.spawnBudgetCosts; foreach (IBudgetCost val in spawnBudgetCosts) { if (val == null || val.Cost > biggestPurchase || val.Cost > b) { continue; } int num4 = TierOf(val); if (num4 >= 5) { if (!flag3 || (num4 == 6 && flag4)) { continue; } } else if ((num4 >= 3 && !flag2) || (num4 == 4 && !flag)) { continue; } float num5 = (float)val.Cost / (float)Mathf.Max(1, b) * val.Rarity; if (!(num5 <= 0f)) { list2.Add((val, num5)); num2 += num5; } } if (list2.Count == 0) { return true; } float num6 = Random.Range(0f, num2); IBudgetCost val2 = list2[list2.Count - 1].Item1; foreach (var item3 in list2) { IBudgetCost item = item3.Item1; float item2 = item3.Item2; num6 -= item2; if (num6 <= 0f) { val2 = item; break; } } int num7 = TierOf(val2); if (num7 >= 5) { _secret++; Log.Info($"Danger tiers: a tier {num7} secret boss is coming"); } else if (num7 >= 3) { _bigOnes++; if (num7 >= 4) { _bosses++; } } budget -= val2.Cost; __result = val2; return false; } catch (Exception ex) { Log.Error("danger tiers: " + ex.Message); return true; } } } [HarmonyPatch(typeof(RoundSpawner), "SpawnMonster")] private static class SpawnMonsterPatch { private static bool Prefix(IBudgetCost monster, PatrolPoint p) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if (!(monster is DangerEntry dangerEntry)) { return true; } if ((Object)(object)MonsterNet.Instance == (Object)null || (Object)(object)p == (Object)null) { return false; } Vector3 spot = ((Component)p).transform.position; NavMeshHit val = default(NavMeshHit); if (dangerEntry.Def.Behaviour == "giant") { List<Vector3> points = (from x in Level.currentLevel.patrolGroups.Values.SelectMany((List<PatrolPoint> v) => v) where (Object)(object)x != (Object)null select ((Component)x).transform.position).ToList(); if (!Monster.TallSpawnSpot(dangerEntry.Def, points, out spot)) { Log.Info("Danger tiers: " + dangerEntry.Def.Name + " bought, but nowhere tall enough here"); return false; } } else if (NavMesh.SamplePosition(spot, ref val, 4f, -1)) { spot = ((NavMeshHit)(ref val)).position; } Log.Info(string.Format("Danger tiers: CW's spawner sends a {0} (tier {1}, {2} points{3})", dangerEntry.Def.Name, dangerEntry.Tier, dangerEntry.Points, (dangerEntry.Troop > 1) ? $", a troop of {dangerEntry.Troop}" : "")); Monster monster2 = MonsterNet.Instance.MasterSpawn(dangerEntry.Def.Index, spot, Random.Range(0f, 360f)); if (dangerEntry.Troop > 1 && (Object)(object)monster2 != (Object)null && dangerEntry.Def.Behaviour == "baboon") { monster2.BaboonExpectTroop(); } if (dangerEntry.Troop > 1) { JToken val2 = Cfg["monsters"][(object)dangerEntry.Def.Id][(object)"troop_delay"]; float num = ((val2 != null) ? ((float)val2[(object)0]) : 1f); float num2 = ((val2 != null) ? ((float)val2[(object)1]) : 60f); Level currentLevel = Level.currentLevel; for (int num3 = 1; num3 < dangerEntry.Troop; num3++) { ((MonoBehaviour)MonsterNet.Instance).StartCoroutine(TroopMember(dangerEntry, currentLevel, num3 + 1, Random.Range(num, num2))); } } return false; } private static IEnumerator TroopMember(DangerEntry d, Level level, int n, float after) { Log.Info($"Danger tiers: {d.Def.Name} troop member {n} comes in {after:F0}s"); yield return (object)new WaitForSeconds(after); if ((Object)(object)Level.currentLevel != (Object)(object)level || (Object)(object)level == (Object)null || !PhotonNetwork.IsMasterClient) { yield break; } List<Vector3> others = (from m in MonsterNet.Instance.Monsters.Values where (Object)(object)m != (Object)null && m.Def == d.Def select ((Component)m).transform.position).ToList(); List<Vector3> list = (from x in level.patrolGroups.Values.SelectMany((List<PatrolPoint> v) => v) where (Object)(object)x != (Object)null select ((Component)x).transform.position).ToList(); if (list.Count == 0) { yield break; } Player val3 = default(Player); List<Vector3> list2 = list.Where((Vector3 c) => !PlayerHandler.instance.CanAnAlivePlayerSeePoint(c, ref val3, (Player)null)).ToList(); if (list2.Count > 0) { list = list2; } Vector3 far = ((others.Count == 0) ? list[Random.Range(0, list.Count)] : list.OrderByDescending((Vector3 c) => others.Min((Vector3 s) => Vector3.Distance(s, c))).First()); NavMeshHit val2 = default(NavMeshHit); Vector3 val = (NavMesh.SamplePosition(far, ref val2, 4f, -1) ? ((NavMeshHit)(ref val2)).position : far); Log.Info(string.Format("Danger tiers: troop member {0} arrives at {1}{2}", n, val, (others.Count > 0) ? $", {others.Min((Vector3 s) => Vector3.Distance(s, far)):F0} m from the others" : "")); Monster monster = MonsterNet.Instance.MasterSpawn(d.Def.Index, val, Random.Range(0f, 360f)); if ((Object)(object)monster != (Object)null && d.Def.Behaviour == "baboon") { monster.BaboonExpectTroop(); } } } private static List<DangerEntry> _entries; private static RoundSpawner _forSpawner; private static int _bigOnes; private static int _bosses; private static int _secret; private static JObject Cfg => (JObject)Plugin.Cache.World.Raw["danger"]; private static int Day { get { if (SurfaceNetworkHandler.RoomStats == null) { return 1; } return Mathf.Max(1, SurfaceNetworkHandler.RoomStats.CurrentDay); } } private static List<DangerEntry> Entries() { //IL_0026: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (_entries != null) { return _entries; } _entries = new List<DangerEntry>(); foreach (JProperty p in ((JObject)Cfg["monsters"]).Properties()) { MonsterDef monsterDef = Plugin.Cache.Monsters.FirstOrDefault((MonsterDef d) => d.Id == p.Name); if (monsterDef == null) { Log.Warn("danger: monster '" + p.Name + "' isn't in the cache"); continue; } GameObject val = new GameObject("ContentRepo danger " + monsterDef.Id); val.transform.SetParent(Plugin.Root.transform, false); DangerEntry dangerEntry = val.AddComponent<DangerEntry>(); dangerEntry.Def = monsterDef; dangerEntry.Tier = (int)p.Value[(object)"tier"]; dangerEntry.Points = (int)p.Value[(object)"points"]; dangerEntry.Weight = ((float?)p.Value[(object)"rarity"]) ?? ((float)Cfg["rarity"]); dangerEntry.Troop = ((int?)p.Value[(object)"troop"]) ?? 1; _entries.Add(dangerEntry); } return _entries; } private static int TierOf(IBudgetCost m) { if (m is DangerEntry dangerEntry) { return dangerEntry.Tier; } foreach (JToken item in (IEnumerable<JToken>)Cfg["cw_tiers"]) { if (m.Cost <= (int)item[(object)0]) { return (int)item[(object)1]; } } return 4; } private static int BigOnesAllowed() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown JObject val = (JObject)Cfg["tier3_max"]; int num = (Day - 1) / 3; return Mathf.Min((int)val["max"], (int)val["base"] + (int)val["per_week"] * num); } } public static class DevField { private static readonly Vector3 Origin = new Vector3(3000f, -60f, 3000f); private const float Size = 60f; private static GameObject _root; private static NavMeshDataInstance _nav; private static Vector3? _returnPos; private static Vector3 _returnFwd; public static bool Enabled => File.Exists(Path.Combine(Plugin.Dir, "testfield.txt")); public static void Build(string scene) { if (Enabled) { if ((Object)(object)_root == (Object)null) { BuildField(); } BuildBedroomButton(scene); } } private static void BuildField() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //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_004f: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_036d: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: 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) //IL_017d: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("CWRM Dev Field"); _root.transform.position = Origin; int layer = LayerMask.NameToLayer("Terrain"); Material val = new Material(Plugin.Cache.LitShader()) { name = "CWRM dev field" }; val.SetColor("_BaseColor", new Color(0.55f, 0.55f, 0.55f)); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "Ground"; obj.layer = layer; obj.transform.SetParent(_root.transform, false); obj.transform.localPosition = Vector3.down * 0.5f; obj.transform.localScale = new Vector3(60f, 1f, 60f); ((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = val; for (int i = 0; i < 4; i++) { GameObject val2 = new GameObject("Edge") { layer = layer }; val2.transform.SetParent(_root.transform, false); BoxCollider obj2 = val2.AddComponent<BoxCollider>(); bool flag = i < 2; float num = ((i % 2 == 0) ? 1 : (-1)); obj2.size = (flag ? new Vector3(60f, 20f, 1f) : new Vector3(1f, 20f, 60f)); val2.transform.localPosition = (flag ? new Vector3(0f, 10f, num * 60f / 2f) : new Vector3(num * 60f / 2f, 10f, 0f)); } Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(-15f, 12f, -15f), new Vector3(15f, 12f, -15f), new Vector3(-15f, 12f, 15f), new Vector3(15f, 12f, 15f) }; foreach (Vector3 localPosition in array) { Light obj3 = new GameObject("Lamp").AddComponent<Light>(); ((Component)obj3).transform.SetParent(_root.transform, false); ((Component)obj3).transform.localPosition = localPosition; obj3.type = (LightType)2; obj3.range = 45f; obj3.intensity = 4f; obj3.shadows = (LightShadows)0; } BakeNavMesh(); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(-6f, 1.4f, -20f); Vector3 spawnAt = Origin + new Vector3(0f, 0.2f, 12f); Button("Spawn Secret 1", val3, new Color(1f, 0.35f, 0.3f), delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) MonsterNet.Instance.RequestSpawn(Idx("secret_1"), spawnAt, 180f); }); Button("Spawn Secret 2", val3 + Vector3.right * 3f, new Color(1f, 0.35f, 0.3f), delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) MonsterNet.Instance.RequestSpawn(Idx("secret_2"), spawnAt, 180f); }); Button("Spawn Test Player", val3 + Vector3.right * 6f, new Color(0.6f, 0.82f, 1f), delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) MonsterNet.Instance.RequestDummy(Origin + new Vector3(Random.Range(-3f, 3f), 0f, -14f), 0f); }); Button("Clear monsters", val3 + Vector3.right * 9f, Color.white, delegate { //IL_0005: Unknown result type (might be due to invalid IL or missing references) MonsterNet.Instance.RequestClear(Origin, 60f); }); Button("Go back", val3 + Vector3.right * 12f, Color.white, GoBack); Log.Info("Dev test field built"); static int Idx(string id) { return Plugin.Cache.Monsters.FindIndex((MonsterDef m) => m.Id == id); } } private static void BakeNavMesh() { //IL_004f: 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_005a: 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_0069: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_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_000c: Unknown result type (might be due to invalid IL or missing references) try { if (((NavMeshDataInstance)(ref _nav)).valid) { NavMesh.RemoveNavMeshData(_nav); } List<NavMeshBuildSource> list = new List<NavMeshBuildSource>(); NavMeshBuilder.CollectSources(_root.transform, LayerMask.GetMask(new string[2] { "Terrain", "Default" }), (NavMeshCollectGeometry)1, 0, new List<NavMeshBuildMarkup>(), list); _nav = NavMesh.AddNavMeshData(NavMeshBuilder.BuildNavMeshData(NavMesh.GetSettingsByID(0), list, new Bounds(Origin + Vector3.up * 5f, new Vector3(70f, 20f, 70f)), Vector3.zero, Quaternion.identity)); } catch (Exception ex) { Log.Warn("Dev field navmesh: " + ex.Message); } } private static void Button(string label, Vector3 local, Color color, Action<Player> press) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) DevButton.Make(_root.transform, label, local, color, 0.3f).OnPress = press; } private static void BuildBedroomButton(string scene) { //IL_0069: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0092: 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_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_00ff: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) JObject button = Plugin.Cache.World.Button; JToken obj = ((button != null) ? button["bedroom"] : null); JObject val = (JObject)(object)((obj is JObject) ? obj : null); if (val == null || scene != (string)val["scene"]) { return; } BedBoss val2 = Object.FindObjectOfType<BedBoss>(); if ((Object)(object)val2 == (Object)null || ((Component)val2).transform.childCount == 0) { Log.Warn("Dev field: no beds found for its button"); return; } Vector3 val3 = Vector3.zero; float num = float.MinValue; foreach (Transform item in ((Component)val2).transform) { Transform val4 = item; val3 += val4.position; Renderer[] componentsInChildren = ((Component)val4).GetComponentsInChildren<Renderer>(); foreach (Renderer val5 in componentsInChildren) { float num2 = num; Bounds bounds = val5.bounds; num = Mathf.Max(num2, ((Bounds)(ref bounds)).max.y); } } val3 /= (float)((Component)val2).transform.childCount; Transform transform = new GameObject("CWRM Dev Field Button").transform; transform.position = new Vector3(val3.x, ((num == float.MinValue) ? val3.y : num) + 1.1f, val3.z); DevButton.Make(transform, "Test Field", Vector3.zero, new Color(0.7f, 0.3f, 1f), 0.32f).OnPress = GoThere; } private static void GoThere(Player p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0077: 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_0095: Unknown result type (might be due to invalid IL or missing references) _returnPos = ((Component)p).transform.position + Vector3.up * 0.2f; Vector3 val = Vector3.ProjectOnPlane(p.data.lookDirection, Vector3.up); Vector3 returnFwd; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { returnFwd = Vector3.forward; } else { val = Vector3.ProjectOnPlane(p.data.lookDirection, Vector3.up); returnFwd = ((Vector3)(ref val)).normalized; } _returnFwd = returnFwd; p.Teleport(Origin + new Vector3(0f, 1.5f, -24f), Vector3.forward); } private static void GoBack(Player p) { //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_0058: 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_005d: 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_006d: Unknown result type (might be due to invalid IL or missing references) if (_returnPos.HasValue) { p.Teleport(_returnPos.Value, _returnFwd); return; } DivingBell val = Object.FindObjectsOfType<DivingBell>().FirstOrDefault(); if ((Object)(object)val != (Object)null) { p.Teleport((((Object)(object)val.itemSpawns != (Object)null) ? val.itemSpawns.position : ((Component)val).transform.position) + Vector3.up, ((Component)val).transform.forward); } } } public class DevButton : Interactable { public Action<Player> OnPress; public string Label; private Vector3 _base; private float _cooldown; public static DevButton Make(Transform parent, string label, Vector3 localPos, Color color, float size) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0079: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_019a: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val).name = "CWRM Button " + label; val.layer = LayerMask.NameToLayer("Interactable"); val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.transform.localScale = Vector3.one * size; Material val2 = new Material(Plugin.Cache.LitShader()) { name = "CWRM button" }; val2.SetColor("_BaseColor", color); val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", color * 0.6f); ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = val2; DevButton devButton = val.AddComponent<DevButton>(); devButton.Label = label; ((Interactable)devButton).hoverText = label; devButton._base = localPos; Light obj = new GameObject("Glow").AddComponent<Light>(); ((Component)obj).transform.SetParent(val.transform, false); obj.type = (LightType)2; obj.range = 2f; obj.intensity = 0.8f; obj.color = color; GameObject val3 = new GameObject("Label"); val3.transform.SetParent(parent, false); val3.transform.localPosition = localPos + Vector3.up * (size * 0.5f + 0.25f); TextMesh val4 = val3.AddComponent<TextMesh>(); val4.text = label; val4.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); ((Renderer)((Component)val4).GetComponent<MeshRenderer>()).sharedMaterial = val4.font.material; val4.characterSize = 0.035f; val4.fontSize = 48; val4.anchor = (TextAnchor)7; val4.color = Color.black; val3.AddComponent<FaceCamera>(); return devButton; } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references) _cooldown -= Time.deltaTime; ((Component)this).transform.localPosition = _base + Vector3.up * Mathf.Sin(Time.time * 1.6f) * 0.06f; } public override void Interact(Player player) { if (_cooldown > 0f) { return; } _cooldown = 0.5f; Log.Info("Button pressed: " + Label); try { OnPress?.Invoke(player); } catch (Exception arg) { Log.Error($"{Label}: {arg}"); } } } public static class FaceText { public static int Max { get { RepoCache cache = Plugin.Cache; object obj; if (cache == null) { obj = null; } else { WorldDef world = cache.World; if (world == null) { obj = null; } else { JObject raw = world.Raw; obj = ((raw != null) ? raw["face_text_max"] : null); } } JToken val = (JToken)obj; if (val == null) { return 5; } return (int)val; } } internal static IEnumerable<CodeInstruction> ReplaceThree(IEnumerable<CodeInstruction> code, string where) { MethodInfo getter = AccessTools.PropertyGetter(typeof(FaceText), "Max"); int n = 0; foreach (CodeInstruction item in code) { if (item.opcode == OpCodes.Ldc_I4_3) { n++; item.opcode = OpCodes.Call; item.operand = getter; } yield return item; } Log.Info($"Face text limit: {where} patched ({n} places)"); } } [HarmonyPatch(typeof(PlayerCustomizer), "TypeWithKeyboard")] internal static class FaceTypingPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code) { return FaceText.ReplaceThree(code, "terminal typing"); } } [HarmonyPatch(typeof(PlayerVisor), "SafetyCheckVisorText")] internal static class FaceVisorPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code) { return FaceText.ReplaceThree(code, "visor check"); } } public class FadeAndDie : MonoBehaviour { public float Life = 0.15f; private float _t; private LineRenderer _line; private Light _light; private float _w0; private float _w1; private float _i0; private void Start() { _line = ((Component)this).GetComponent<LineRenderer>(); _light = ((Component)this).GetComponentInChildren<Light>(); if ((Object)(object)_line != (Object)null) { _w0 = _line.startWidth; _w1 = _line.endWidth; } if ((Object)(object)_light != (Object)null) { _i0 = _light.intensity; } } private void Update() { _t += Time.deltaTime; float num = 1f - Mathf.Clamp01(_t / Life); if ((Object)(object)_line != (Object)null) { _line.startWidth = _w0 * num; _line.endWidth = _w1 * num; } if ((Object)(object)_light != (Object)null) { _light.intensity = _i0 * num; } if (_t >= Life) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class FleaBlind : MonoBehaviour { public static float CoveredUntil; private float _alpha; private Canvas _canvas; private CanvasGroup _group; private Canvas _helmet; private void Update() { bool flag = Time.time < CoveredUntil; _alpha = Mathf.MoveTowards(_alpha, flag ? 1f : 0f, Time.unscaledDeltaTime * (flag ? 8f : 4f)); if (_alpha <= 0f) { if ((Object)(object)_canvas != (Object)null) { ((Behaviour)_canvas).enabled = false; } return; } if ((Object)(object)_canvas == (Object)null) { Build(); } Attach(); ((Behaviour)_canvas).enabled = true; _group.alpha = _alpha; } private void Build() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0090: 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_0096: 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) GameObject val = new GameObject("CWRM FleaBlind"); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _group = val.AddComponent<CanvasGroup>(); _group.blocksRaycasts = false; _group.interactable = false; Image obj = new GameObject("Black").AddComponent<Image>(); ((Component)obj).transform.SetParent(val.transform, false); ((Graphic)obj).color = Color.black; ((Graphic)obj).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; } private void Attach() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 if ((Object)(object)_helmet == (Object)null || !((Behaviour)_helmet).isActiveAndEnabled) { _helmet = null; Canvas[] array = Object.FindObjectsOfType<Canvas>(); foreach (Canvas val in array) { if (((Object)val).name == "HelmetUI" && ((Behaviour)val).isActiveAndEnabled && (int)val.renderMode == 1) { _helmet = val; break; } } } Canvas val2 = (((Object)(object)_helmet != (Object)null && (Object)(object)_helmet.worldCamera != (Object)null) ? _helmet : null); if ((Object)(object)val2 != (Object)null) { _canvas.renderMode = (RenderMode)1; _canvas.worldCamera = val2.worldCamera; _canvas.planeDistance = val2.planeDistance + 0.01f; _canvas.sortingLayerID = val2.sortingLayerID; _canvas.sortingOrder = val2.sortingOrder - 1; } else { _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = -100; } } } public class GiantHold : MonoBehaviour { private static int _monster = -1; private static float _until; public static void Apply(int actorNr, int monsterId, float seconds) { Player localPlayer = Player.localPlayer; if (!((Object)(object)localPlayer == (Object)null) && localPlayer.refs.view.OwnerActorNr == actorNr) { _monster = monsterId; _until = Time.time + seconds; Log.Info((monsterId >= 0) ? $"Grabbed by monster #{monsterId}" : "Let go"); } } private void FixedUpdate() { //IL_00aa: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (_monster < 0) { return; } Player localPlayer = Player.localPlayer; if ((Object)(object)localPlayer == (Object)null || localPlayer.data.dead || Time.time > _until || (Object)(object)MonsterNet.Instance == (Object)null || !MonsterNet.Instance.Monsters.TryGetValue(_monster, out var value) || (Object)(object)value == (Object)null) { _monster = -1; return; } Transform val = value.Body.Slot("hold"); if ((Object)(object)val == (Object)null) { return; } localPlayer.refs.ragdoll.Fall(0.5f); Rigidbody rig = localPlayer.GetRig((BodypartType)0); if ((Object)(object)rig == (Object)null) { return; } localPlayer.MoveAllRigsInDirection(val.position - rig.position); foreach (Rigidbody rig2 in localPlayer.refs.ragdoll.rigList) { if ((Object)(object)rig2 != (Object)null) { rig2.linearVelocity = Vector3.zero; rig2.angularVelocity *= 0.5f; } } } } public class GnomeGrab : Interactable { public Monster Gnome; public static void AddTo(Monster gnome) { //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_001a: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) GameObject val = new GameObject("Grab") { layer = LayerMask.NameToLayer("Interactable") }; val.transform.SetParent(((Component)gnome).transform, false); val.transform.localPosition = Vector3.up * gnome.Def.Height * 0.5f; val.AddComponent<SphereCollider>().radius = Mathf.Max(0.3f, gnome.Def.Radius * 1.4f); GnomeGrab gnomeGrab = val.AddComponent<GnomeGrab>(); gnomeGrab.Gnome = gnome; ((Interactable)gnomeGrab).hoverText = "Pick up gnome"; } public override bool IsValid(Player player) { if ((Object)(object)Gnome != (Object)null) { return Gnome.CanBeGrabbed; } return false; } public override void Interact(Player player) { if (!((Object)(object)Gnome == (Object)null) && Gnome.CanBeGrabbed) { MonsterNet.Instance.RequestGrabGnome(Gnome.NetId, player.refs.view.ViewID); } } } public static class Hearing { private struct Ev { public Vector3 Pos; public float Loud; public float Time; } public struct Heard { public Vector3 Pos; public float Perceived; public Target Target; } private static readonly List<Ev> Events = new List<Ev>(); private const float EventLife = 0.6f; public static void Emit(Vector3 pos, float loudness) { //IL_0017: 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) if (PhotonNetwork.IsMasterClient) { Events.Add(new Ev { Pos = pos, Loud = loudness, Time = Time.time }); if (Events.Count > 64) { Events.RemoveAt(0); } } } public static IEnumerable<(Vector3 pos, float loud, Target who)> Sources(float since) { foreach (Target item in Target.All()) { float noise = item.Noise; if (noise > 0f) { yield return (pos: item.Ground, loud: noise, who: item); } } foreach (Ev @event in Events) { if (@event.Time > since && Time.time - @event.Time <= Mathf.Max(0.6f, 2f)) { yield return (pos: @event.Pos, loud: @event.Loud, who: null); } } } public static Heard Loudest(Vector3 pos, float range) { //IL_002b: 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_0066: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) Heard result = new Heard { Perceived = 0f }; foreach (Target item in Target.All()) { float num = Vector3.Distance(pos, item.Center); if (!(num > range)) { float num2 = item.Noise * (1f - num / range); if (num2 > result.Perceived) { result = new Heard { Pos = item.Ground, Perceived = num2, Target = item }; } } } for (int num3 = Events.Count - 1; num3 >= 0; num3--) { Ev ev = Events[num3]; if (Time.time - ev.Time > 0.6f) { Events.RemoveAt(num3); } else { float num4 = Vector3.Distance(pos, ev.Pos); if (!(num4 > range)) { float num5 = ev.Loud * (1f - num4 / range); if (num5 > result.Perceived) { result = new Heard { Pos = ev.Pos, Perceived = num5, Target = null }; } } } } return result; } } [HarmonyPatch(typeof(PhysicsSound), "OnCollisionEnter")] internal static class PhysicsSoundNoisePatch { private static void Prefix(PhysicsSound __instance, Collision collision, float ___counter) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) if (___counter < 0.5f) { return; } Vector3 relativeVelocity = collision.relativeVelocity; float sqrMagnitude = ((Vector3)(ref relativeVelocity)).sqrMagnitude; if (!(sqrMagnitude < 25f) && !((Object)(object)((Component)collision.collider).GetComponentInParent<Player>() != (Object)null)) { Monster componentInParent = ((Component)collision.collider).GetComponentInParent<Monster>(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.OnHitByItem(); } float loudness = Mathf.Clamp(Mathf.Sqrt(sqrMagnitude) / 12f, 0.35f, 1.2f); Hearing.Emit(((Component)__instance).transform.position, loudness); } } } public class ModContentProvider : ContentProvider { public Func<string> Live; public int Instance; public override void GetContent(List<ContentEventFrame> contentEvents, float seenAmount, Camera camera, float time) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) try { int num = ModContentEvent.IndexOf(Live?.Invoke()); if (num >= 0) { contentEvents.Add(new ContentEventFrame((ContentEvent)(object)new ModContentEvent { Kind = num, Instance = Instance }, seenAmount, time)); } } catch (Exception ex) { Log.Warn("mod content: " + ex.Message); } } } public class ModContentEvent : ContentEvent { public const ushort BaseId = 2780; public int Kind; public int Instance; private static List<string> _kinds; private static JObject Rows { get { JToken obj = Plugin.Cache.World.Raw["content"]; return (JObject)(object)((obj is JObject) ? obj : null); } } private static List<string> Kinds { get { object obj = _kinds; if (obj == null) { JObject rows = Rows; obj = ((rows != null) ? (from p in rows.Properties() where !p.Name.StartsWith("_") select p.Name).ToList() : null) ?? new List<string>(); _kinds = (List<string>)obj; } return (List<string>)obj; } } private JObject Row { get { if (Kind < 0 || Kind >= Kinds.Count) { return null; } JToken obj = Rows[Kinds[Kind]]; return (JObject)(object)((obj is JObject) ? obj : null); } } public static int IndexOf(string kind) { if (kind != null) { return Kinds.IndexOf(kind); } return -1; } public static bool Owns(ushort id) { if (id >= 2780) { return id < 2796; } return false; } public override float GetContentValue() { JObject row = Row; return ((float?)((row != null) ? row["value"] : null)) ?? 100f; } public override ushort GetID() { return (ushort)(2780 + Kind); } public override string GetName() { if (Kind < 0 || Kind >= Kinds.Count) { return "ContentRepo"; } return Kinds[Kind]; } public override int GetUniqueID() { return 28000000 + Kind * 10000 + Instance; } public override string[] GetAllComments() { JObject row = Row; string[] array = ((row == null) ? null : ((IEnumerable<JToken>)row["comments"])?.Select((JToken x) => (string)x).ToArray()); if (array == null || array.Length == 0) { array = new string[1] { "what is going on" }; } return array.Select((string x) => "CWRM:" + x).ToArray(); } public override Comment GenerateComment() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown string[] allComments = ((ContentEvent)this).GetAllComments(); return new Comment(allComments[Random.Range(0, allComments.Length)]); } public override void Serialize(BinarySerializer serializer) { serializer.WriteInt(Instance); } public override void Deserialize(BinaryDeserializer deserializer) { Instance = deserializer.ReadInt(); } } public static class ModHats { public static readonly List<Hat> Hats = new List<Hat>(); public static readonly List<string> Ids = new List<string>(); public static int CwCount = -1; private static GameObject _holder; public static int IndexOf(string id) { int num = Ids.IndexOf(id); if (num >= 0 && CwCount >= 0) { return CwCount + num; } return -1; } public static string IdAt(int index) { if (CwCount < 0 || index < CwCount || index - CwCount >= Ids.Count) { return null; } return Ids[index - CwCount]; } public static void Register() { //IL_0166: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown HatDatabase instance = HatDatabase.instance; if ((Object)(object)instance == (Object)null || instance.hats == null || instance.hats.Length == 0) { Log.Warn("Hats: CW's hat database isn't there yet"); } else { if ((Hats.Count > 0 && instance.hats.Contains(Hats[0])) || Plugin.Cache.Hats.Count == 0) { return; } Hat val = ((IEnumerable<Hat>)instance.hats).FirstOrDefault((Func<Hat, bool>)((Hat h) => (Object)(object)h != (Object)null && ((Object)h).name.ToLower().Contains("bowler"))) ?? instance.hats.First((Hat h) => (Object)(object)h != (Object)null); MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); Mesh val2 = ((component != null) ? component.sharedMesh : null); Bounds rb = (Bounds)(((Object)(object)val2 != (Object)null) ? val2.bounds : new Bounds(Vector3.zero, Vector3.one)); if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("CWRM hats"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } Hats.Clear(); Ids.Clear(); foreach (var (val3, nodes) in Plugin.Cache.Hats) { try { Hat val4 = Make(val3, nodes, val, rb); if ((Object)(object)val4 != (Object)null) { Hats.Add(val4); Ids.Add((string)val3["id"]); } } catch (Exception ex) { Log.Warn("Hat " + (string)val3["name"] + ": " + ex.Message); } } CwCount = instance.hats.Length; instance.hats = instance.hats.Concat(Hats).ToArray(); Log.Info(string.Format("Hats: {0} added to Content Warning's {1} ({2})", Hats.Count, CwCount, string.Join(", ", Hats.Select((Hat h) => h.displayName)))); ModHatSave.Sync(); } } private static Hat Make(JObject cfg, List<NodeDef> nodes, Hat bowler, Bounds rb) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00b1: 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) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) string text = (string)cfg["name"]; List<string> keys; Mesh val = Bake(nodes, text, out keys); if ((Object)(object)val == (Object)null) { Log.Warn("Hat " + text + ": nothing to bake"); return null; } Fit(val, cfg, rb); GameObject val2 = new GameObject("CWRM Hat " + text); val2.transform.SetParent(_holder.transform, false); val2.transform.localScale = ((Component)bowler).transform.localScale; val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterials = keys.Select(Plugin.Cache.GetMaterial).ToArray(); val2.AddComponent<ModHatLook>().Keys = keys; Hat obj = val2.AddComponent<Hat>(); obj.displayName = text; obj.rarity = (RARITY)((!Enum.TryParse<RARITY>(((string)cfg["rarity"]) ?? "rare", out RARITY result)) ? 10000 : ((int)result)); obj.giveContentEvent = true; obj.contentValue = ((int?)cfg["content_value"]) ?? 60; obj.comments = ((IEnumerable<JToken>)(((object)cfg["comments"]) ?? ((object)new JArray()))).Select((JToken c) => "CWRM:" + (string)c).DefaultIfEmpty("CWRM:nice hat").ToArray(); return obj; } private static Mesh Bake(List<NodeDef> nodes, string name, out List<string> keys) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00dc: Unknown result type (might be due to invalid IL or missing references) keys = new List<string>(); GameObject val = new GameObject("CWRM hat bake"); try { List<Transform> list = Plugin.Cache.BuildNodes(nodes, val.transform); Transform transform = val.transform; List<CombineInstance> list2 = new List<CombineInstance>(); for (int i = 0; i < list.Count; i++) { NodeDef nodeDef = nodes[i]; MeshFilter component = ((Component)list[i]).GetComponent<MeshFilter>(); if (nodeDef.Mesh != null && !((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && ((Component)list[i]).gameObject.activeInHierarchy) { Matrix4x4 transform2 = transform.worldToLocalMatrix * list[i].localToWorldMatrix; for (int j = 0; j < component.sharedMesh.subMeshCount; j++) { CombineInstance item = default(CombineInstance); ((CombineInstance)(ref item)).mesh = component.sharedMesh; ((CombineInstance)(ref item)).subMeshIndex = j; ((CombineInstance)(ref item)).transform = transform2; list2.Add(item); keys.Add((nodeDef.Mats != null && j < nodeDef.Mats.Length) ? nodeDef.Mats[j] : null); } } } if (list2.Count == 0) { return null; } Mesh val2 = new Mesh { name = "CWRM hat " + name, indexFormat = (IndexFormat)1 }; val2.CombineMeshes(list2.ToArray(), false, true); return val2; } finally { Object.Destroy((Object)(object)val); } } private static void Fit(Mesh mesh, JObject cfg, Bounds rb) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0055: 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_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_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0099: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00ca: 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) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ed: 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) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: 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_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Euler(((float?)cfg["tilt"]).GetValueOrDefault(), ((float?)cfg["yaw"]).GetValueOrDefault(), 0f); Vector3[] vertices = mesh.vertices; Vector3[] normals = mesh.normals; Bounds bounds = mesh.bounds; Vector3 center = ((Bounds)(ref bounds)).center; Vector3 val2 = Vector3.positiveInfinity; Vector3 val3 = Vector3.negativeInfinity; for (int i = 0; i < vertices.Length; i++) { Vector3 val4 = val * (vertices[i] - center); vertices[i] = new Vector3(val4.x, 0f - val4.z, val4.y); val2 = Vector3.Min(val2, vertices[i]); val3 = Vector3.Max(val3, vertices[i]); if (i < normals.Length) { Vector3 val5 = val * normals[i]; normals[i] = new Vector3(val5.x, 0f - val5.z, val5.y); } } float num = Mathf.Max(((Bounds)(ref rb)).size.x, ((Bounds)(ref rb)).size.y); float num2 = (((float?)cfg["size"]) ?? 1f) * num / Mathf.Max(new float[3] { val3.x - val2.x, val3.y - val2.y, 0.0001f }); Vector3 val6 = default(Vector3); Vector3 val7 = default(Vector3); if ((string)cfg["seat"] == "face") { ((Vector3)(ref val6))..ctor(((Bounds)(ref rb)).center.x, ((Bounds)(ref rb)).min.y - ((float?)cfg["forward"]).GetValueOrDefault() * num, ((Bounds)(ref rb)).min.z - (((float?)cfg["down"]) ?? 0.4f) * num); ((Vector3)(ref val7))..ctor((val2.x + val3.x) / 2f, val3.y, (val2.z + val3.z) / 2f); } else { ((Vector3)(ref val6))..ctor(((Bounds)(ref rb)).center.x, ((Bounds)(ref rb)).center.y, ((Bounds)(ref rb)).min.z + ((float?)cfg["lift"]).GetValueOrDefault() * num); ((Vector3)(ref val7))..ctor((val2.x + val3.x) / 2f, (val2.y + val3.y) / 2f, val2.z); } for (int j = 0; j < vertices.Length; j++) { vertices[j] = val6 + (vertices[j] - val7) * num2; } mesh.vertices = vertices; if (normals.Length == vertices.Length) { mesh.normals = normals; } mesh.RecalculateBounds(); } public static void Wear(Player p, int index) { if (!((Object)(object)p == (Object)null)) { p.Call_EquipHat(index); Log.Info((index < 0) ? "Hat taken off" : ("Wearing hat " + HatDatabase.instance.hats[index].displayName)); } } } [HarmonyPatch(typeof(HatShop), "Restock")] internal static class HatShopPatch { private const int Shelves = 2; private static void Postfix(HatShop __instance) { if (ModHats.Hats.Count == 0 || __instance.hatBuyInteractables.Count == 0) { return; } List<Hat> shown = __instance.hatBuyInteractables.Select((HatBuyInteractable b) => (!((Object)(object)b.hatPrefab != (Object)null)) ? null : b.hatPrefab.GetComponent<Hat>()).ToList(); Random rng = new Random(__instance.savedSeed); List<Hat> list = (from _ in ModHats.Hats where !shown.Contains(_) orderby rng.Next() select _).ToList(); int num = Mathf.Min(2, __instance.hatBuyInteractables.Count) - shown.Count((Hat h) => (Object)(object)h != (Object)null && ModHats.Hats.Contains(h)); int num2 = __instance.hatBuyInteractables.Count - 1; while (num2 >= 0 && num > 0 && list.Count > 0) { if (!((Object)(object)shown[num2] != (Object)null) || !ModHats.Hats.Contains(shown[num2])) { Hat val = list[0]; list.RemoveAt(0); int num3 = Mathf.RoundToInt((float)val.GetBasePrice() * (0.5f + 1.5f * (float)rng.NextDouble()) / 10f) * 10; __instance.hatBuyInteractables[num2].LoadHat(((Component)val).gameObject, num3); num--; } num2--; } } } public class ModHatLook : MonoBehaviour { public List<string> Keys = new List<string>(); private void Awake() { MeshRenderer component = ((Component)this).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null && Keys.Count > 0) { ((Renderer)component).sharedMaterials = Keys.Select(Plugin.Cache.GetMaterial).ToArray(); } } } public static class ModHatSave { [HarmonyPatch(typeof(MetaProgressionHandler), "OnLoadedMetaData")] internal static class LoadedPatch { private static void Postfix() { _metaLoaded = true; Sync(); } } [HarmonyPatch(typeof(MetaProgressionHandler), "UnlockHat")] internal static class UnlockPatch { private static void Postfix(int hat) { string text = ModHats.IdAt(hat); if (text != null) { Load(); if (_owned.Add(text)) { Save(); } } } } [HarmonyPatch(typeof(Player), "RPCA_EquipHat")] internal static class EquipPatch { private static void Prefix(Player __instance, int hatIndex) { if (__instance.IsLocal && ModHats.CwCount >= 0) { Load(); string text = ModHats.IdAt(hatIndex); if (!(text == _worn)) { _worn = text; Save(); } } } } [HarmonyPatch(typeof(Player), "LoadHat")] internal static class WearPatch { private static void Prefix() { if (ModHats.CwCount >= 0) { Load(); int num = PlayerPrefs.GetInt("EquippedHat", -1); if (_worn != null) { PlayerPrefs.SetInt("EquippedHat", ModHats.IndexOf(_worn)); } else if (num >= ModHats.CwCount) { PlayerPrefs.SetInt("EquippedHat", -1); } } } } private static HashSet<string> _owned; private static string _worn; private static bool _metaLoaded; private static string FilePath => Path.Combine(Application.persistentDataPath, "ContentRepo_hats.json"); private static void Load() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_owned != null) { return; } _owned = new HashSet<string>(); try { if (!File.Exists(FilePath)) { return; } JObject val = JObject.Parse(File.ReadAllText(FilePath)); foreach (JToken item in (IEnumerable<JToken>)(((object)val["owned"]) ?? ((object)new JArray()))) { _owned.Add((string)item); } _worn = (string)val["worn"]; } catch (Exception ex) { Log.Warn("Hat save: " + ex.Message); } } private static void Save() { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown try { File.WriteAllText(FilePath, ((object)new JObject { ["owned"] = (JToken)new JArray((object)_owned.OrderBy((string x) => x)), ["worn"] = JToken.op_Implicit(_worn) }).ToString()); } catch (Exception ex) { Log.Warn("Hat save: " + ex.Message); } } public static void Sync() { MetaProgressionHandler instance = RetrievableSingleton<MetaProgressionHandler>.Instance; if (!_metaLoaded || ModHats.CwCount < 0 || (Object)(object)instance == (Object)null) { return; } Load(); instance.unlockedHats.RemoveWhere((int i) => i >= ModHats.CwCount); foreach (string item in _owned) { int num = ModHats.IndexOf(item); if (num >= 0) { instance.unlockedHats.Add(num); } } } } public class Monster : MonoBehaviour { private enum SpiderGoal { None, Web, Perch, Home, Corpse } private class NestCell { public Vector3 Pos; public float WidthX; public float WidthZ; public bool Gap; public bool NarrowX; } private class Flying { public Pickup P; public float Until; public MonsterDef By; } private bool _bbInit; private bool _bbBold; private bool _bbHasCamp; private bool _bbExpect; private float _bbBorn; private Vector3 _bbCamp; private Vector3 _bbTargetPrev; private Vector3 _bbTargetVel; private Vector3 _bbLookAt; private float _bbLeader; private float _bbScoutUntil; private float _bbRestUntil; private float _bbScan; private float _bbGroupScan; private float _bbSitCheck; private float _bbFight; private float _bbFightUntil; private float _bbFocusUntil; private float _bbUnseen; private float _bbLookUntil; private float _bbLastHit; private float _bbLaughAt; private float _bbPhase; private float _bbLootScan; private Monster _bbFollow; private readonly Dictionary<object, float> _bbIgnore = new Dictionary<object, float>(); private Pickup _bbGoal; private ClipData _bbClip; private float _bbDropAt; private float _bCd; private float _bFlameCd; private float _bClawCd; private float _bTick; private float _bBack; private float _bClawTip; private int _bSwings; private bool _bFlag; private bool _bHitDone; private Target _bVictim; private Vector3 _bReel; private bool _bShown = true; private AudioSource _bWorld; private Light _bGlow; private Transform _bGlowBall; private ParticleSystem _bFlame; private Vector3 _bClawFrom; private Vector3 _bClawDir; private Vector3 _bClawLast; private float _bChatter; private float _bVoiceAt; private float _bLandAt; private float _bWait; private static readonly List<DivingBell> _bells = new List<DivingBell>(); private static float _bellsAt = -99f; private ClipData _frozenClip; private float _movedFor; private float _nextCoilHit; private float _coilBorn = -1f; private float _victimCheckUntil; private bool _coilLeaving; private Target _victim; public int NetId; public MonsterDef Def; public MonsterBody Body; public MState State; public int TargetActor = -1; private AudioSource _loop; private AudioSource _oneShot; private AudioSource _gun; private float _stateTime; private float _animPhase; private float _walkPhase; private float _nextStep; private float _nextChatter; private float _nextWail; private Vector3 _lastPos; private Vector3 _velocity; private float _yaw; private Vector3 _roamTarget; private Vector3 _lastSeen; private Vector3 _searchPoint; private Vector3 _stuckFrom; private float _roamWait; private float _lostSight; private float _giveUpAfter; private float _searchTimer; private float _stuckTimer; private float _lookBase; private bool _searching; private Vector3 _attackPoint; private Vector3 _leapFrom; private Target _target; private readonly Dictionary<object, float> _immuneUntil = new Dictionary<object, float>(); private readonly List<Vector3> _path = new List<Vector3>(); private float _repath; private bool _hitDone; private Vector3 _netPos; private float _netYaw; private static int _groundMask = -1; private static Material _tracerMat; private static readonly Dictionary<AudioClip, AudioClip> _loudClips = new Dictionary<AudioClip, AudioClip>(); private bool _thinking; private MState _lastState; private bool _netHop; private float _spawnAnimUntil; private float _airT; private float _hopY; private bool _wasHopping; private bool _shootPoint; private Vector3 _noisePoint; private Vector3 _investigatePoint; private Vector3 _investigateWander; private Vector3 _heardPos; private float _investigateUntil; private float _investigateRepick; private Vector3 _fleePoint; private float _fleeRepick; private float _ignoreUntil; private bool _enraged; private bool _leaving; private bool _despawned; private float _lastFaceLook; private float _despawnAt; private float _dazedFor; private float _nextLightScan; private readonly List<Flashlight> _lights = new List<Flashlight>(); private bool _hopAir; private float _hopTimer; private Vector3 _leashCenter; private float _leash; private float _descent; private Vector3 _tumbleDir; private float _tumbleStill; private float _nextImpactSound; private float _fallSpeed; private const float StepDown = 0.6f; private const float Gravity = 15f; private const float MaxFall = 40f; private int _groundFrame = -1; private static readonly RaycastHit[] _hits = (RaycastHit[])(object)new RaycastHit[16]; private int _dogSus; private bool _dogHeardHowl; private float _dogListen; private float _dogHeardAt; private float _dogTick; private float _dogSpeed; private float _dogLungeCd; private float _dogLunged; private float _dogNoiseDist; private float _dogPhase; private Vector3 _dogGuess; private Vector3 _dogNoise; private ClipData _dogClip; private const int DogSuspicious = 5; private const int DogAlert = 9; private const int DogMax = 11; private Vector3 _ceilGround; private Vector3 _ceilPoint; private Vector3 _climbFrom; private bool _hasCeiling; private bool _hasWall; private Vector3 _wallFoot; private Vector3 _wallBase; private Vector3 _wallTop; private float _wallYaw; private float _ceilSearch; private float _latchFor; private float _latchTick; private float _fleaDropT; private Target _latchTarget; private Vector3 _dropFrom; private readonly Dictionary<object, float> _gMeter = new Dictionary<object, float>(); private float _gSee; private float _gStare; private float _gLookUntil; private float _gLost; private float _gLostFor; private float _gBlocked; private float _gSwitched; private float _gNextLook; private float _gPhase; private float _gReach; private Vector3 _gLookAt; private Vector3 _gGoal; private Vector3 _gLastSeen; private bool _gGoalSet; private bool _gEatSound; private Target _gVictim; private ClipData _gClip; private static readonly Dictionary<Vector3Int, bool> _fits = new Dictionary<Vector3Int, bool>(); private static object _fitsLevel; private bool _hoardNestSet; private Vector3 _hoardNest; private readonly List<Pickup> _nestItems = new List<Pickup>(); private Pickup _goalPickup; private Monster _goalGnome; private Monster _goalRugrat; private Monster _gnomeHome; private float _hoardLook; private float _nestCheck; private float _angryUntil; private float _flyY; private Target _l4dVictim; private bool _l4dFlag; private bool _l4dCarry; private bool _l4dHitDone; private bool _l4dRockOut; private bool _l4dRetreat; private bool _l4dDown; private float _l4dTick; private float _l4dCd; private float _l4dAnger; private float _l4dSince; private float _l4dTip; private float _l4dChatter; private float _l4dThrowCd; private float _l4dLost; private Vector3 _l4dFrom; private Vector3 _l4dTo; private Vector3 _l4dDir; private float _l4dPoundAt; private AudioSource _l4dTheme; private int _l4dThemePhase; private readonly Dictionary<object, float> _l4dBlame = new Dictionary<object, float>(); private LineRenderer _tongue; private static Material _tongueMat; private Vector3? _perch; private float _perchUntil; private float _perchSearch; private bool _perchDone; private float _nextLightScanL4D; private readonly List<Flashlight> _witchLights = new List<Flashlight>(); private bool _nestMade; private bool _onWall; private bool _spoolCorpse; private Vector3 _nest; private Vector3 _spiderGoalPos; private Vector3 _perchBase; private Vector3 _perchTop; private float _perchYaw; private float _webCheck; private float _nextBite; private float _climb; private float _nextFootSound; private SpiderGoal _goalKind; private bool _hasPerch; private readonly List<(Vector3 pos, float yaw, float width, float height, bool door)> _webSpots = new List<(Vector3, float, float, float, bool)>(); private int _websMade; private Target _corpse; private Vector3 _corpsePos; private Quaternion _bodyRot = Quaternion.identity; private bool _bodyRotSet; private readonly Dictionary<Vector2Int, NestCell> _nestCells = new Dictionary<Vector2Int, NestCell>(); private float _spLeash; private static readonly HashSet<object> _claimed = new HashSet<object>(); private Monster _owner; private readonly List<Monster> _gnomes = new List<Monster>(); private Monster _heldGnome; private Monster _fetchGnome; private Pickup _heldPickup; private Pickup _fetchPickup; private float _lookForThrowable; private float _syncTimer; private Vector3 _flyFrom; private Vector3 _flyVel; private Monster _thrower; private float _shatterAt; private static readonly List<Flying> _flying = new List<Flying>(); private static readonly List<Pickup> _pickups = new List<Pickup>(); private static readonly Dictionary<Pickup, float> _movedAt = new Dictionary<Pickup, float>(); private static float _refreshPickups; private float _ignoreItemHitsUntil; public bool Statue; private float _thSpeed; private float _thRepath; private float _thDazeFor; private Vector3 _thCorner; private bool _thReversing; private bool _thBit; private float _thPhase; private ClipData _thClip; public Vector3 BaboonCamp => _bbCamp; public bool BaboonReady => _bbInit; public bool IsBoss => Def.Behaviour.StartsWith("secret_"); private bool IsSecond => Def.Behaviour == "secret_2"; public bool Hidden { get { if (IsBoss) { if (State != MState.Sleep) { return State == MState.Posture; } return true; } return false; } } private bool _bNetFlag => HopAir; private static int GroundMask { get { if (_groundMask == -1) { return _groundMask = LayerMask.GetMask(new string[3] { "Terrain", "Prop", "Default" }); } return _groundMask; } } private static int SightMask => LayerMask.GetMask(new string[1] { "Terrain" }); public bool HopAir { get { if (!PhotonNetwork.IsMasterClient) { return _netHop; } if (!_hopAir && !Holding && !_bbBold && !_l4dFlag) { return _bFlag; } return true; } } private Vector3 Eye => ((Component)this).transform.position + Vector3.up * Def.Height * 0.85f; private static AiDef Ai => Plugin.Cache.Ai; public float Yaw => _yaw; public bool IsL4D => Def.Behaviour.StartsWith("l4d_"); public bool L4DHolding { get { if (IsL4D) { if (State != MState.Latched && State != MState.Kill) { if (Def.Behaviour == "l4d_charger" && State == MState.Attack && TargetActor != -1) { return _l4dCarry; } return false; } return true; } return false; } } private bool L4DElevated { get { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (_target != null) { return ((Component)this).transform.position.y - _target.Ground.y >= S("perch_min", 1.5f); } return false; } } private static int WallMask => LayerMask.GetMask(new string[2] { "Terrain", "Prop" }); private bool Holding { get { if (!((Object)(object)_heldGnome != (Object)null)) { return (Object)(object)_heldPickup != (Object)null; } return true; } } private Vector3 HoldPoint { get { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) if (!((Object)(object)Body.Slot("hold") != (Object)null)) { return ((Component)this).transform.position + Vector3.up * Def.Height; } return Body.Slot("hold").position; } } public bool CanBeGrabbed { get { if (Def.Behaviour == "gnome") { if (State != MState.Roam) { return State == MState.Investigate; } return true; } return false; } } private bool GnomeStatue { get { if (Def.Behaviour == "gnome") { if (State != MState.Frozen) { if (State == MState.Carried && MonsterNet.Instance.Monsters.TryGetValue(TargetActor, out var value) && (Object)(object)value != (Object)null) { return value.Def.Behaviour == "hoarder"; } return false; } return true; } return false; } } public void BaboonExpectTroop() { _bbExpect = true; } private float S(string key, float fallback) { return Def.Stat(key, fallback); } private IEnumerable<Monster> OtherHawks() { return MonsterNet.Instance.Monsters.Values.Where((Monster m) => (Object)(object)m != (Object)null && (Object)(object)m != (Object)(object)this && m.Def.Behaviour == "baboon"); } private int HawksNearby() { return OtherHawks().Count((Monster m) => m.State != MState.Flee && Vector3.Distance(((Component)m).transform.position, ((Component)this).transform.position) < S("group_range", 20f)); } private void ThinkBaboon(float dt) { //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) if (!_bbInit) { _bbInit = true; _bbLeader = Random.value; _bbScoutUntil = Time.time + Random.Range(S("scout_min", 25f), S("scout_max", 70f)); Monster monster = OtherHawks().FirstOrDefault((Monster m) => m._bbHasCamp && Vector3.Distance(((Component)m).transform.position, ((Component)this).transform.position) < S("group_range", 20f) * 2f); if ((Object)(object)monster != (Object)null) { _bbCamp = monster._bbCamp; _bbHasCamp = true; } else if (!OtherHawks().Any() && !_bbExpect) { _bbCamp = ((Component)this).transform.position; _bbHasCamp = true; } _bbBorn = T