using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using Silksong.AssetHelper.ManagedAssets; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Troll_Trobbio { [BepInPlugin("lagerthon.Troll_Trobbio", "Troll_Trobbio", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Trobbio : BaseUnityPlugin { public static Trobbio instance; public static ManualLogSource Log; public static ManagedAsset sentryGO; public static GameObject sentry; private static bool sentryBool; public static ConfigEntry timer; private void Awake() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; if ((Object)(object)instance == (Object)null) { instance = this; } sentryGO = ManagedAsset.FromSceneAsset("hang_04_boss", "Battle Scene/Wave 8 - Heavy Sentry/Song Heavy Sentry"); SceneManager.sceneLoaded += OnSceneLoaded; Harmony val = new Harmony("lagerthon.Troll_Trobbio"); val.PatchAll(); Log.LogInfo((object)"Troll_Trobbio loaded"); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { PlaymakerFSMPatch.trobbioPatched = false; PlaymakerFSMPatch.bombPatched = false; if ((Object)(object)HeroController.instance != (Object)null && !sentryBool) { ((MonoBehaviour)this).StartCoroutine(Sentry()); } } private IEnumerator Sentry() { sentryBool = true; yield return null; ((ManagedAssetBase)(object)sentryGO).Load(); yield return (object)new WaitUntil((Func)(() => ((ManagedAssetBase)(object)sentryGO).IsLoaded)); sentry = ManagedAssetExtensions.InstantiateAsset(sentryGO); Object.DontDestroyOnLoad((Object)(object)sentry); sentry.SetActive(false); } } [HarmonyPatch(typeof(PlayMakerFSM), "Awake")] public class PlaymakerFSMPatch { public static bool bombPatched; public static GameObject customBomb; public static PlayMakerFSM trobbioCtrl; public static bool trobbioPatched; private static void Postfix(PlayMakerFSM __instance) { //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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Expected O, but got Unknown //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Expected O, but got Unknown Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "Library_13" || (Object)(object)__instance == (Object)null || bombPatched) { return; } if (((Object)((Component)__instance).gameObject).name == "Trobbio" && !trobbioPatched) { HealthManager component = ((Component)__instance).gameObject.GetComponent(); component.hp = 1400; trobbioCtrl = PlayMakerFSM.FindFsmOnGameObject(((Component)__instance).gameObject, "Control"); if ((Object)(object)trobbioCtrl != (Object)null) { trobbioPatched = true; SpawnBomb(trobbioCtrl, "Throw"); SpawnBomb(trobbioCtrl, "Flurry Shot"); } } if (!((Object)((Component)__instance).gameObject).name.Contains("Trobbio Bomb")) { return; } if ((Object)(object)customBomb == (Object)null) { bombPatched = true; customBomb = Object.Instantiate(((Component)__instance).gameObject); ((Object)customBomb).name = "Custom Bomb"; foreach (Transform item in customBomb.transform) { Transform val = item; foreach (Transform item2 in val) { Transform val2 = item2; if (((Object)val2).name.Contains("Steam")) { ((Component)val2).gameObject.SetActive(false); } } } bombPatched = false; BoxCollider2D component2 = customBomb.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = false; } CircleCollider2D val3 = customBomb.AddComponent(); val3.radius = 0.3f; ((Behaviour)val3).enabled = false; BoxCollider2D component3 = customBomb.GetComponent(); PhysicsMaterial2D val4 = new PhysicsMaterial2D(); val4.bounciness = 0.3f; val4.friction = 0.2f; ((Collider2D)component3).sharedMaterial = val4; PlayMakerFSM[] components = customBomb.GetComponents(); PlayMakerFSM[] array = components; foreach (PlayMakerFSM val5 in array) { if (!(val5.FsmName == "Control")) { continue; } FsmState state = val5.Fsm.GetState("Air"); if (state != null) { state.Transitions = state.Transitions.Where((FsmTransition t) => t.EventName == "TIME UP").ToArray(); } } PlayMakerFSM val6 = ((IEnumerable)Trobbio.sentry.GetComponents()).FirstOrDefault((Func)((PlayMakerFSM f) => f.FsmName == "Bomb Cast")); PlayMakerFSM val7 = customBomb.AddComponent(); if ((Object)(object)val6 != (Object)null) { val7.Fsm = new Fsm(val6.Fsm, (FsmVariables)null); val7.FsmName = val6.FsmName; FsmState state2 = val7.Fsm.GetState("First Bomb"); if (state2 == null) { return; } FsmFloat fsmFloat = val7.Fsm.Variables.GetFsmFloat("Bomb Pause"); if (fsmFloat != null) { fsmFloat.Value = 0.02f; } FsmFloat fsmFloat2 = val7.Fsm.Variables.GetFsmFloat("Bomb Spacing"); if (fsmFloat2 != null) { fsmFloat2.Value = 1.5f; } FsmStateAction[] actions = state2.Actions; foreach (FsmStateAction val8 in actions) { FloatAdd val9 = (FloatAdd)(object)((val8 is FloatAdd) ? val8 : null); if (val9 != null) { val9.add.Value = 3f; } SetIntValue val10 = (SetIntValue)(object)((val8 is SetIntValue) ? val8 : null); if (val10 != null) { val10.intValue.Value = 30; } } FsmState state3 = val7.Fsm.GetState("Bomb Pairs"); FsmStateAction[] actions2 = state3.Actions; foreach (FsmStateAction val11 in actions2) { SpawnObjectFromGlobalPool val12 = (SpawnObjectFromGlobalPool)(object)((val11 is SpawnObjectFromGlobalPool) ? val11 : null); if (val12 == null) { continue; } GameObject value = val12.gameObject.Value; foreach (Transform item3 in value.transform) { Transform val13 = item3; if (((Object)((Component)val13).gameObject).name.Contains("damage")) { ((Component)val13).gameObject.layer = LayerMask.NameToLayer("Attack"); TrobbioDamager trobbioDamager = ((Component)val13).gameObject.AddComponent(); ((Behaviour)trobbioDamager).enabled = true; } } } val7.Fsm.InitData(); ((Behaviour)val7).enabled = true; customBomb.AddComponent(); customBomb.AddComponent(); } customBomb.SetActive(false); Object.DontDestroyOnLoad((Object)(object)customBomb); } PatchOriginalBomb(__instance); } private static void SpawnBomb(PlayMakerFSM fsm, string stateName) { FsmState state = fsm.Fsm.GetState(stateName); if (state != null && !state.Actions.Any((FsmStateAction a) => a is SpawnBombAction)) { List list = state.Actions.ToList(); list.Insert(0, (FsmStateAction)(object)new SpawnBombAction()); state.Actions = list.ToArray(); } } private static void PatchOriginalBomb(PlayMakerFSM __instance) { if ((Object)(object)__instance == (Object)null || !((Object)((Component)__instance).gameObject).name.Contains("Trobbio Bomb") || __instance.FsmName != "Control") { return; } FsmState state = __instance.Fsm.GetState("Antic"); FsmFloat fsmFloat = __instance.Fsm.Variables.GetFsmFloat("Rotation"); if (fsmFloat != null) { fsmFloat.Value = 20f; } if (state == null) { return; } state.Actions = state.Actions.Where((FsmStateAction a) => !(a is SetRotation) || !(a is SetIsKinematic2d)).ToArray(); FsmStateAction[] actions = state.Actions; foreach (FsmStateAction val in actions) { SetRotation val2 = (SetRotation)(object)((val is SetRotation) ? val : null); if (val2 != null) { val2.zAngle.Value = 5f; val2.everyFrame = true; val2.lateUpdate = true; } SetIsKinematic2d val3 = (SetIsKinematic2d)(object)((val is SetIsKinematic2d) ? val : null); if (val3 != null) { val3.isKinematic.Value = true; } Wait val4 = (Wait)(object)((val is Wait) ? val : null); if (val4 != null) { val4.time.Value = Random.Range(1f, 2.5f); } } FsmState state2 = __instance.Fsm.GetState("Explode"); if (state2 != null) { state2.Actions = state2.Actions.Where((FsmStateAction a) => !(a is SetIsKinematic2d)).ToArray(); Rigidbody2D val5 = ((Component)__instance).gameObject.GetComponent() ?? ((Component)__instance).gameObject.AddComponent(); val5.bodyType = (RigidbodyType2D)0; val5.constraints = (RigidbodyConstraints2D)0; val5.freezeRotation = false; BombAirPatch bombAirPatch = ((Component)__instance).gameObject.AddComponent(); bombAirPatch.Init(__instance); } } } public class SpawnBombAction : FsmStateAction { public override void OnEnter() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PlaymakerFSMPatch.customBomb == (Object)null) { ((FsmStateAction)this).Finish(); return; } GameObject val = Object.Instantiate(PlaymakerFSMPatch.customBomb); ((Object)val).name = "Custom Bomb (Spawned)"; val.transform.position = new Vector3(73f, 28f, 0f); PlayMakerFSM fsm = ((IEnumerable)val.GetComponents()).FirstOrDefault((Func)((PlayMakerFSM f) => f.FsmName == "Bomb Cast")); BombCast component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.Init(fsm, 17f); } val.SetActive(true); ((FsmStateAction)this).Finish(); } } [HarmonyPatch(typeof(PlayMakerFSM), "Start")] public class PlaymakerFSMPatch1 { private static void Postfix(PlayMakerFSM __instance) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0141: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_01a3: 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_01bd: Expected O, but got Unknown if (((Object)((Component)__instance).gameObject).name != "Trobbio") { return; } Fsm fsm = __instance.Fsm; FsmState state = fsm.GetState("Tornado Start"); FsmStateAction[] actions = state.Actions; foreach (FsmStateAction val in actions) { SetFloatValue val2 = (SetFloatValue)(object)((val is SetFloatValue) ? val : null); if (val2 != null && val2.floatValue != null) { if (val2.floatValue.Value == 22f) { val2.floatValue.Value = 25f; } if (val2.floatValue.Value == -22f) { val2.floatValue.Value = -25f; } } } state = fsm.GetState("Tornado Shoot"); List list = state.Actions.OfType().ToList(); List list2 = state.Actions.ToList(); for (int j = 0; j < list.Count; j++) { SpawnObjectFromGlobalPool val3 = list[j]; SpawnObjectFromGlobalPool val4 = new SpawnObjectFromGlobalPool(); val4.gameObject = new FsmGameObject { UseVariable = false, Value = val3.gameObject.Value }; val4.spawnPoint = new FsmGameObject { UseVariable = false, Value = val3.spawnPoint.Value }; val4.position = new FsmVector3 { UseVariable = false, Name = "", Value = new Vector3(Mathf.Pow(-1f, (float)j) * 5f, 0f, val3.position.Value.z) }; val4.rotation = val3.rotation; val4.storeObject = val3.storeObject; int index = Mathf.Min(14 + j, list2.Count); list2.Insert(index, (FsmStateAction)(object)val4); } state.Actions = list2.ToArray(); state = fsm.GetState("Tornado"); if (!state.Actions.Any((FsmStateAction a) => a is TornadoTurn)) { list2 = state.Actions.ToList(); list2.Insert(0, (FsmStateAction)(object)new TornadoTurn()); state.Actions = list2.ToArray(); } } } public class TornadoTurn : FsmStateAction { private Rigidbody2D rb; private Transform trobbio; private Transform hero; private float distMax; public override void OnEnter() { trobbio = ((FsmStateAction)this).Owner.transform; hero = ((Component)HeroController.instance).transform; rb = ((FsmStateAction)this).Owner.GetComponent(); distMax = Random.Range(10f, 12f); } public override void OnUpdate() { //IL_002f: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)hero == (Object)null || (Object)(object)rb == (Object)null) { return; } Vector2 val = Vector2.op_Implicit(hero.position - trobbio.position); float magnitude = ((Vector2)(ref val)).magnitude; if (!(Mathf.Abs(hero.position.x - trobbio.position.x) < distMax)) { Vector2 normalized = ((Vector2)(ref val)).normalized; Vector2 velocity = rb.velocity; float num = Vector2.Dot(((Vector2)(ref velocity)).normalized, normalized); if (num < 0f) { ((FsmStateAction)this).Fsm.Event("WALL"); } } } } public class BombControlPatch : MonoBehaviour { private PlayMakerFSM controlFSM; private FsmBool inRangeX; private FsmBool inRangeY; private FsmBool timeUp; private CircleCollider2D cr; private BoxCollider2D box; private float timer; private void Awake() { cr = ((Component)this).GetComponent(); box = ((Component)this).GetComponent(); ((Behaviour)cr).enabled = true; ((Collider2D)cr).isTrigger = true; controlFSM = ((IEnumerable)((Component)this).GetComponents()).FirstOrDefault((Func)((PlayMakerFSM f) => f.FsmName == "Control")); if ((Object)(object)controlFSM == (Object)null) { return; } inRangeX = controlFSM.Fsm.Variables.GetFsmBool("In Range X"); inRangeY = controlFSM.Fsm.Variables.GetFsmBool("In Range Y"); timeUp = controlFSM.Fsm.Variables.GetFsmBool("Time Up"); FsmState state = controlFSM.Fsm.GetState("Air"); if (state != null) { state.Actions = state.Actions.Where((FsmStateAction a) => !(a is FloatInRange) && !(a is GetVelocity2d) && !(a is SetFloatValue)).ToArray(); } FsmState state2 = controlFSM.Fsm.GetState("Antic"); if (state2 != null) { state2.Transitions = (FsmTransition[])(object)new FsmTransition[0]; state2.Actions = state2.Actions.Where((FsmStateAction a) => !(a is ClampPosition) && !(a is DecelerateV2) && !(a is SetIsKinematic2d)).ToArray(); } FsmStateAction[] actions = state2.Actions; FsmStateAction[] array = actions; foreach (FsmStateAction val in array) { AudioStop val2 = (AudioStop)(object)((val is AudioStop) ? val : null); if (val2 != null) { val2.fadeTime.Value = 3f; } } timer = 0f; } private void LateUpdate() { if (inRangeX != null) { inRangeX.Value = true; } if (inRangeY != null) { inRangeY.Value = true; } if (timeUp != null) { timeUp.Value = true; } timer += Time.deltaTime; if (timer > 1f) { ((Behaviour)box).enabled = true; } else { ((Behaviour)box).enabled = false; } } } public class TrobbioDamager : MonoBehaviour { private int damage; private void OnTriggerEnter2D(Collider2D other) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)other).gameObject).name != "Trobbio" || !BombCast.hornetHit) { return; } HealthManager component = ((Component)other).GetComponent(); if (!((Object)(object)component == (Object)null)) { int nailDamage = PlayerData.instance.nailDamage; if (1 == 0) { } int num = nailDamage switch { 5 => 3, 9 => 3, 13 => 4, 17 => 5, 21 => 5, _ => 6, }; if (1 == 0) { } damage = num; HitInstance val = new HitInstance { Source = ((Component)HeroController.instance).gameObject, DamageDealt = damage, Multiplier = 1f, AttackType = (AttackTypes)1, HitEffectsType = (EffectsTypes)0, Direction = Mathf.Sign(((Component)other).transform.position.x - ((Component)HeroController.instance).transform.position.x), IgnoreInvulnerable = true, CanWeakHit = true, MagnitudeMultiplier = 1f }; component.Hit(val); BombCast.damageDealt = true; } } } public class BombCast : MonoBehaviour { private PlayMakerFSM fsm; private float castY; private float count; private bool bombCasted = false; public static bool hornetHit; public static bool damageDealt; private bool show; private Texture2D tex; private float scale = 0.05f; public void Init(PlayMakerFSM fsm, float y) { this.fsm = fsm; castY = y; count = 3f; bombCasted = false; hornetHit = false; damageDealt = false; } private void Update() { count -= Time.deltaTime; if ((Object)(object)fsm == (Object)null) { return; } string activeStateName = fsm.ActiveStateName; if (count < 0f) { count = 5f; if (!bombCasted) { fsm.SendEvent("BOMB CAST"); bombCasted = true; } } if (bombCasted && count < 4.71f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnTriggerEnter2D(Collider2D other) { if (!((Object)((Component)other).gameObject).name.Contains("damage") && LayerMask.LayerToName(((Component)other).gameObject.layer) == "Attack") { fsm.SendEvent("BOMB CAST"); bombCasted = true; count = 5f; if (((Object)((Component)other).gameObject).name.Contains("DownSlash")) { hornetHit = true; } } } } public class BombAirPatch : MonoBehaviour { private PlayMakerFSM fsm; private float airTimer = 0f; private float anticTimer = 0f; private bool inAir = false; private bool inAntic = false; private int mode; private float dir; private float dirTimer = 0f; private HealthManager trobbioHM; public void Init(PlayMakerFSM fsm) { this.fsm = fsm; mode = ((!(Random.value < 0.5f)) ? 1 : (-1)); dir = ((!(Random.value < 0.5f)) ? 1 : (-1)); } private void Update() { if ((Object)(object)fsm == (Object)null) { return; } trobbioHM = ((Component)PlaymakerFSMPatch.trobbioCtrl).gameObject.GetComponent(); float num = Mathf.Lerp(1.5f, 1f, (float)trobbioHM.hp / 1400f); string activeStateName = fsm.ActiveStateName; if (activeStateName == "Antic" || activeStateName == "Explode") { Rigidbody2D val = ((Component)this).GetComponent() ?? ((Component)this).gameObject.AddComponent(); val.angularVelocity = ((mode == 1) ? (dir * num * 180f) : (3f * num * 180f * Mathf.Sin(MathF.PI * 4f * dirTimer))); } dirTimer += Time.deltaTime; if (activeStateName == "Air") { if (!inAir) { inAir = true; airTimer = 0f; } airTimer += Time.deltaTime; if (airTimer >= 2f) { fsm.SendEvent("TIME UP"); airTimer = 0f; inAir = false; } } else { inAir = false; airTimer = 0f; } if (activeStateName == "Antic" || activeStateName == "Explode") { if (!inAntic) { inAntic = true; anticTimer = 0f; } anticTimer += Time.deltaTime; if (anticTimer >= 6f) { anticTimer = 0f; inAntic = false; } } else { inAntic = false; anticTimer = 0f; } } } }