Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Matryoshka v1.0.0
Matriochka.dll
Decompiled 37 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Localization.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace Matriochka { internal static class Lang { internal static readonly string[] Codes = new string[21] { "en", "fr", "de", "es", "es-419", "it", "pt", "pt-BR", "ru", "uk", "pl", "tr", "ja", "ko", "zh-Hans", "zh-Hant", "ar", "da", "fi", "sv", "th" }; internal static ConfigEntry<string> Cfg; private static string code = "en"; private static float codeAt = -99f; private static float nextTick; internal static readonly Dictionary<string, string> NameTable = new Dictionary<string, string> { { "en", "Matryoshka" }, { "fr", "Matriochka" }, { "de", "Matrjoschka" }, { "es", "Matrioska" }, { "es-419", "Matrioska" }, { "it", "Matrioska" }, { "pt", "Matrioska" }, { "pt-BR", "Matrioska" }, { "ru", "Матрёшка" }, { "uk", "Матрьошка" }, { "pl", "Matrioszka" }, { "tr", "Matruşka" }, { "ja", "マトリョーシカ" }, { "ko", "마트료시카" }, { "zh-Hans", "套娃" }, { "zh-Hant", "套娃" }, { "ar", "ماتريوشكا" }, { "da", "Matrjosjka" }, { "fi", "Maatuska" }, { "sv", "Matrjosjka" }, { "th", "ต\u0e38\u0e4aกตาแม\u0e48ล\u0e39กดก" } }; internal const bool HasMessages = false; internal static string Code { get { //IL_006c: 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 (Time.unscaledTime - codeAt < 1f) { return code; } codeAt = Time.unscaledTime; string text = ((Cfg != null) ? Cfg.Value : "Auto"); if (string.IsNullOrEmpty(text) || text.Trim().Equals("Auto", StringComparison.OrdinalIgnoreCase)) { text = "en"; try { Locale selectedLocale = LocalizationSettings.SelectedLocale; if ((Object)(object)selectedLocale != (Object)null) { LocaleIdentifier identifier = selectedLocale.Identifier; text = ((LocaleIdentifier)(ref identifier)).Code; } } catch (Exception) { } } code = Normalize(text); return code; } } internal static string Name => Pick(NameTable); internal static void Bind(ConfigFile config) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown List<string> list = new List<string> { "Auto" }; list.AddRange(Codes); Cfg = config.Bind<string>("Language", "Language", "Auto", new ConfigDescription("Language of this monster's in-game texts (its name when grabbed). Auto = the game's language (English if the game's language is not one of these).", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray()), Array.Empty<object>())); } internal static void Tick() { if (Time.unscaledTime < nextTick) { return; } nextTick = Time.unscaledTime + 1f; try { string name = Name; if (Object.op_Implicit((Object)(object)Plugin.Prefab)) { EnemyParent componentInChildren = Plugin.Prefab.GetComponentInChildren<EnemyParent>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.enemyName = name; } } foreach (MatAI item in MatAI.All) { if (Object.op_Implicit((Object)(object)item)) { EnemyParent componentInParent = ((Component)item).GetComponentInParent<EnemyParent>(true); if (Object.op_Implicit((Object)(object)componentInParent) && componentInParent.enemyName != name) { componentInParent.enemyName = name; } } } } catch (Exception) { } } internal static string Normalize(string c) { c = (c ?? "en").Trim().Replace('_', '-').ToLowerInvariant(); if (c.StartsWith("zh")) { if (!c.Contains("hant") && !c.Contains("tw") && !c.Contains("hk") && !c.Contains("mo")) { return "zh-Hans"; } return "zh-Hant"; } if (c.StartsWith("es")) { if (!(c == "es") && !(c == "es-es")) { return "es-419"; } return "es"; } if (c.StartsWith("pt")) { if (!(c == "pt-br")) { return "pt"; } return "pt-BR"; } string text = ((c.Length >= 2) ? c.Substring(0, 2) : c); if (Array.IndexOf(Codes, text) < 0) { return "en"; } return text; } internal static string Pick(Dictionary<string, string> t) { if (!t.TryGetValue(Code, out var value) || string.IsNullOrEmpty(value)) { return t["en"]; } return value; } } public class MatAI : MonoBehaviour { public enum State { Spawn, Hunt, Attack, Opening, Stunned } private Enemy enemy; private PhotonView photonView; private EnemyHealth health; private EnemyRigidbody erb; private CapsuleCollider capsule; private Transform visuals; private Transform model; private Transform particles; private readonly Dictionary<string, Transform> J = new Dictionary<string, Transform>(); private readonly Dictionary<string, Vector3> restPos = new Dictionary<string, Vector3>(); private Renderer[] faces = (Renderer[])(object)new Renderer[3]; private bool ready; public State state; public int size; public bool isChild; private bool stateImpulse = true; private float stateTimer; private float stateTime; private PlayerAvatar targetPlayer; private PhysGrabObject targetItem; internal int familyId; private float attackCooldown; private float retargetTimer; private float pathTimer; private float laughTimer = 6f; private float lastGroundY; private bool hitDone; private bool fellInPit; private bool destroying; private bool baseSpawnValuable = true; private bool hasSpawned; internal bool initialDespawnSeen; private int spawnCount; private float pitGrace = 2f; private float itemChase; private PhysGrabObject ignoreItem; private float ignoreItemUntil; private float phase; private float keyAngle; private float rollAcc; private float roll; private float pitch; private float bodySpeed; private Vector3 lastPos; internal static float SkipTeleportUntil; internal static readonly List<MatAI> All = new List<MatAI>(); private static bool MP => GameManager.Multiplayer(); private static bool Master => SemiFunc.IsMasterClientOrSingleplayer(); private float H => Plugin.Heights[Mathf.Clamp(size, 0, 2)]; internal static MatAI Existing() { All.RemoveAll((MatAI a) => (Object)(object)a == (Object)null); foreach (MatAI item in All) { if (!item.isChild) { return item; } } return null; } private void Awake() { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown enemy = ((Component)this).GetComponent<Enemy>(); photonView = ((Component)this).GetComponent<PhotonView>(); health = ((Component)this).GetComponent<EnemyHealth>(); Transform parent = ((Component)this).transform.parent; erb = ((Component)parent.Find("Rigidbody")).GetComponent<EnemyRigidbody>(); Transform val = ((Component)erb).transform.Find("Collider"); capsule = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CapsuleCollider>() : null); visuals = parent.Find("Visuals"); model = (Object.op_Implicit((Object)(object)visuals) ? visuals.Find("MatModel") : null); particles = parent.parent.Find("Particles"); if (Object.op_Implicit((Object)(object)model)) { Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (Array.IndexOf(ModelLayout.Parts, ((Object)val2).name) >= 0) { J[((Object)val2).name] = val2; restPos[((Object)val2).name] = val2.localPosition; } } } for (int j = 0; j < 3; j++) { if (J.TryGetValue("face" + j, out var value)) { faces[j] = ((Component)value).GetComponent<Renderer>(); } } MatImpact component = ((Component)erb).GetComponent<MatImpact>(); if (Object.op_Implicit((Object)(object)component)) { component.ai = this; } EnemyStateSpawn component2 = ((Component)this).GetComponent<EnemyStateSpawn>(); if (Object.op_Implicit((Object)(object)component2)) { component2.OnSpawn.AddListener(new UnityAction(OnSpawn)); } if (Object.op_Implicit((Object)(object)health)) { health.onHurt.AddListener(new UnityAction(OnHurt)); health.onDeath.AddListener(new UnityAction(OnDeath)); } ready = Object.op_Implicit((Object)(object)model) && Object.op_Implicit((Object)(object)erb) && Object.op_Implicit((Object)(object)capsule) && J.ContainsKey("top") && J.ContainsKey("key") && Object.op_Implicit((Object)(object)faces[2]); if (!ready) { Plugin.Log.LogError((object)"MatAI: hierarchy incomplete, behaviour disabled."); } familyId = (Object.op_Implicit((Object)(object)photonView) ? (photonView.ViewID * 100) : ((Object)this).GetInstanceID()); if (Object.op_Implicit((Object)(object)health)) { baseSpawnValuable = health.spawnValuable; } All.Add(this); ApplySize(0); } private void OnDestroy() { All.Remove(this); if (isChild && Object.op_Implicit((Object)(object)EnemyDirector.instance) && Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.EnemyParent)) { EnemyDirector.instance.enemiesSpawned.Remove(enemy.EnemyParent); } } private void OnEnable() { //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_002f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)erb)) { lastPos = ((Component)erb).transform.position; lastGroundY = ((Component)erb).transform.position.y; } } private void OnDisable() { if (!hasSpawned) { initialDespawnSeen = true; } else if (Master && isChild && !destroying && Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.EnemyParent)) { destroying = true; Util.DestroyLater(((Component)enemy.EnemyParent).gameObject, 0.2f); } } private void ApplySize(int s) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) size = Mathf.Clamp(s, 0, 2); float h = H; if (Object.op_Implicit((Object)(object)model)) { model.localScale = Vector3.one * h; } if (Object.op_Implicit((Object)(object)capsule)) { capsule.direction = 1; capsule.radius = 0.26f * h; capsule.height = h; capsule.center = new Vector3(0f, -0.5f + h * 0.5f, 0f); } if (Object.op_Implicit((Object)(object)erb) && Object.op_Implicit((Object)(object)erb.rb)) { erb.rb.centerOfMass = new Vector3(0f, -0.5f + h * 0.32f, 0f); } for (int i = 0; i < 3; i++) { if (Object.op_Implicit((Object)(object)faces[i])) { faces[i].enabled = i == size; } } if (Master && Object.op_Implicit((Object)(object)health)) { health.health = Plugin.CfgHealth[size].Value; health.healthCurrent = health.health; } } private void Update() { if (ready && Master) { MasterLogic(Time.deltaTime); } } private void LateUpdate() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (ready) { visuals.position = ((Component)erb).transform.position; visuals.rotation = Quaternion.Euler(0f, ((Component)erb).transform.eulerAngles.y, 0f); Animate(Time.deltaTime); } } private void FixedUpdate() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (ready && Master && Object.op_Implicit((Object)(object)erb.rb) && !erb.rb.isKinematic && !enemy.IsStunned()) { Rigidbody rb = erb.rb; Vector3 val = Vector3.Cross(((Component)rb).transform.up, Vector3.up); Vector3 angularVelocity = rb.angularVelocity; rb.AddTorque(val * 50f - new Vector3(angularVelocity.x, 0f, angularVelocity.z) * 8f, (ForceMode)5); } } private void MasterLogic(float dt) { //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) stateTime += dt; if (attackCooldown > 0f) { attackCooldown -= dt; } if (enemy.IsStunned() && state != State.Stunned && state != State.Opening) { SetState(State.Stunned); } PitCheck(); Face(dt); Vector3 val; switch (state) { case State.Spawn: if (stateImpulse) { stateImpulse = false; stateTimer = 1f; } Halt(); if ((stateTimer -= dt) <= 0f) { SetState(State.Hunt); } break; case State.Hunt: if (stateImpulse) { stateImpulse = false; retargetTimer = 0f; } if ((retargetTimer -= dt) <= 0f) { retargetTimer = 0.5f; PickTarget(); } if ((laughTimer -= dt) <= 0f) { laughTimer = Random.Range(7f, 14f); Rpc("MatLaughRPC"); } if (Object.op_Implicit((Object)(object)targetItem) && (itemChase += dt) > 6f) { ignoreItem = targetItem; ignoreItemUntil = Time.time + 15f; targetItem = null; itemChase = 0f; retargetTimer = 0f; } if (Object.op_Implicit((Object)(object)targetItem)) { GoTo(targetItem.midPoint, dt); if (Vector3.Distance(targetItem.midPoint, ((Component)erb).transform.position + Vector3.down * (0.5f - H * 0.5f)) < 0.45f + 0.26f * H + 0.25f && attackCooldown <= 0f) { Bite(targetItem); } } else if (ValidPlayer(targetPlayer)) { GoTo(((Component)targetPlayer).transform.position, dt); val = Flat(((Component)targetPlayer).transform.position - ((Component)erb).transform.position); if (((Vector3)(ref val)).magnitude < 0.35f + 0.26f * H + 0.35f && attackCooldown <= 0f) { SetState(State.Attack); } } else { Halt(); } break; case State.Attack: if (stateImpulse) { stateImpulse = false; stateTimer = 0.5f; hitDone = false; if (Object.op_Implicit((Object)(object)erb.rb) && ValidPlayer(targetPlayer)) { Rigidbody rb = erb.rb; val = Flat(((Component)targetPlayer).transform.position - ((Component)erb).transform.position); rb.AddForce(((Vector3)(ref val)).normalized * (2.5f + (float)size), (ForceMode)2); } } stateTimer -= dt; if (!hitDone && stateTimer <= 0.3f) { hitDone = true; HitPlayer(); } if (stateTimer <= 0f) { attackCooldown = ((size == 0) ? 1.6f : ((size == 1) ? 1.1f : 0.7f)); SetState(State.Hunt); } break; case State.Opening: if (stateImpulse) { stateImpulse = false; stateTimer = Plugin.CfgOpenTime.Value; Rpc("MatLaughRPC"); } Halt(); if ((stateTimer -= dt) <= 0f) { Split(); } break; case State.Stunned: if (stateImpulse) { stateImpulse = false; } if (!enemy.IsStunned()) { SetState(State.Hunt); } break; } } private void GoTo(Vector3 p, float dt) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((pathTimer -= dt) <= 0f) { pathTimer = 0.3f; enemy.NavMeshAgent.SetDestination(p); } float value = Plugin.CfgSpeed[size].Value; enemy.NavMeshAgent.OverrideAgent(value, value * 4f, 0.4f); } private void Halt() { enemy.NavMeshAgent.Stop(0.2f); } private void Face(float dt) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (state == State.Stunned || state == State.Opening || state == State.Spawn) { return; } Vector3 val = Vector3.zero; if (state == State.Attack && ValidPlayer(targetPlayer)) { val = ((Component)targetPlayer).transform.position - ((Component)erb).transform.position; } else { Vector3 agentVelocity = enemy.NavMeshAgent.AgentVelocity; if (((Vector3)(ref agentVelocity)).sqrMagnitude > 0.04f) { val = agentVelocity; } } val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up), 1f - Mathf.Exp(-6f * dt)); } } private void PickTarget() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) Vector3 position = ((Component)erb).transform.position; targetItem = null; if (size == 2 && Object.op_Implicit((Object)(object)ValuableDirector.instance) && ValuableDirector.instance.valuableList != null) { float num = Plugin.CfgItemRange.Value; foreach (ValuableObject valuable in ValuableDirector.instance.valuableList) { if (Object.op_Implicit((Object)(object)valuable) && ((Component)valuable).gameObject.activeInHierarchy && Object.op_Implicit((Object)(object)valuable.physGrabObject)) { float num2 = Vector3.Distance(valuable.physGrabObject.midPoint, position); if ((!((Object)(object)valuable.physGrabObject == (Object)(object)ignoreItem) || !(Time.time < ignoreItemUntil)) && num2 < num) { num = num2; targetItem = valuable.physGrabObject; } } } } PlayerAvatar val = null; float num3 = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (ValidPlayer(item)) { float num4 = Vector3.Distance(((Component)item).transform.position, position); if (num4 < num3) { num3 = num4; val = item; } } } if ((Object)(object)val != (Object)(object)targetPlayer) { targetPlayer = val; SyncState(); } } private void HitPlayer() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0037: 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_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_00a8: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0106: 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) PlayerAvatar val = targetPlayer; if (!ValidPlayer(val)) { return; } Vector3 v = ((Component)val).transform.position - ((Component)erb).transform.position; Vector3 val2 = Flat(v); if (!(((Vector3)(ref val2)).magnitude > 0.35f + 0.26f * H + 0.8f)) { int value = Plugin.CfgDamage[size].Value; if (value > 0) { val.playerHealth.HurtOther(value, ((Component)val).transform.position + Vector3.up, false, SemiFunc.EnemyGetIndex(enemy), false); } val2 = Flat(v); val.ForceImpulse(((Vector3)(ref val2)).normalized * (2f + 2f * (float)(2 - size)) + Vector3.up * 1.5f); if (MP) { photonView.RPC("MatBonkRPC", (RpcTarget)0, new object[2] { ((Component)val).transform.position + Vector3.up * 0.8f, 1f + 0.35f * (float)size }); } else { MatBonkRPC(((Component)val).transform.position + Vector3.up * 0.8f, 1f + 0.35f * (float)size); } } } private void Bite(PhysGrabObject item) { //IL_003c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b1: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) attackCooldown = 0.7f; itemChase = 0f; PhysGrabObjectImpactDetector val = (Object.op_Implicit((Object)(object)item.impactDetector) ? item.impactDetector : ((Component)item).GetComponent<PhysGrabObjectImpactDetector>()); if (Object.op_Implicit((Object)(object)val)) { val.BreakLight(item.midPoint, true); } if (Object.op_Implicit((Object)(object)item.rb)) { item.rb.AddForce((Random.insideUnitSphere + Vector3.up) * 1.2f, (ForceMode)2); } if (Object.op_Implicit((Object)(object)erb.rb)) { Rigidbody rb = erb.rb; Vector3 val2 = Flat(item.midPoint - ((Component)erb).transform.position); rb.AddForce(((Vector3)(ref val2)).normalized * 2f, (ForceMode)2); } if (MP) { photonView.RPC("MatBonkRPC", (RpcTarget)0, new object[2] { item.midPoint, 1.9f }); } else { MatBonkRPC(item.midPoint, 1.9f); } } internal void BeforeHurt(int damage) { if (Object.op_Implicit((Object)(object)health) && !health.dead && health.healthCurrent - damage <= 0) { health.spawnValuable = !fellInPit && FamilyAlive() <= 1; } } internal void AfterHurt() { if (Object.op_Implicit((Object)(object)health) && !health.dead && health.healthCurrent > 0 && size < 2 && state != State.Opening && (float)health.healthCurrent < (float)Plugin.CfgHealth[size].Value * Plugin.CfgSplitAt.Value) { SetState(State.Opening); } } private int FamilyAlive() { int num = 0; All.RemoveAll((MatAI a) => (Object)(object)a == (Object)null); foreach (MatAI item in All) { if (item.familyId == familyId && ((Behaviour)item).isActiveAndEnabled && Object.op_Implicit((Object)(object)item.health) && !item.health.dead) { num++; } } return num; } private void Split() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00f7: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_0239: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) if (health.dead) { return; } int num = size; int num2 = size + 1; Vector3 position = ((Component)erb).transform.position; Vector3 val = Flat(((Component)erb).transform.right); Vector3 normalized = ((Vector3)(ref val)).normalized; ApplySize(num2); if (MP) { photonView.RPC("MatSizeRPC", (RpcTarget)1, new object[4] { num2, isChild, true, num }); } Shells(num, position, ((Component)erb).transform.eulerAngles.y); Plugin.Log.LogInfo((object)$"[Matriochka] Split: size {num} -> 2 x size {num2}"); float num3 = Plugin.Heights[num]; Vector3 val2 = position + Vector3.down * 0.5f; Vector3 val3 = val2 + normalized * (0.3f * num3 + 0.3f); NavMeshHit val4 = default(NavMeshHit); val3 = ((!NavMesh.SamplePosition(val3, ref val4, 1.5f, -1)) ? val2 : ((NavMeshHit)(ref val4)).position); try { SkipTeleportUntil = Time.time + 5f; List<EnemyParent> list = Enemies.SpawnEnemy(Plugin.Setup, val3, ((Component)this).transform.rotation, false); if (list != null) { foreach (EnemyParent item in list) { MatAI matAI = (Object.op_Implicit((Object)(object)item) ? ((Component)item).GetComponentInChildren<MatAI>(true) : null); if (Object.op_Implicit((Object)(object)matAI)) { matAI.InitAsChild(num2, familyId); ((MonoBehaviour)Plugin.Instance).StartCoroutine(ChildAppear(item, matAI, val3)); } } } } catch (Exception ex) { Plugin.Log.LogError((object)("[Matriochka] Child spawn failed: " + ex)); } if (Object.op_Implicit((Object)(object)erb.rb)) { erb.rb.AddForce(-normalized * 2.5f + Vector3.up * 1.5f, (ForceMode)2); } SetState(State.Hunt); } private static IEnumerator ChildAppear(EnemyParent ep, MatAI child, Vector3 pos) { //IL_0015: 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) float t0 = Time.time; while (Object.op_Implicit((Object)(object)ep) && Object.op_Implicit((Object)(object)child) && !child.initialDespawnSeen && Time.time - t0 < 5f) { yield return null; } yield return null; if (Object.op_Implicit((Object)(object)ep) && Object.op_Implicit((Object)(object)child)) { if (!ep.Spawned) { SkipTeleportUntil = Time.time + 5f; ep.Spawn(); } if (Object.op_Implicit((Object)(object)child.enemy)) { child.enemy.EnemyTeleported(pos); } child.pitGrace = 2f; } } internal void InitAsChild(int s, int family) { isChild = true; familyId = family; if (Object.op_Implicit((Object)(object)health)) { health.spawnValuable = false; } ApplySize(s); if (MP) { photonView.RPC("MatSizeRPC", (RpcTarget)1, new object[4] { s, true, false, s }); } } [PunRPC] private void MatSizeRPC(int s, bool child, bool shells, int old, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { isChild = child; ApplySize(s); if (shells && Object.op_Implicit((Object)(object)erb)) { Shells(old, ((Component)erb).transform.position, ((Component)erb).transform.eulerAngles.y); } } } private void Shells(int oldSize, Vector3 bodyPos, float yaw) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006c: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00cb: 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_00d6: 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_00e8: 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) Sounds.Play(Sounds.Pop, bodyPos, 1f, 1f + 0.2f * (float)oldSize); if (!((Object)(object)PrefabBuilder.TopMesh == (Object)null)) { float num = Plugin.Heights[Mathf.Clamp(oldSize, 0, 2)]; Vector3 val = bodyPos + Vector3.down * 0.5f; Quaternion val2 = Quaternion.Euler(0f, yaw, 0f); MatShell.Create(PrefabBuilder.BottomMesh, PrefabBuilder.BottomMats, val, val2, num, Vector3.zero, Vector3.zero); Vector3 vel = val2 * new Vector3(Random.Range(-0.6f, 0.6f), 0f, -1f) * 1.4f + Vector3.up * 3.2f; MatShell.Create(PrefabBuilder.TopMesh, PrefabBuilder.TopMats, val + Vector3.up * 0.52f * num, val2, num, vel, new Vector3(-260f, Random.Range(-90f, 90f), 0f)); } } internal void HeavyHit(PhysGrabObject by, float speed) { //IL_009f: 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_00bc: Unknown result type (might be due to invalid IL or missing references) if (Master && Object.op_Implicit((Object)(object)health) && !health.dead) { int num = Mathf.RoundToInt(by.rb.mass * speed * Plugin.CfgImpactFactor.Value); if (num > 0) { Plugin.Log.LogInfo((object)$"[Matriochka] Heavy impact: {((Object)by).name} {by.rb.mass:0.0} kg at {speed:0.0} m/s -> {num} damage"); EnemyHealth obj = health; Vector3 val = Flat(((Component)erb).transform.position - ((Component)by).transform.position); obj.Hurt(num, ((Vector3)(ref val)).normalized); } } } private void PitCheck() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) if (!Object.op_Implicit((Object)(object)erb.rb) || fellInPit) { return; } if (pitGrace > 0f) { pitGrace -= Time.deltaTime; lastGroundY = ((Component)erb).transform.position.y; return; } bool num = !enemy.HasGrounded || !Object.op_Implicit((Object)(object)enemy.Grounded) || enemy.Grounded.grounded; float y = ((Component)erb).transform.position.y; if (num || erb.physGrabObject.playerGrabbing.Count > 0) { lastGroundY = y; } else if (y < lastGroundY - Plugin.CfgPitFall.Value && erb.rb.velocity.y < -4f) { fellInPit = true; Plugin.Log.LogInfo((object)"[Matriochka] Fell into a pit: destroyed whole."); health.spawnValuable = false; health.Hurt(99999, Vector3.down); } } private void SetState(State s) { if (s != state) { ApplyState(s); SyncState(); } } private void SyncState() { if (MP) { photonView.RPC("MatStateRPC", (RpcTarget)1, new object[2] { (int)state, Object.op_Implicit((Object)(object)targetPlayer) ? targetPlayer.photonView.ViewID : (-1) }); } } [PunRPC] private void MatStateRPC(int s, int playerID, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } targetPlayer = null; if (playerID >= 0) { PhotonView val = PhotonView.Find(playerID); if (Object.op_Implicit((Object)(object)val)) { targetPlayer = ((Component)val).GetComponent<PlayerAvatar>(); } } if (s != (int)state) { ApplyState((State)s); } } private void ApplyState(State s) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00b6: Unknown result type (might be due to invalid IL or missing references) State state = this.state; this.state = s; stateImpulse = true; stateTimer = 0f; stateTime = 0f; if (Master && s != State.Hunt && s != State.Attack) { Plugin.Log.LogInfo((object)$"[Matriochka] (size {size}) {state} -> {s}"); } Vector3 pos = (Object.op_Implicit((Object)(object)erb) ? ((Component)erb).transform.position : ((Component)this).transform.position); if (s == State.Stunned) { Sounds.Play(Sounds.Stun, pos, 0.8f); } if (state == State.Stunned && s == State.Hunt) { Sounds.Play(Sounds.StunOutro, pos, 0.7f); } } private void Rpc(string name) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (MP) { photonView.RPC(name, (RpcTarget)0, Array.Empty<object>()); } else if (name == "MatLaughRPC") { MatLaughRPC(); } } [PunRPC] private void MatLaughRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { Sounds.Play((size == 2) ? Sounds.LaughSmall : Sounds.Laugh, ((Component)erb).transform.position, 1f, (size == 1) ? 1.15f : 1f); } } [PunRPC] private void MatBonkRPC(Vector3 pos, float pitch, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info)) { Sounds.Play(Sounds.Bonk, pos, 0.9f, pitch); } } private void OnSpawn() { //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_002f: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)erb)) { lastPos = ((Component)erb).transform.position; lastGroundY = ((Component)erb).transform.position.y; } hasSpawned = true; pitGrace = 2f; if (!Master) { return; } fellInPit = false; if (!isChild) { familyId = photonView.ViewID * 100 + ++spawnCount % 100; if (Object.op_Implicit((Object)(object)health)) { health.spawnValuable = baseSpawnValuable; } ApplySize(0); if (MP) { photonView.RPC("MatSizeRPC", (RpcTarget)1, new object[4] { 0, false, false, 0 }); } } bool flag = Time.time < SkipTeleportUntil; if (flag) { SkipTeleportUntil = 0f; } if (!flag && Plugin.TryQuietPoint(Vector3.zero, 0f, 999f, out var pos)) { enemy.EnemyTeleported(pos); flag = true; } if (!flag) { flag = SemiFunc.EnemySpawn(enemy); } if (flag) { if (!isChild) { Plugin.Log.LogInfo((object)("[Matriochka] Spawned at " + ((object)((Component)erb).transform.position/*cast due to .constrained prefix*/).ToString())); } targetPlayer = null; targetItem = null; if (state == State.Spawn) { stateImpulse = true; stateTimer = 0f; stateTime = 0f; } else { SetState(State.Spawn); } } } internal void DebugBring(Vector3 pos) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) EnemyParent enemyParent = enemy.EnemyParent; if (Object.op_Implicit((Object)(object)enemyParent) && !enemyParent.Spawned) { SkipTeleportUntil = Time.time + 5f; enemyParent.Spawn(); } enemy.EnemyTeleported(pos); pitGrace = 2f; SetState(State.Spawn); } private void OnHurt() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Sounds.Play(Sounds.Hurt, ((Component)erb).transform.position, 0.6f, 1.2f + 0.2f * (float)size); } private void OnDeath() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)erb).transform.position; Sounds.Play(Sounds.Death, position, 0.9f, 1f + 0.25f * (float)size); Sounds.Play(Sounds.DeathSpark, position, 0.7f); Shells(size, position, ((Component)erb).transform.eulerAngles.y); if (Object.op_Implicit((Object)(object)particles)) { particles.position = position; ParticleSystem[] componentsInChildren = ((Component)particles).GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Play(true); } } if (Master) { if (isChild) { destroying = true; Util.DestroyLater(((Component)enemy.EnemyParent).gameObject, 1f); } else { enemy.EnemyParent.Despawn(); } } } private static Vector3 Flat(Vector3 v) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) v.y = 0f; return v; } private static bool ValidPlayer(PlayerAvatar p) { if ((Object)(object)p != (Object)null && !p.isDisabled) { return !p.deadSet; } return false; } private static float Damp(float c, float t, float s, float dt) { return Mathf.Lerp(c, t, 1f - Mathf.Exp((0f - s) * dt)); } private void Animate(float dt) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (!(dt <= 0f)) { if (!Master) { stateTime += dt; } Vector3 position = ((Component)erb).transform.position; Vector3 val = Flat(position - lastPos); float num = ((Vector3)(ref val)).magnitude; lastPos = position; if (num / dt > 15f) { num = 0f; } bodySpeed = Damp(bodySpeed, num / dt, 8f, dt); float h = H; float num2 = Mathf.Clamp01(bodySpeed / (Plugin.CfgSpeed[size].Value * 0.6f + 0.1f)); phase += num / (0.45f * h) * (float)Math.PI; keyAngle += num / h * 300f + dt * 40f; rollAcc += num; if (rollAcc > 0.45f * h && state != State.Stunned) { rollAcc = 0f; Sounds.Play(Sounds.Roll, position, 0.25f + 0.1f * (float)(2 - size), 1f + 0.3f * (float)size); } float t = 13f * num2 * Mathf.Sin(phase); float t2 = 6f * num2; float num3 = 0f; float num4 = 0f; float num5 = 0f; float num6 = 0.03f * h * num2 * Mathf.Abs(Mathf.Sin(phase)); switch (state) { case State.Attack: { float num8 = Mathf.Sin((float)Math.PI * Mathf.Clamp01(stateTime / 0.5f)); t2 = 30f * num8; break; } case State.Opening: { float num7 = Mathf.Clamp01(stateTime / Mathf.Max(0.1f, Plugin.CfgOpenTime.Value)); t = 5f * Mathf.Sin(stateTime * 55f); t2 = 3f * Mathf.Sin(stateTime * 47f); num4 = 0.06f * num7; num5 = -18f * num7; break; } case State.Stunned: t = 9f * Mathf.Sin(stateTime * 9f); t2 = 6f * Mathf.Sin(stateTime * 7f); break; case State.Spawn: t = 8f * Mathf.Sin(stateTime * 12f) * (1f - Mathf.Clamp01(stateTime)); break; } roll = Damp(roll, t, 14f, dt); pitch = Damp(pitch, t2, 14f, dt); model.localRotation = Quaternion.Euler(pitch, 0f, roll); model.localPosition = new Vector3(0f, -0.5f + num6 + num3, 0f); Transform obj = J["top"]; obj.localPosition = restPos["top"] + new Vector3(0f, num4, 0f); obj.localRotation = Quaternion.Euler(num5, 0f, 0f); J["key"].localRotation = Quaternion.Euler(0f, 0f, keyAngle); } } } public class MatImpact : MonoBehaviour { internal MatAI ai; private float cooldown; private void Update() { if (cooldown > 0f) { cooldown -= Time.deltaTime; } } private void OnCollisionEnter(Collision c) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ai) || cooldown > 0f || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } Rigidbody rigidbody = c.rigidbody; if ((Object)(object)rigidbody == (Object)null || rigidbody.isKinematic || Object.op_Implicit((Object)(object)((Component)rigidbody).GetComponent<PlayerAvatar>()) || Object.op_Implicit((Object)(object)((Component)rigidbody).GetComponent<EnemyRigidbody>())) { return; } PhysGrabObject component = ((Component)rigidbody).GetComponent<PhysGrabObject>(); if (!((Object)(object)component == (Object)null)) { Vector3 relativeVelocity = c.relativeVelocity; float magnitude = ((Vector3)(ref relativeVelocity)).magnitude; if (rigidbody.mass >= Plugin.CfgImpactMass.Value && magnitude >= Plugin.CfgImpactSpeed.Value) { cooldown = 0.3f; ai.HeavyHit(component, magnitude); } } } } public class MatShell : MonoBehaviour { private Vector3 vel; private Vector3 spin; private float t; private float floorY; private float scale; private bool resting; internal static void Create(Mesh mesh, int[] matIds, Vector3 pos, Quaternion rot, float scale, Vector3 vel, Vector3 spin) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_009a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Matriochka Shell"); val.transform.SetPositionAndRotation(pos, rot); val.transform.localScale = Vector3.one * scale; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); Material[] array = (Material[])(object)new Material[matIds.Length]; for (int i = 0; i < array.Length; i++) { array[i] = PrefabBuilder.Materials[Mathf.Clamp(matIds[i], 0, PrefabBuilder.Materials.Length - 1)]; } ((Renderer)val2).sharedMaterials = array; MatShell matShell = val.AddComponent<MatShell>(); matShell.vel = vel; matShell.spin = spin; matShell.scale = scale; matShell.floorY = pos.y - ((vel == Vector3.zero) ? 0f : (0.52f * scale)); matShell.resting = vel == Vector3.zero; } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; t += deltaTime; if (!resting) { vel += Physics.gravity * deltaTime; Transform transform = ((Component)this).transform; transform.position += vel * deltaTime; ((Component)this).transform.rotation = Quaternion.Euler(spin * deltaTime) * ((Component)this).transform.rotation; if (((Component)this).transform.position.y <= floorY + 0.05f * scale && vel.y < 0f) { ((Component)this).transform.position = new Vector3(((Component)this).transform.position.x, floorY + 0.05f * scale, ((Component)this).transform.position.z); resting = true; ((Component)this).transform.rotation = Quaternion.Euler(Random.Range(80f, 100f), ((Component)this).transform.eulerAngles.y, 0f); } } if (t > 6f) { float num = 1f - Mathf.Clamp01((t - 6f) / 2f); ((Component)this).transform.localScale = Vector3.one * scale * num; if (num <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } } internal static class ModelLayout { public static readonly string[] Parts = new string[6] { "bottom", "top", "face0", "face1", "face2", "key" }; public static readonly string[] Parents = new string[6] { "", "bottom", "top", "top", "top", "bottom" }; public static readonly Vector3[] Pivots = (Vector3[])(object)new Vector3[6] { new Vector3(0f, 0f, 0f), new Vector3(0f, 0.52f, 0f), new Vector3(0f, 0.785f, 0f), new Vector3(0f, 0.785f, 0f), new Vector3(0f, 0.785f, 0f), new Vector3(0f, 0.4f, -0.25016f) }; public const float Split = 0.52f; public const float RadiusMax = 0.268f; } internal static class Sounds { public static Sound Laugh; public static Sound LaughSmall; public static Sound Roll; public static Sound Pop; public static Sound Bonk; public static Sound Hurt; public static Sound Death; public static Sound DeathSpark; public static Sound Stun; public static Sound StunOutro; public static Sound Break; public static void Play(Sound s, Vector3 pos, float volume = 1f, float pitch = 1f) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (s == null || s.Sounds == null || s.Sounds.Length == 0) { return; } float pitch2 = s.Pitch; try { s.Pitch = pitch2 * pitch; s.Play(pos, volume, 1f, 1f, 1f); } catch (Exception ex) { Plugin.Log.LogDebug((object)("Sound play failed: " + ex.Message)); } finally { s.Pitch = pitch2; } } internal static Sound Make(string name, AudioType type, float volume, float spatial, float pitchRandom, params string[] wavs) { //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_0075: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00eb: Expected O, but got Unknown List<AudioClip> list = new List<AudioClip>(); foreach (string text in wavs) { try { list.Add(Wav.Load("Matriochka." + text, name + " " + text)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Sound " + text + ": " + ex.Message)); } } return new Sound { Sounds = list.ToArray(), Type = type, Volume = volume, VolumeRandom = 0.05f, Pitch = 1f, PitchRandom = pitchRandom, SpatialBlend = spatial, Doppler = 0f, ReverbMix = 1f, FalloffMultiplier = 1f, OffscreenVolume = 1f, OffscreenFalloff = 1f, LowPassIgnoreColliders = new List<Collider>() }; } } internal static class Wav { public static AudioClip Load(string resource, string clipName) { byte[] array = Resource.Embedded(resource); int num = BitConverter.ToInt16(array, 22); int num2 = BitConverter.ToInt32(array, 24); if (BitConverter.ToInt16(array, 34) != 16) { throw new Exception("only 16-bit PCM"); } int i = 12; int num3 = -1; int num4 = 0; int num5; for (; i + 8 <= array.Length; i += 8 + num5 + (num5 & 1)) { string text = Encoding.ASCII.GetString(array, i, 4); num5 = BitConverter.ToInt32(array, i + 4); if (text == "data") { num3 = i + 8; num4 = num5; break; } } if (num3 < 0) { throw new Exception("no data chunk"); } int num6 = num4 / 2; float[] array2 = new float[num6]; for (int j = 0; j < num6; j++) { array2[j] = (float)BitConverter.ToInt16(array, num3 + j * 2) / 32768f; } AudioClip obj = AudioClip.Create(clipName, num6 / num, num, num2, false); obj.SetData(array2, 0); ((Object)obj).hideFlags = (HideFlags)32; return obj; } } [BepInPlugin("maxime.repo.matriochka", "Matriochka", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "maxime.repo.matriochka"; public const string NAME = "Matriochka"; public const string VERSION = "1.0.0"; internal static Plugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<int> CfgPoolWeight; internal static ConfigEntry<int> CfgSpawnChance; internal static ConfigEntry<int> CfgDifficulty; internal static ConfigEntry<int>[] CfgHealth = new ConfigEntry<int>[3]; internal static ConfigEntry<int>[] CfgDamage = new ConfigEntry<int>[3]; internal static ConfigEntry<float>[] CfgSpeed = new ConfigEntry<float>[3]; internal static ConfigEntry<float> CfgSplitAt; internal static ConfigEntry<float> CfgOpenTime; internal static ConfigEntry<float> CfgImpactMass; internal static ConfigEntry<float> CfgImpactSpeed; internal static ConfigEntry<float> CfgImpactFactor; internal static ConfigEntry<float> CfgPitFall; internal static ConfigEntry<float> CfgItemRange; internal static ConfigEntry<bool> CfgDebugSpawn; internal static ConfigEntry<KeyCode> CfgDebugSpawnKey; internal static readonly float[] Heights = new float[3] { 1.6f, 1f, 0.55f }; internal const float MinPlayerDistance = 15f; internal static EnemySetup Setup; internal static GameObject Prefab; private static GameObject holder; private Harmony harmony; private float lastDebugSpawn = -10f; private LevelGenerator handledLevel; private float levelReadyTime = -1f; private float nextSpawnTry; private bool rolled; internal static GameObject Holder { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)holder == (Object)null) { holder = new GameObject("MatriochkaPrefabHolder"); holder.SetActive(false); ((Object)holder).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)holder); } return holder; } } private void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; BindConfig(); harmony = new Harmony("maxime.repo.matriochka"); harmony.PatchAll(typeof(Plugin).Assembly); try { Prefab = PrefabBuilder.Build(); Register(); Log.LogInfo((object)"Matriochka v1.0.0 loaded: enemy prefab built and registered with REPOLib."); } catch (Exception ex) { Log.LogError((object)("Failed to build/register the Matriochka: " + ex)); } } private void BindConfig() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown CfgSpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "BonusChance", 0, new ConfigDescription("Optional extra copy ON TOP of the level's monsters: chance (%) per level, only if the normal draw did not pick it. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); CfgPoolWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "PoolWeight", 100, new ConfigDescription("Weight in the game's normal monster draw: it takes the place of a vanilla pick, never adds one. 100 = as likely as a standard vanilla monster, 0 = never drawn. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 300), Array.Empty<object>())); CfgDifficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "DifficultyTier", 2, new ConfigDescription("Enemy tier (1-3): size of the orb it drops. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>())); string[] array = new string[3] { "Large", "Medium", "Small" }; int[] array2 = new int[3] { 300, 100, 30 }; int[] array3 = new int[3] { 25, 15, 5 }; float[] array4 = new float[3] { 1.5f, 3f, 5f }; for (int i = 0; i < 3; i++) { CfgHealth[i] = ((BaseUnityPlugin)this).Config.Bind<int>("Sizes", array[i] + "Health", array2[i], new ConfigDescription(array[i] + " doll hit points.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 3000), Array.Empty<object>())); CfgSpeed[i] = ((BaseUnityPlugin)this).Config.Bind<float>("Sizes", array[i] + "Speed", array4[i], new ConfigDescription(array[i] + " doll speed (m/s).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>())); CfgDamage[i] = ((BaseUnityPlugin)this).Config.Bind<int>("Sizes", array[i] + "Damage", array3[i], new ConfigDescription(array[i] + " doll damage per hit.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); } CfgSplitAt = ((BaseUnityPlugin)this).Config.Bind<float>("Division", "SplitBelow", 0.5f, new ConfigDescription("Splits into two smaller dolls when health drops below this fraction (large -> 2 medium -> 4 small).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.95f), Array.Empty<object>())); CfgOpenTime = ((BaseUnityPlugin)this).Config.Bind<float>("Division", "OpeningTime", 0.8f, new ConfigDescription("Seconds it spends opening before splitting: kill it during that window and it does not split.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); CfgItemRange = ((BaseUnityPlugin)this).Config.Bind<float>("Division", "SmallItemRange", 15f, new ConfigDescription("Small dolls go for valuables within this range first (each hit breaks a little of the item).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); CfgImpactMass = ((BaseUnityPlugin)this).Config.Bind<float>("Counterplay", "HeavyImpactMinMass", 3f, new ConfigDescription("Objects at least this heavy (kg)...", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 30f), Array.Empty<object>())); CfgImpactSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Counterplay", "HeavyImpactMinSpeed", 5f, new ConfigDescription("...hitting it at least this fast (m/s) deal mass x speed x factor damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>())); CfgImpactFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Counterplay", "HeavyImpactFactor", 4f, new ConfigDescription("Damage factor of heavy impacts (8 kg at 10 m/s with factor 4 = 320: a one-shot on the large doll).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); CfgPitFall = ((BaseUnityPlugin)this).Config.Bind<float>("Counterplay", "PitFallDistance", 6f, new ConfigDescription("A doll falling more than this (m) is destroyed whole, without splitting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 100f), Array.Empty<object>())); Lang.Bind(((BaseUnityPlugin)this).Config); CfgDebugSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableSpawnKey", false, "Host only: the key brings the Matriochka 4 m in front of you (or spawns it)."); CfgDebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)288, "Debug spawn key."); } private static void Register() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) Setup = ScriptableObject.CreateInstance<EnemySetup>(); ((Object)Setup).name = "Enemy - Matriochka"; ((Object)Setup).hideFlags = (HideFlags)32; Setup.status = (Status)1; Setup.spawnObjects = new List<PrefabRef>(); Setup.levelsCompletedCondition = false; Setup.levelsCompletedMin = 0; Setup.levelsCompletedMax = 10; RarityPreset val = ScriptableObject.CreateInstance<RarityPreset>(); ((Object)val).name = "Matriochka Rarity"; val.chance = Mathf.Max(1f, (float)CfgPoolWeight.Value); ((Object)val).hideFlags = (HideFlags)32; Setup.rarityPreset = val; EnemyContent val2 = ScriptableObject.CreateInstance<EnemyContent>(); ((Object)val2).name = "Matriochka"; ((Object)val2).hideFlags = (HideFlags)32; AccessTools.Field(typeof(EnemyContent), "_setup").SetValue(val2, Setup); AccessTools.Field(typeof(EnemyContent), "_spawnObjects").SetValue(val2, new List<GameObject> { Prefab }); Enemies.RegisterEnemy(val2); } private void Update() { BonusSpawnTick(); DebugKeyTick(); Lang.Tick(); } private void BonusSpawnTick() { //IL_0135: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Setup == (Object)null) { return; } LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated) { levelReadyTime = -1f; } else { if ((Object)(object)instance == (Object)(object)handledLevel) { return; } try { if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel()) { handledLevel = instance; return; } if (levelReadyTime < 0f) { levelReadyTime = Time.time; rolled = false; nextSpawnTry = 0f; return; } float num = Time.time - levelReadyTime; if (num < 4f || Time.time < nextSpawnTry) { return; } nextSpawnTry = Time.time + 1f; if ((Object)(object)MatAI.Existing() != (Object)null) { handledLevel = instance; return; } if (!rolled) { rolled = true; int num2 = Random.Range(0, 100); if (num2 >= CfgSpawnChance.Value) { handledLevel = instance; Log.LogInfo((object)$"[Matriochka] Not in this level (roll {num2} >= {CfgSpawnChance.Value})."); return; } } if (!TryQuietPoint(Vector3.zero, 0f, 999f, out var pos)) { if (!(num < 29f)) { handledLevel = instance; } } else { handledLevel = instance; MatAI.SkipTeleportUntil = Time.time + 5f; Enemies.SpawnEnemy(Setup, pos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), false); Log.LogInfo((object)$"[Matriochka] Level Matriochka spawned at {pos}."); } } catch (Exception ex) { handledLevel = instance; Log.LogError((object)("[Matriochka] Level spawn failed: " + ex)); } } } internal static bool TryQuietPoint(Vector3 from, float minD, float maxD, out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) pos = Vector3.zero; List<LevelPoint> list = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? LevelGenerator.Instance.LevelPathPoints : null); if (list == null || list.Count == 0) { return false; } List<PlayerAvatar> list2 = SemiFunc.PlayerGetList(); for (int i = 0; i < 60; i++) { LevelPoint val = list[Random.Range(0, list.Count)]; if (!Object.op_Implicit((Object)(object)val) || val.Truck) { continue; } Vector3 position = ((Component)val).transform.position; if (from != Vector3.zero) { float num = Vector3.Distance(from, position); if (num < minD || num > maxD) { continue; } } bool flag = true; if (list2 != null) { foreach (PlayerAvatar item in list2) { if (Object.op_Implicit((Object)(object)item) && !item.isDisabled && Vector3.Distance(((Component)item).transform.position, position) < 15f) { flag = false; break; } } } if (flag || i >= 45) { pos = position + Vector3.up * 0.1f; return true; } } return false; } private void DebugKeyTick() { //IL_001f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b1: 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_00bc: 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_00c6: 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_00da: 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_0123: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (!CfgDebugSpawn.Value || (Object)(object)Setup == (Object)null || !Input.GetKeyDown(CfgDebugSpawnKey.Value) || Time.unscaledTime - lastDebugSpawn < 0.75f) { return; } lastDebugSpawn = Time.unscaledTime; try { if (!SemiFunc.IsMasterClientOrSingleplayer()) { Log.LogInfo((object)"[Debug] Only the host can spawn the Matriochka."); return; } if (!SemiFunc.RunIsLevel() || (Object)(object)PlayerAvatar.instance == (Object)null) { Log.LogInfo((object)"[Debug] Spawn key only works inside a level."); return; } Transform transform = ((Component)PlayerAvatar.instance).transform; Vector3 val = Vector3.ProjectOnPlane(transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = transform.position + normalized * 4f + Vector3.up * 0.2f; MatAI matAI = MatAI.Existing(); if ((Object)(object)matAI != (Object)null) { matAI.DebugBring(val2); Log.LogInfo((object)$"[Debug] Matriochka brought to {val2}."); return; } MatAI.SkipTeleportUntil = Time.time + 5f; Enemies.SpawnEnemy(Setup, val2, Quaternion.LookRotation(-normalized), false); handledLevel = LevelGenerator.Instance; Log.LogInfo((object)$"[Debug] Matriochka spawned at {val2}."); } catch (Exception ex) { Log.LogError((object)("[Debug] Spawn failed: " + ex)); } } } [HarmonyPatch(typeof(EnemyDirector), "AmountSetup")] internal static class DirectorExcludePatch { private static void Prefix(EnemyDirector __instance) { if (Plugin.CfgPoolWeight.Value <= 0 && !((Object)(object)Plugin.Setup == (Object)null) && Strip(__instance.enemiesDifficulty1) + Strip(__instance.enemiesDifficulty2) + Strip(__instance.enemiesDifficulty3) > 0) { Plugin.Log.LogInfo((object)"[Matriochka] Removed from the regular monster picks (spawns as one extra per level)."); } } private static int Strip(List<EnemySetup> list) { return list?.RemoveAll((EnemySetup s) => (Object)(object)s == (Object)(object)Plugin.Setup || ((Object)(object)s != (Object)null && ((Object)s).name == "Enemy - Matriochka")) ?? 0; } } [HarmonyPatch(typeof(EnemyHealth), "Hurt")] internal static class HurtPatch { private static void Prefix(EnemyHealth __instance, int _damage) { if (SemiFunc.IsMasterClientOrSingleplayer()) { MatAI component = ((Component)__instance).GetComponent<MatAI>(); if (Object.op_Implicit((Object)(object)component)) { component.BeforeHurt(_damage); } } } private static void Postfix(EnemyHealth __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { MatAI component = ((Component)__instance).GetComponent<MatAI>(); if (Object.op_Implicit((Object)(object)component)) { component.AfterHurt(); } } } } internal static class Util { public static void DestroyLater(GameObject go, float delay) { if (Object.op_Implicit((Object)(object)Plugin.Instance) && Object.op_Implicit((Object)(object)go)) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(Run(go, delay)); } } private static IEnumerator Run(GameObject go, float delay) { yield return (object)new WaitForSeconds(delay); if (Object.op_Implicit((Object)(object)go)) { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.Destroy(go); } else { Object.Destroy((Object)(object)go); } } } } internal static class Resource { public static T Load<T>(string path) where T : Object { T val = Resources.Load<T>(path); if ((Object)(object)val == (Object)null) { val = Resources.Load<T>(path.ToLowerInvariant()); } return val; } public static byte[] Embedded(string name) { using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream(name); if (stream == null) { throw new FileNotFoundException("Embedded resource missing: " + name); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } } internal static class PrefabBuilder { internal struct Part { public Mesh Mesh; public int[] MatIds; } internal const float RigidbodyHeight = 0.5f; internal static Mesh TopMesh; internal static Mesh BottomMesh; internal static int[] TopMats; internal static int[] BottomMats; internal static Material[] Materials; public static GameObject Build() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Resource.Load<GameObject>("Enemies/Enemy - Valuable Thrower"); if ((Object)(object)obj == (Object)null) { throw new Exception("Vanilla prefab 'Enemies/Enemy - Valuable Thrower' not found"); } GameObject val = Object.Instantiate<GameObject>(obj, Plugin.Holder.transform); ((Object)val).name = "Enemy - Matriochka"; Transform obj2 = val.transform.Find("Enable"); Transform val2 = obj2.Find("Controller"); Transform val3 = obj2.Find("Rigidbody"); Transform val4 = obj2.Find("Visuals"); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null) { throw new Exception("Unexpected Rugrat hierarchy (game update?)"); } CollectSounds(); Kill((Component)(object)((Component)val2).GetComponent<EnemyValuableThrower>()); Kill((Component)(object)((Component)val4).GetComponent<EnemyValuableThrowerAnim>()); Kill((Component)(object)((Component)val4).GetComponent<Animator>()); Transform val5 = val4.Find("Vision Transform"); List<GameObject> list = new List<GameObject>(); foreach (Transform item in val4) { Transform val6 = item; if ((Object)(object)val6 != (Object)(object)val5) { list.Add(((Component)val6).gameObject); } } Transform val7 = val.transform.Find("Plane"); if (Object.op_Implicit((Object)(object)val7)) { list.Add(((Component)val7).gameObject); } foreach (GameObject item2 in list) { Object.DestroyImmediate((Object)(object)item2); } EnemyParent component = val.GetComponent<EnemyParent>(); component.enemyName = "Matriochka"; component.enemyNameLocalized = null; component.difficulty = (Difficulty)Mathf.Clamp(Plugin.CfgDifficulty.Value - 1, 0, 2); component.SpawnedTimeMin = 240f; component.SpawnedTimeMax = 360f; component.DespawnedTimeMin = 90f; component.DespawnedTimeMax = 150f; ((Component)val2).GetComponent<Enemy>().Type = (EnemyType)2; EnemyHealth component2 = ((Component)val2).GetComponent<EnemyHealth>(); component2.health = Plugin.CfgHealth[0].Value; component2.objectHurtStun = false; component2.spawnValuable = true; EnemyRigidbody component3 = ((Component)val3).GetComponent<EnemyRigidbody>(); component3.positionSpeedIdle = 6f; component3.positionSpeedChase = 6f; component3.distanceWarpIdle = 1.5f; component3.distanceWarpChase = 1.5f; component3.rotationSpeedIdle = 0.6f; component3.rotationSpeedChase = 0.6f; Transform val8 = val3.Find("Collider"); if (Object.op_Implicit((Object)(object)val8)) { val8.localScale = Vector3.one; val8.localPosition = Vector3.zero; val8.localRotation = Quaternion.identity; CapsuleCollider component4 = ((Component)val8).GetComponent<CapsuleCollider>(); if (Object.op_Implicit((Object)(object)component4)) { component4.direction = 1; component4.radius = 0.26f * Plugin.Heights[0]; component4.height = Plugin.Heights[0]; component4.center = new Vector3(0f, -0.5f + Plugin.Heights[0] * 0.5f, 0f); } else { Plugin.Log.LogError((object)"Matriochka: Rugrat collider is not a capsule."); } } Transform transform = new GameObject("Center of Mass").transform; transform.SetParent(val3, false); transform.localPosition = new Vector3(0f, -0.25f, 0f); Transform val9 = val.transform.Find("Particles"); if (Object.op_Implicit((Object)(object)val9)) { ParticleSystem[] componentsInChildren = ((Component)val9).GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.55f, 0.57f, 0.6f), new Color(0.25f, 0.26f, 0.29f)); } } Transform meshParent = BuildModel(val4); component2.meshParent = meshParent; if (Object.op_Implicit((Object)(object)val5)) { val5.localPosition = new Vector3(0f, 0.79999995f, 0.2f); val5.localRotation = Quaternion.identity; } ((Component)val2).gameObject.AddComponent<MatAI>(); ((Component)val3).gameObject.AddComponent<MatImpact>(); return val; } private static void Kill(Component c) { if ((Object)(object)c != (Object)null) { Object.DestroyImmediate((Object)(object)c); } } private static T AnimOf<T>(string path) where T : Component { GameObject val = Resource.Load<GameObject>(path); if (!Object.op_Implicit((Object)(object)val)) { return default(T); } return val.GetComponentInChildren<T>(true); } private static void CollectSounds() { try { Sounds.Laugh = Sounds.Make("Laugh", (AudioType)0, 0.75f, 1f, 0.04f, "laugh_1.wav", "laugh_2.wav"); Sounds.LaughSmall = Sounds.Make("LaughSmall", (AudioType)0, 0.5f, 1f, 0.08f, "laugh_small.wav"); Sounds.Roll = Sounds.Make("Roll", (AudioType)0, 0.35f, 1f, 0.1f, "roll_1.wav", "roll_2.wav", "roll_3.wav"); Sounds.Pop = Sounds.Make("Pop", (AudioType)0, 0.85f, 1f, 0.05f, "pop.wav"); Sounds.Bonk = Sounds.Make("Bonk", (AudioType)0, 0.8f, 1f, 0.06f, "bonk.wav"); EnemyBangAnim val = AnimOf<EnemyBangAnim>("Enemies/Enemy - Bang"); if (Object.op_Implicit((Object)(object)val)) { Sounds.Hurt = val.soundImpactMedium; Sounds.Death = val.soundDeathSFX; Sounds.Break = val.soundImpactLight; } EnemyBowtieAnim val2 = AnimOf<EnemyBowtieAnim>("Enemies/Enemy - Bowtie"); if (Object.op_Implicit((Object)(object)val2)) { Sounds.DeathSpark = val2.despawnSparkSound; } EnemyBeamerAnim val3 = AnimOf<EnemyBeamerAnim>("Enemies/Enemy - Beamer"); if (Object.op_Implicit((Object)(object)val3)) { Sounds.Stun = val3.soundStunIntro; Sounds.StunOutro = val3.soundStunOutro; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not prepare sounds: " + ex.Message)); } } private static Transform BuildModel(Transform vis) { //IL_001f: 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_00a2: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) Dictionary<string, Part> dictionary = LoadMeshes(Resource.Embedded("Matriochka.matrio.mesh")); Materials = MakeMaterials(); Transform transform = new GameObject("MatModel").transform; transform.SetParent(vis, false); transform.localPosition = new Vector3(0f, -0.5f, 0f); Dictionary<string, Transform> dictionary2 = new Dictionary<string, Transform>(); for (int i = 0; i < ModelLayout.Parts.Length; i++) { string text = ModelLayout.Parts[i]; string text2 = ModelLayout.Parents[i]; Transform parent = (string.IsNullOrEmpty(text2) ? transform : dictionary2[text2]); Vector3 val = (string.IsNullOrEmpty(text2) ? Vector3.zero : ModelLayout.Pivots[Array.IndexOf(ModelLayout.Parts, text2)]); dictionary2[text] = MakePart(text, dictionary[text], Materials, parent, ModelLayout.Pivots[i] - val); } TopMesh = dictionary["top"].Mesh; TopMats = dictionary["top"].MatIds; BottomMesh = dictionary["bottom"].Mesh; BottomMats = dictionary["bottom"].MatIds; return transform; } private static Transform MakePart(string name, Part p, Material[] mats, Transform parent, Vector3 localPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = localPos; val.AddComponent<MeshFilter>().sharedMesh = p.Mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); Material[] array = (Material[])(object)new Material[p.MatIds.Length]; for (int i = 0; i < array.Length; i++) { array[i] = mats[Mathf.Clamp(p.MatIds[i], 0, mats.Length - 1)]; } ((Renderer)val2).sharedMaterials = array; return val.transform; } private static Material[] MakeMaterials() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) Texture2D tex = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(tex, Resource.Embedded("Matriochka.atlas.png"), false); ((Object)tex).name = "Matriochka Atlas"; ((Texture)tex).wrapMode = (TextureWrapMode)1; ((Texture)tex).filterMode = (FilterMode)2; ((Texture)tex).anisoLevel = 4; tex.Apply(true, true); ((Object)tex).hideFlags = (HideFlags)32; Material baseMat = null; GameObject val = Resource.Load<GameObject>("Valuables/03 Medium/Valuable Manor Vase"); if (Object.op_Implicit((Object)(object)val)) { MeshRenderer componentInChildren = val.GetComponentInChildren<MeshRenderer>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { baseMat = ((Renderer)componentInChildren).sharedMaterial; } } Shader shader = (Object.op_Implicit((Object)(object)baseMat) ? baseMat.shader : Shader.Find("Standard")); return (Material[])(object)new Material[3] { Make("Matriochka Lacquer", 0.86f, 0.3f, Color.black), Make("Matriochka Brass", 0.75f, 0.9f, Color.black), Make("Matriochka Inner", 0.2f, 0f, Color.black) }; Material Make(string n, float gloss, float metal, Color emission) { //IL_0023: 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_0029: Expected O, but got Unknown //IL_003e: 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_00a6: Unknown result type (might be due to invalid IL or missing references) Material val2 = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(shader)); ((Object)val2).name = n; val2.mainTexture = (Texture)(object)tex; val2.color = Color.white; if (val2.HasProperty("_Glossiness")) { val2.SetFloat("_Glossiness", gloss); } if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", metal); } if (((Color)(ref emission)).maxColorComponent > 0f && val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", emission); if (val2.HasProperty("_EmissionMap")) { val2.SetTexture("_EmissionMap", (Texture)(object)tex); } val2.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; } else { val2.DisableKeyword("_EMISSION"); if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", Color.black); } } ((Object)val2).hideFlags = (HideFlags)32; return val2; } } private static Dictionary<string, Part> LoadMeshes(byte[] data) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00cf: 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_00fa: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown Dictionary<string, Part> dictionary = new Dictionary<string, Part>(); using BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); if (new string(binaryReader.ReadChars(4)) != "FMSH") { throw new Exception("Bad mesh data"); } int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32())); int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int k = 0; k < num2; k++) { array2[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int l = 0; l < num2; l++) { array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int num3 = binaryReader.ReadInt32(); Mesh val = new Mesh { name = "Matriochka " + text }; val.vertices = array; val.normals = array2; val.uv = array3; val.subMeshCount = num3; int[] array4 = new int[num3]; for (int m = 0; m < num3; m++) { array4[m] = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); int[] array5 = new int[num4]; for (int n = 0; n < num4; n++) { array5[n] = binaryReader.ReadInt32(); } val.SetTriangles(array5, m); } val.RecalculateBounds(); val.RecalculateTangents(); ((Object)val).hideFlags = (HideFlags)32; dictionary[text] = new Part { Mesh = val, MatIds = array4 }; } return dictionary; } } }