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 HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using Silksong.FsmUtil; using TeamCherry.Localization; using UnityEngine; using UnityEngine.Events; 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: AssemblyCompany("RebelliousSecondSentinel")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("RebelliousSecondSentinel")] [assembly: AssemblyTitle("RebelliousSecondSentinel")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/1/SilksongMod1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace RebelliousSecondSentinel { [BepInPlugin("AuthorName", "RebelliousSecondSentinel", "0.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class SecondSentinel : BaseUnityPlugin { public static SecondSentinel Instance; private static HealthManager? healthManager; private static PlayMakerFSM? secondSentinel; public static UnityAction? __sceneLoadSetup; private static bool isInitialized = false; public static bool isInCorrectScene = false; public static bool hpRecheck = false; private static int CScount = 0; public static bool bladeWillRotate = true; private static float WScount = 1f; public static bool isComboTribleWS = false; private static bool willRotateDuringRS = false; public static bool rotateDone = false; public static bool comboRSnotComboWS = false; private static int parryCount = 0; private static int setPhase2HP = 800; private static int phaseCheck = 1500; public static bool isInPhase2 = false; public static bool isPhaseChangeDone = false; public static bool sendMessage = true; public void Awake() { Instance = this; Harmony.CreateAndPatchAll(typeof(SecondSentinel), (string)null); UnityAction val; if ((val = __sceneLoadSetup) == null) { val = SceneCheck; } SceneManager.sceneLoaded += val; } private void SceneCheck(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name != "Hang_17b") { isInCorrectScene = false; return; } ResetValues(); isInCorrectScene = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Scene Loaded"); } public void OnDestroy() { SceneManager.sceneLoaded -= SceneCheck; } public static void Initialize(PlayMakerFSM __instance) { PlayMakerFSM fsmComponent = __instance.fsm.FsmComponent; if (!((Object)(object)fsmComponent == (Object)null)) { FsmState state = FsmUtil.GetState(fsmComponent, "Back Dash"); if (state != null) { isInitialized = true; FsmUtil.RemoveTransition(fsmComponent, "Sing", "SING DURATION END"); FsmUtil.RemoveAction(fsmComponent, "Sing", 3); FsmUtil.RemoveAction(fsmComponent, "Parry Stance", 6); FsmUtil.GetFirstActionOfType(fsmComponent, "Idle").time = FsmFloat.op_Implicit(0.2f); FsmUtil.GetFirstActionOfType(fsmComponent, "Back Dash").speed = FsmFloat.op_Implicit(-42f); FsmUtil.GetFirstActionOfType(fsmComponent, "Rising Slash").ySpeed = FsmFloat.op_Implicit(0f); FsmUtil.GetFirstActionOfType(fsmComponent, "Rising Slash Antic").ySpeed = FsmFloat.op_Implicit(0f); FsmUtil.GetFirstActionOfType(fsmComponent, "Close Decel").speed = FsmFloat.op_Implicit(5f); FsmUtil.GetFirstActionOfType(fsmComponent, "CS Ground Launch").speed = FsmFloat.op_Implicit(0f); } } } [HarmonyPostfix] [HarmonyPatch(typeof(Language), "Get", new Type[] { typeof(string), typeof(string) })] private static void LanguageSet(string key, string sheetTitle, ref string __result) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 LanguageCode val = Language.CurrentLanguage(); if (key == "SONG_KNIGHT_SUPER") { if ((int)val == 199) { __result = "有点叛逆的"; } else { __result = "Rebellious Second"; } } if (key == "SONG_KNIGHT_MAIN") { if ((int)val == 199) { __result = "次席戍卫"; } else { __result = "Sentinel"; } } if (key == "SONG_KNIGHT_SUB") { if ((int)val == 199) { __result = "(屑)"; } else { __result = "(Bruh)"; } } } public static void ResetValues() { healthManager = null; isInitialized = false; isInCorrectScene = false; CScount = 0; bladeWillRotate = true; WScount = 1f; isComboTribleWS = false; willRotateDuringRS = false; rotateDone = false; phaseCheck = 1500; parryCount = 0; setPhase2HP = 800; isPhaseChangeDone = false; comboRSnotComboWS = false; isInPhase2 = false; sendMessage = true; hpRecheck = false; } public void FixedUpdate() { } [HarmonyPrefix] [HarmonyPatch(typeof(FsmState), "OnEnter")] private static void OnFsmStateEntered(FsmState __instance) { //IL_0165: 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) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || !isInCorrectScene) { return; } if (!isInitialized) { secondSentinel = __instance.Fsm.FsmComponent; Initialize(secondSentinel); } if ((Object)(object)secondSentinel != (Object)null) { GameObject val = GameObject.Find("Song Knight"); DamageHero component = val.GetComponent(); string name = __instance.Name; if (name == "Forward Antic" || name == "Back Antic") { component.damageDealt = 0; return; } if (name == "Dash Land" || name == "Back Dash Land") { ((MonoBehaviour)Instance).StartCoroutine(DelayDamageHero(component)); return; } if (name == "First Idle") { hpRecheck = true; healthManager = ((Component)__instance.fsm.FsmComponent).gameObject.GetComponent(); healthManager.hp = 1500; phaseCheck = healthManager.hp; return; } if (name == "Move Choice" || name == "Do Move") { rotateDone = false; val.transform.localEulerAngles = Vector3.zero; return; } switch (name) { case "Idle": rotateDone = false; if ((Object)(object)healthManager == (Object)null && hpRecheck) { healthManager = ((Component)__instance.fsm.FsmComponent).gameObject.GetComponent(); } if ((Object)(object)healthManager != (Object)null && phaseCheck > setPhase2HP) { phaseCheck = healthManager.hp; } if (phaseCheck <= setPhase2HP && parryCount <= 15 && !isPhaseChangeDone && sendMessage) { secondSentinel.SetState("Parry Stance"); } val.transform.localEulerAngles = Vector3.zero; return; case "Land 2": if (CScount <= 1) { Vector3 position = HeroController.instance.transform.position; float scaleX2 = Extensions.GetScaleX(((Component)secondSentinel).transform); position.x += scaleX2 * 2.33f; position.y -= 1.06f; ((Component)secondSentinel).transform.position = position; secondSentinel.SetState("CS Jump Antic"); } else { CScount = 0; } return; case "Rising Slash": if (willRotateDuringRS) { ((MonoBehaviour)Instance).StartCoroutine(RotateOverTime(val, 1f)); ((Component)secondSentinel).transform.localEulerAngles = Vector3.zero; if (rotateDone) { ((MonoBehaviour)Instance).StopCoroutine(RotateOverTime(val, 1f)); } } else { ((MonoBehaviour)Instance).StartCoroutine(MoveOverTime(val, 0.5f)); } return; case "Rising Slash Followup": ((Component)secondSentinel).transform.localEulerAngles = Vector3.zero; return; case "CrossSlash 1": { CScount++; component.damageDealt = 0; Transform val2 = ((Component)secondSentinel).gameObject.transform.Find("CrossSlash Antic"); float positionX3 = Extensions.GetPositionX(((Component)val2).transform); float positionY = Extensions.GetPositionY(((Component)val2).transform); float scaleX3 = Extensions.GetScaleX(((Component)secondSentinel).transform); if (bladeWillRotate) { bladeWillRotate = false; ((Component)val2).gameObject.transform.localEulerAngles = new Vector3(0f, 0f, 32f); ((Component)val2).transform.position = new Vector3(positionX3 + 0.33f * scaleX3, positionY + 0.86f, 0f); } else { bladeWillRotate = true; ((Component)val2).gameObject.transform.localEulerAngles = Vector3.zero; ((Component)val2).transform.position = new Vector3(positionX3 - 0.33f * scaleX3, positionY - 0.86f, 0f); } return; } case "Dash Slash Antic": { float positionX = Extensions.GetPositionX(val.transform); float scaleX = Extensions.GetScaleX(val.transform); float positionX2 = Extensions.GetPositionX(HeroController.instance.transform); if (positionX2 * scaleX > positionX * scaleX) { val.transform.localScale = new Vector3(0f - scaleX, 1f, 0f); } return; } case "Parry Stance": { GameObject gameObject = ((Component)((Component)secondSentinel).gameObject.transform.Find("Charge Effect")).gameObject; GameObject gameObject2 = ((Component)((Component)secondSentinel).gameObject.transform.Find("Charged Effect")).gameObject; GameObject gameObject3 = ((Component)((Component)secondSentinel).gameObject.transform.Find("Parry Clash Effect")).gameObject; gameObject3.SetActive(false); if (phaseCheck <= setPhase2HP && parryCount <= 15 && !isPhaseChangeDone) { sendMessage = false; parryCount++; ((MonoBehaviour)Instance).StartCoroutine(ChangePhase1(0.1f)); gameObject.SetActive(true); if (parryCount >= 10) { gameObject.SetActive(false); gameObject2.SetActive(true); } if (parryCount == 15) { CScount = 0; bladeWillRotate = true; WScount = 0f; isPhaseChangeDone = true; parryCount = 0; } } else { parryCount = 0; ((MonoBehaviour)Instance).StartCoroutine(WallSideCombo(0.5f)); gameObject.SetActive(false); } return; } case "Sing": if (phaseCheck <= setPhase2HP && parryCount <= 15 && !isPhaseChangeDone) { Object.Destroy((Object)(object)FSMUtility.LocateMyFSM(((Component)secondSentinel).gameObject, "Stun Control")); ((MonoBehaviour)Instance).StartCoroutine(ChangePhase2(1.5f / (float)parryCount)); return; } WScount = 1f; isComboTribleWS = false; willRotateDuringRS = false; rotateDone = false; secondSentinel.SetState("CrossSlash 1"); return; case "Hornet Dead": ResetValues(); return; case "Stunned": WScount = 1f; isComboTribleWS = false; willRotateDuringRS = false; rotateDone = false; return; case "Stun Recover": WScount = 1f; isComboTribleWS = false; willRotateDuringRS = false; rotateDone = false; return; case "Jump Fall": if (isComboTribleWS) { if (WScount < 4f) { secondSentinel.SetState("Parry Stance"); return; } WScount = 1f; isComboTribleWS = false; comboRSnotComboWS = Random.Range(0, 2) == 0; return; } break; } if (name == "Windslash A" && Extensions.GetPositionY(((Component)secondSentinel).transform) < 8f) { secondSentinel.SetState("Windslash G"); } else if (name == "Dive Dir" && isInPhase2) { ((MonoBehaviour)Instance).StartCoroutine(ChargeDuringDive()); } else if (name == "Dive Land" && isInPhase2) { ((MonoBehaviour)Instance).StartCoroutine(DiveLandCS(0.5f)); } } else { ResetValues(); } } public static IEnumerator ChargeDuringDive() { GameObject charge = ((Component)((Component)secondSentinel).gameObject.transform.Find("Charge Effect")).gameObject; GameObject charged = ((Component)((Component)secondSentinel).gameObject.transform.Find("Charged Effect")).gameObject; charge.SetActive(true); yield return (object)new WaitForSeconds(0.4f); charge.SetActive(false); charged.SetActive(true); yield return (object)new WaitForSeconds(0.3f); charged.SetActive(false); } public static IEnumerator DiveLandCS(float duration) { yield return (object)new WaitForSeconds(0.05f); GameObject crossSlash = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((GameObject go) => ((Object)go).name == "Song Knight CrossSlash(Clone)")); Vector3 pos = ((Component)secondSentinel).transform.position; float scalex = Extensions.GetScaleX(((Component)secondSentinel).transform); pos.x -= 2f * scalex; pos.y -= 1f; crossSlash.transform.position = pos; float timer = 0f; crossSlash.SetActive(true); while (timer < duration) { timer += Time.deltaTime; crossSlash.transform.localEulerAngles = new Vector3(0f, 0f, timer * 720f); crossSlash.transform.localScale = new Vector3(scalex * 0.6f * (1.2f - timer), 1.2f - timer, 1f); yield return null; } crossSlash.SetActive(false); crossSlash.transform.localScale = new Vector3(scalex * 2f, 2f, 1f); yield return null; } public static IEnumerator DelayDamageHero(DamageHero damageHero) { yield return (object)new WaitForSeconds(0.5f); damageHero.damageDealt = 1; } public static IEnumerator Delay(float delay) { yield return (object)new WaitForSeconds(delay); } public static IEnumerator RotateOverTime(GameObject ss, float duration) { float time = 0f; float goPosx = Extensions.GetPositionX(ss.transform); float goPosy = Extensions.GetPositionY(ss.transform); float goScalex = Extensions.GetScaleX(ss.transform); while (time < duration && !rotateDone) { time += Time.deltaTime; float caly = goPosy + 8f * ((0f - time) * time * time + 1.4f * time); ss.transform.localEulerAngles = new Vector3(0f, 0f, 1080f * SmoothFunction(time)); ss.transform.position = new Vector3(goPosx + time * 20f * (0f - goScalex), caly, 0.006f); if (time > 0.5f && willRotateDuringRS) { secondSentinel.SetState("Rising Slash"); willRotateDuringRS = false; yield return null; } if (time > 1f) { rotateDone = true; comboRSnotComboWS = Random.Range(0, 2) == 0; yield return null; } yield return null; } } public static IEnumerator MoveOverTime(GameObject ss, float duration) { float time = 0f; float goPosx = Extensions.GetPositionX(ss.transform); float goScalex = Extensions.GetScaleX(ss.transform); while (time < duration) { time += Time.deltaTime; if (goScalex < 0f) { float posx = goPosx + (49.5f - goPosx) * SmoothFunction(time * 2f); ss.transform.position = new Vector3(posx, 6.5f, 0.006f); yield return null; } else { float posx = goPosx + (29.5f - goPosx) * SmoothFunction(time * 2f); ss.transform.position = new Vector3(posx, 6.5f, 0.006f); yield return null; } } ss.transform.localEulerAngles = new Vector3(0f, 0f, 0f); } public static IEnumerator ChangePhase1(float delay) { yield return (object)new WaitForEndOfFrame(); secondSentinel.SetState("Sing"); isInPhase2 = true; } public static IEnumerator ChangePhase2(float delay) { yield return (object)new WaitForSeconds(delay); secondSentinel.SetState("Parry Stance"); } public static IEnumerator WallSideCombo(float delay) { float timer = 0f; yield return (object)new WaitForEndOfFrame(); float scalex = Extensions.GetScaleX(((Component)secondSentinel).transform); float posx = ((Component)secondSentinel).transform.position.x; float posy = ((Component)secondSentinel).transform.position.y; if (comboRSnotComboWS) { willRotateDuringRS = true; secondSentinel.SetState("Rising Slash Antic"); while (timer < 0.5f) { timer += Time.deltaTime; CalculatedMove(scalex, posx, 5.9213f, timer); yield return null; } yield break; } isComboTribleWS = true; secondSentinel.SetState("Windslash G"); WScount += 1f; while (timer < 0.5f && WScount < 4f) { timer += Time.deltaTime; CalculatedMove(scalex, posx, posy, timer); yield return null; } } public static IEnumerator WSRotateRoundabout(float duration, Transform transform, float rotateRadius, float willReverse) { float time = 0f; yield return (object)new WaitForSeconds(0.25f); float goPosx = Extensions.GetPositionX(transform); float goPosy = Extensions.GetPositionY(transform); while (time < duration) { float theta = (float)((double)(time * 2f) * Math.PI); time += Time.deltaTime; transform.position = new Vector3(goPosx - rotateRadius * (float)(Math.Sin(theta) * (double)willReverse), goPosy - rotateRadius * (float)Math.Cos(theta) + rotateRadius, 0f); transform.localEulerAngles = new Vector3(0f, 0f, time * 360f * (0f - willReverse)); yield return null; } } public static IEnumerator CSRotateRoundabout(float duration, Transform transform, float willReverse) { float time = 0f; while (time < duration) { time += Time.deltaTime; transform.localEulerAngles = new Vector3(0f, 0f, (32f - time * 180f) * willReverse); yield return null; } } public static IEnumerator WSSizeIncerease(float duration, Transform transform, float willReverse) { float time = 0f; while (time < duration) { time += Time.deltaTime; float calScale = time * 1.5f + 1f; transform.localScale = new Vector3(calScale * willReverse, calScale, 1f); yield return null; } yield return (object)new WaitForSeconds(0.5f); transform.localScale = new Vector3(5f * willReverse, 5f, 1f); } public static float SmoothFunction(float value) { return (float)(3.0 * Math.Pow(value, 2.0) - 2.0 * Math.Pow(value, 3.0)); } public static void CalculatedMove(float scalex, float posx, float posy, float timer) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (scalex > 0f) { ((Component)secondSentinel).transform.position = new Vector3(posx + (50f - posx) * SmoothFunction(timer * 2f), posy, 0.006f); } else { ((Component)secondSentinel).transform.position = new Vector3(posx + (29f - posx) * SmoothFunction(timer * 2f), posy, 0.006f); } } public static float SizeRatio(float value) { return 1f / 6f * value * value - 0.5f * value + 1.3333334f; } [HarmonyPatch(typeof(SpawnObjectFromGlobalPool), "OnEnter")] [HarmonyPostfix] private static void ObjectSettings(SpawnObjectFromGlobalPool __instance) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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) GameObject gameObject = __instance.storeObject.Value.gameObject; Transform transform = gameObject.transform; float scaleX = Extensions.GetScaleX(transform); float num = ((!(scaleX < 0f)) ? 1f : (-1f)); if (((Object)transform).name.StartsWith("Song Knight Projectile")) { float num2 = SizeRatio(WScount); transform.localScale = new Vector3(num2, num2, 0f); if (WScount == 1f && isInPhase2) { if (Extensions.GetPositionY(((Component)secondSentinel).transform) < 9f) { transform.localEulerAngles = Vector3.zero; ((MonoBehaviour)Instance).StartCoroutine(WSRotateRoundabout(1f, transform, 5f, Extensions.GetScaleX(((Component)secondSentinel).transform))); } else { ((MonoBehaviour)Instance).StartCoroutine(WSSizeIncerease(1f, transform, Extensions.GetScaleX(((Component)secondSentinel).transform))); } } if (WScount == 4f) { gameObject.GetComponent().damageDealt = 2; } else { gameObject.GetComponent().damageDealt = 1; } } if (((Object)transform).name.StartsWith("Song Knight CrossSlash") && bladeWillRotate) { transform.localEulerAngles = new Vector3(0f, 0f, 32f * num); float positionX = Extensions.GetPositionX(transform); float positionY = Extensions.GetPositionY(transform); transform.position = new Vector3(positionX + 0.33f * num, positionY + 0.86f, 0f); if (isInPhase2) { ((MonoBehaviour)Instance).StartCoroutine(CSRotateRoundabout(1f, transform, num)); } } else if (((Object)transform).name.StartsWith("Song Knight CrossSlash")) { transform.localEulerAngles = Vector3.zero; } } } }