using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Xml; using System.Xml.Serialization; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LLHandlers; using StageBackground; 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(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace BudgetStages; [HarmonyPatch(typeof(BG), "StartUp")] public class StartPatch { public static void Postfix() { Plugin.Log.LogInfo((object)QualitySettings.shadowDistance); Plugin.Log.LogInfo((object)BG.instance.fixedCamPosY); StageSwapper component = ((Component)BG.instance).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } ((Component)BG.instance).gameObject.AddComponent(); } } [HarmonyPatch(typeof(BG), "StartMatchIntro")] public class IntroCamPatch { public static void Prefix() { //IL_007b: 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) Plugin.Log.LogInfo((object)"Start match intro called!"); string text = ((object)Unsafe.As(ref JOMBNFKIHIC.GIGAKBJGFDI.OOEPDFABFIP)/*cast due to .constrained prefix*/).ToString().ToLower(); string path = Path.Combine(Plugin.bundleLocation.ToString(), text + ".xml"); StageSettings stageSettings = Plugin.LoadXML(path); if (stageSettings != null) { List list = new List(); CamShot[] shots = stageSettings.shots; foreach (CamShot camShot in shots) { list.Add(new IntroCamShot { StartPoint = Plugin.FromCamTransform(camShot.StartCam), EndPoint = Plugin.FromCamTransform(camShot.EndCam), Duration = camShot.Duration, isConstantSpeed = !camShot.Smooth }); } BG.instance.introCamShots = Enumerable.ToArray(list).ToArray(); } } } [BepInPlugin("com.github.janeriver.BudgetStages", "Budget Stages", "1.0.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static Plugin Instance; private static IDictionary StageBundles = new Dictionary(); public static string bundleLocation => Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "Bundles"); internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("Budget Stages"); val.PatchAll(); Log.LogInfo((object)bundleLocation); } private void Start() { ((MonoBehaviour)this).StartCoroutine(LoadSwaps()); } private unsafe IEnumerator LoadSwaps() { yield return (object)new WaitForSeconds(4f); if (StageHandler.stagesAll == null) { Log.LogError((object)"Stage handler wasn't loaded yet - please report this bug"); } foreach (Stage stage in StageHandler.stagesAll) { string stagePath = Path.Combine(bundleLocation, ((object)(*(Stage*)(&stage))/*cast due to .constrained prefix*/).ToString().ToLower()); if (File.Exists(stagePath)) { Log.LogInfo((object)("Loading assetbundle: " + stagePath)); AssetBundle bund = AssetBundle.LoadFromFile(stagePath); StageBundles[((object)(*(Stage*)(&stage))/*cast due to .constrained prefix*/).ToString()] = bund; } } } public static AssetBundle GetBundle(string name) { if (StageBundles.ContainsKey(name)) { return StageBundles[name]; } return null; } public static bool HasSwap(string name) { return StageBundles.ContainsKey(name); } public static StageSettings LoadXML(string path) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (File.Exists(path)) { XmlSerializer val = new XmlSerializer(typeof(StageSettings)); XmlReader val2 = XmlReader.Create(path); try { return (StageSettings)val.Deserialize(val2); } finally { ((IDisposable)val2)?.Dispose(); } } return null; } public static Transform FromCamTransform(CamTransform cam) { //IL_0012: 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_004e: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)cam.ToString()); Transform transform = new GameObject().transform; transform.localPosition = new Vector3(cam.x, cam.y, cam.z); transform.localEulerAngles = new Vector3(cam.rotX, cam.rotY, cam.rotZ); return transform; } } public static class PluginInfos { public const string PLUGIN_ID = "com.github.janeriver.BudgetStages"; public const string PLUGIN_NAME = "Budget Stages"; public const string PLUGIN_VERSION = "1.0.7"; } [Serializable] public class StageSettings { public int ShadowDistance; public float CameraPositionY; [XmlArray("NormalObjects")] [XmlArrayItem("string")] public string[] normal; [XmlArray("EclipseObjects")] [XmlArrayItem("string")] public string[] eclipse; [XmlArray("IntroCamShots")] [XmlArrayItem("CamShot")] public CamShot[] shots; } [Serializable] public class CamShot { public CamTransform StartCam; public CamTransform EndCam; public float Duration; public bool Smooth; } [Serializable] public class CamTransform { public float x; public float y; public float z; public float rotX; public float rotY; public float rotZ; public override string ToString() { return $"Pos({x},{y},{z}), Rot({rotX},{rotY},{rotZ})"; } } public class StageSwapper : MonoBehaviour { public AssetBundle sceneBundle; public string[] normalNames; public string[] eclipseNames; public CamShot[] camShots; public bool active = false; private void Start() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((int)DNPFJHMAIBP.HHMOGKIMBNM() == 21) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "title") { return; } ManualLogSource log = Plugin.Log; activeScene = SceneManager.GetActiveScene(); log.LogInfo((object)((Scene)(ref activeScene)).name); string text = ((object)Unsafe.As(ref JOMBNFKIHIC.GIGAKBJGFDI.OOEPDFABFIP)/*cast due to .constrained prefix*/).ToString(); sceneBundle = Plugin.GetBundle(text); if ((Object)(object)sceneBundle != (Object)null) { active = true; string path = Path.Combine(Plugin.bundleLocation.ToString(), text + ".xml"); StageSettings stageSettings = Plugin.LoadXML(path); if (stageSettings != null) { QualitySettings.shadowDistance = stageSettings.ShadowDistance; BG.instance.fixedCamPosY = stageSettings.CameraPositionY; BG.instance.maxPosY = BG.instance.fixedCamPosY + 0.5f; normalNames = stageSettings.normal; eclipseNames = stageSettings.eclipse; camShots = stageSettings.shots; } else { normalNames = new string[1] { "StageSwapperNormal" }; eclipseNames = new string[1] { "StageSwapperEclipse" }; } ((MonoBehaviour)this).StartCoroutine(ReplaceStage()); } else { QualitySettings.shadowDistance = 40f; } } private IEnumerator ReplaceStage() { yield return (object)new WaitForEndOfFrame(); BG.instance.obsEclipse = null; BG.instance.obsNormal = null; BG.instance.eclipseMaterials = null; BG.instance.replaceMaterials = null; BG.instance.eclipseColorRenderers = null; BG.instance.introCamShots = null; ((UnityEventBase)BG.instance.eclipseEvents).RemoveAllListeners(); ClearStage(GameObject.Find("Background")); ClearStage(GameObject.Find("Eclipse")); ClearStage(GameObject.Find("BGLayer2_Animated")); ClearStage(GameObject.Find("PedestriansLayer")); ClearStage(GameObject.Find("Blimp_Animated 1")); ClearStage(GameObject.Find("Blimp_Animated 2")); ClearStage(GameObject.Find("Blimp_Animated 3")); ((MonoBehaviour)this).StartCoroutine("ChangeShadowsPlane"); Plugin.Log.LogInfo((object)"Cleared stage objects"); string[] scenePath = sceneBundle.GetAllScenePaths(); SceneManager.LoadScene(scenePath[0], (LoadSceneMode)1); ((MonoBehaviour)this).StartCoroutine(SetupScene()); } private IEnumerator SetupScene() { yield return (object)new WaitForEndOfFrame(); List normal = new List(); List eclipse = new List(); string[] array = normalNames; foreach (string objName in array) { GameObject obj = GameObject.Find(objName); if ((Object)(object)obj == (Object)null) { Plugin.Log.LogWarning((object)("Could not find obj with name '" + objName + "' for normal objects")); } else { normal.Add(obj); } } string[] array2 = eclipseNames; foreach (string objName2 in array2) { GameObject obj2 = GameObject.Find(objName2); if ((Object)(object)obj2 == (Object)null) { Plugin.Log.LogWarning((object)("Could not find obj with name '" + objName2 + "' for eclipse objects")); } else { eclipse.Add(obj2); } } BG.instance.obsNormal = Enumerable.ToArray(normal); BG.instance.obsEclipse = Enumerable.ToArray(eclipse); Plugin.Log.LogInfo((object)(BG.instance.obsNormal.Length + " elements in normal")); Plugin.Log.LogInfo((object)(BG.instance.obsEclipse.Length + " elements in eclipse")); GameObject[] obsEclipse = BG.instance.obsEclipse; foreach (GameObject ele in obsEclipse) { ele.SetActive(false); } GameObject light = GameObject.Find("shadowCastLight"); light.GetComponent().shadows = (LightShadows)0; GameObject[] obsEclipse2 = BG.instance.obsEclipse; foreach (GameObject obj3 in obsEclipse2) { obj3.SetActive(false); } } private static void ClearStage(GameObject gameObject) { if (!((Object)(object)gameObject != (Object)null)) { return; } for (int i = 0; i < gameObject.transform.childCount; i++) { bool flag = ((Object)gameObject.transform.GetChild(i)).name.Contains("Positions"); bool flag2 = ((Object)gameObject.transform.GetChild(i)).name.Contains("Light"); if (!flag && !flag2) { ((Component)gameObject.transform.GetChild(i)).gameObject.SetActive(false); } } } private IEnumerator ChangeShadowsPlane() { yield return (object)new WaitForSeconds(0.1f); if (Object.op_Implicit((Object)(object)GameObject.Find("CustomReceiveShadowsPlane"))) { GameObject originalPlane = GameObject.Find("receiveShadowsPlane"); GameObject customPlane = GameObject.Find("CustomReceiveShadowsPlane"); originalPlane.GetComponent().mesh = customPlane.GetComponent().mesh; originalPlane.transform.position = customPlane.transform.position; originalPlane.transform.rotation = customPlane.transform.rotation; originalPlane.transform.localScale = customPlane.transform.localScale; customPlane.SetActive(false); } else { Plugin.Log.LogMessage((object)"There is no 'CustomReceiveShadowsPlane' gameObject in the scene, if it's intentional, ignore this message.\nIf you want to create a custom ReceiveShadowsPlane, please create a gameObject with the exact name 'CustomReceiveShadowsPlane'.\nAdd a MeshFilter Component on this gameObject and assign your mesh.\nMake sure to let this gameObject active before building your stage bundle."); } } }