using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameplayEntities; using HarmonyLib; using LLBML.Math; using LLBML.Utils; using LLHandlers; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("StageBlocks (us.wallace.plugins.llb.stageblocks)")] [assembly: AssemblyProduct("StageBlocks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.6.0")] [module: UnverifiableCode] namespace StageBlocks; [BepInPlugin("us.wallace.plugins.llb.stageblocks", "StageBlocks", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("LLBlaze.exe")] public class StageBlocks : BaseUnityPlugin { public static ConfigEntry customStageBlocks; public Dictionary> stageBlocks = new Dictionary>(); private const string CONFIG_HEADER = "# The format is : , , , ; #\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\n"; private const string DEFAULT_CONFIG = "Outskirts: -625, 205, 250, 54; #070B12FF\nOutskirts: 375, 205, 250, 54; #231E30FF\nSewers: -66, 285, 132, 290 ; #7E0C8555\nDesert: -65, 193, 630, 54 ; #393521FF\nElevator: -740, -4, 280, 190 ; #000000FF\nElevator: 460, -4, 280, 190 ; #0000000FF\nFactory: -670, 350, 350, 200 ; #322E3655\nFactory: 425, -8, 350, 200 ; #91663055\nSubway: -425, -10, 250, 120 ; #B04E2B77\nSubway: 135, -10, 250, 120 ; #B04E2B77\nStadium: -356, 211.5, 82, 57 ; #B4DED277\nStadium: 274, 211.5, 82, 57 ; #B4DED277\nStreets: -410, 215, 300, 54 ; #C45B2477\nStreets: 110, 215, 300, 54 ; #C45B2477\nPool: -310.5, 193, 621, 54 ; #4D3A1E77\nRoom21: 391.5, -1, 231, 186 ; #000000FF\nRoom21: -370, 205, 280, 54 ; #000000FF\nRetro Factory: -1628, -200, 1415.75, 10000; #FF0000\nRetro Factory: 203.5, -200, 10000, 10000; #FF0000\nRetro Factory: -2000, -100, 10000, 250; #FF0000\nRetro Factory: -2000, 566, 10000, 200; #FF0000\n"; private static readonly Dictionary allStagesMapping = StringUtils.regularStagesNames.Union(StringUtils.retroStagesNames).ToDictionary((KeyValuePair x) => x.Key, (KeyValuePair x) => x.Value); private static readonly Dictionary reverseStageMapping = allStagesMapping.ToDictionary((KeyValuePair x) => x.Value, (KeyValuePair x) => x.Key); public static ManualLogSource Log { get; private set; } = null; public static StageBlocks Instance { get; private set; } public string BlocksConfigPath => Path.Combine(ModdingFolder.GetModSubFolder(((BaseUnityPlugin)this).Info).FullName, "BlockConfig.txt"); private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Instance = this; ((BaseUnityPlugin)this).Config.Bind("Use Custom Stage Blocks", "mm_header_qol", "Use Custom Stage Blocks", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" })); customStageBlocks = ((BaseUnityPlugin)this).Config.Bind("StageBlocksToggle", "enableCustomStageBlocks", true, (ConfigDescription)null); ((BaseUnityPlugin)this).Logger.LogDebug((object)"liuberal poop hippie pronoun fortnite be farting pooping bacon epic, i love ivermectin flouride apartmentism"); Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); val.PatchAll(typeof(WorldSetStageDimensionsPatch)); val.PatchAll(typeof(NitroStuckFix)); ((BaseUnityPlugin)this).Logger.LogDebug((object)(((BaseUnityPlugin)this).Info.Metadata.Name + " is loaded")); } private void Start() { ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, (List)null); LoadConfig(); } private void CreateConfig() { using TextWriter textWriter = File.CreateText(BlocksConfigPath); textWriter.Write("# The format is : , , , ; #\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\nOutskirts: -625, 205, 250, 54; #070B12FF\nOutskirts: 375, 205, 250, 54; #231E30FF\nSewers: -66, 285, 132, 290 ; #7E0C8555\nDesert: -65, 193, 630, 54 ; #393521FF\nElevator: -740, -4, 280, 190 ; #000000FF\nElevator: 460, -4, 280, 190 ; #0000000FF\nFactory: -670, 350, 350, 200 ; #322E3655\nFactory: 425, -8, 350, 200 ; #91663055\nSubway: -425, -10, 250, 120 ; #B04E2B77\nSubway: 135, -10, 250, 120 ; #B04E2B77\nStadium: -356, 211.5, 82, 57 ; #B4DED277\nStadium: 274, 211.5, 82, 57 ; #B4DED277\nStreets: -410, 215, 300, 54 ; #C45B2477\nStreets: 110, 215, 300, 54 ; #C45B2477\nPool: -310.5, 193, 621, 54 ; #4D3A1E77\nRoom21: 391.5, -1, 231, 186 ; #000000FF\nRoom21: -370, 205, 280, 54 ; #000000FF\nRetro Factory: -1628, -200, 1415.75, 10000; #FF0000\nRetro Factory: 203.5, -200, 10000, 10000; #FF0000\nRetro Factory: -2000, -100, 10000, 250; #FF0000\nRetro Factory: -2000, 566, 10000, 200; #FF0000\n"); } public void LoadConfig() { if (!File.Exists(BlocksConfigPath)) { CreateConfig(); } using TextReader reader = File.OpenText(BlocksConfigPath); ReadConfig(reader, stageBlocks); } public void WriteConfig(TextWriter writer, Dictionary> config) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) writer.Write("# The format is : , , , ; #\n# One block per line, '#' is a comment line.\n# stage xy origin is bottom center of the stage\n# block xy origin is bottom left of the block\n# Refer to readme for stage names (case sensitive)\n"); foreach (Stage key in config.Keys) { foreach (StageBlock item in config[key]) { writer.WriteLine(allStagesMapping[key] + ": " + item.ToString()); } } } public void ReadConfig(TextReader reader, Dictionary> config) { //IL_0068: 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_0078: 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) config.Clear(); while (reader.Peek() >= 0) { string text = reader.ReadLine(); try { if (text[0] == '#') { continue; } string[] array = text.Split(new char[1] { ':' }); if (!reverseStageMapping.ContainsKey(array[0])) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Unknown stage name: " + array[0])); continue; } Stage key = reverseStageMapping[array[0]]; if (!config.ContainsKey(key)) { config.Add(key, new List()); } try { config[key].Add(StageBlock.FromString(array[1])); } catch (FormatException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Couldn't convert floats from line \"" + text + "\" \n" + ex)); } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Couldn't parse data from line \"" + text + "\" \n" + ex2)); } } } } public static class PluginInfos { public const string PLUGIN_NAME = "StageBlocks"; public const string PLUGIN_ID = "us.wallace.plugins.llb.stageblocks"; public const string PLUGIN_VERSION = "1.0.6"; } internal class NitroStuckFix { [HarmonyTranspiler] [HarmonyPatch(typeof(BallEntity), "UpdateState", new Type[] { })] public static IEnumerable UpdateState_Transpiler(IEnumerable instructions, ILGenerator iL) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, iL); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloc_3, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null) }); try { val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), Transpilers.EmitDelegate>((Action)delegate(BallEntity __instance) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) PlayerEntity playerEntity = PlayerHandler.instance.GetPlayerEntity(((GetHitBallEntity)__instance).ballData.cuffBallOwner); CopPlayer val2 = (CopPlayer)(object)((playerEntity is CopPlayer) ? playerEntity : null); if (((MovableData)((AbilityEntity)val2).abilityData).abilityState == "CUFF_HOOKSHOT" && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.GCPKPHMKLBN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m)) && HHBCPNCDNDH.HPLPMEAOJPM(HHBCPNCDNDH.NPDCPLFLLIG(((EntityData)((MovableEntity)val2).moveableData).velocity.CGJJEHPPOAN), HHBCPNCDNDH.NKKIFJJEPOL(0.5m))) { ((MovableEntity)val2).SetAbilityState("CUFF_NEUTRAL_STAY"); ((AnimatableEntity)val2).PlayAnim("cuffPull", "main"); ((AbilityEntity)val2).abilityData.specialHeading = (Side)5; ((EntityData)((PlayerEntity)val2).playerData).velocity = IBGCBLLKIHA.GCPFGINDGEM(); ((HittingEntity)val2).GiveBall((BallState)22, __instance, false); } }) }); } catch (Exception ex) { StageBlocks.Log.LogInfo((object)ex); } return val.InstructionEnumeration(); } } internal class WorldSetStageDimensionsPatch { [HarmonyPatch(typeof(World), "SetStageDimensions")] [HarmonyPostfix] public static void SetStageDimensions_Postfix(World __instance) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_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_00a2: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if (!StageBlocks.customStageBlocks.Value || __instance.useStageBlocks) { return; } StageBlocks.Instance.LoadConfig(); if (!StageBlocks.Instance.stageBlocks.ContainsKey(StageHandler.curStage)) { return; } foreach (StageBlock item in StageBlocks.Instance.stageBlocks[StageHandler.curStage]) { Rect box = item.box; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); obj.transform.rotation = Quaternion.identity; obj.transform.position = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).center.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).center.y) * Floatf.op_Implicit(World.FPIXEL_SIZE))); obj.transform.localScale = new Vector3(Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).size.x) * Floatf.op_Implicit(World.FPIXEL_SIZE)), Floatf.op_Implicit(Floatf.op_Implicit(((Rect)(ref box)).size.y) * Floatf.op_Implicit(World.FPIXEL_SIZE)), 1f); Renderer component = obj.GetComponent(); component.material.color = item.color; component.material.EnableKeyword("_EMISSION"); component.material.SetColor("_EmissionColor", item.color * ((float)(int)item.emission / 128f)); __instance.stageBlockList.Add(Boundsf.op_Implicit(new Boundsf(new Vector2f(Floatf.op_Implicit(((Rect)(ref box)).center.x), Floatf.op_Implicit(((Rect)(ref box)).center.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE), new Vector2f(Floatf.op_Implicit(((Rect)(ref box)).size.x), Floatf.op_Implicit(((Rect)(ref box)).size.y)) * Floatf.op_Implicit(World.FPIXEL_SIZE)))); } } } public struct StageBlock { public const float emissionMultiplier = 128f; public Rect box; public Color color; public byte emission; public StageBlock(Rect block, Color? color = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) box = block; this.color = (Color)(((??)color) ?? Color.clear); emission = Convert.ToByte(this.color.a * 255f); this.color.a = 1f; } public static implicit operator StageBlock(Rect a) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new StageBlock(a); } public override string ToString() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_005e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) string text = ""; text = text + ((Rect)(ref box)).position.x + ", " + ((Rect)(ref box)).position.y + ", " + ((Rect)(ref box)).size.x + ", " + ((Rect)(ref box)).size.y; text = text + " ; #" + ColorUtility.ToHtmlStringRGB(color); return text + StringUtils.BytesToHexString(new byte[1] { emission }); } public static StageBlock FromString(string data) { //IL_00b8: 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_00ab: 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) string[] array = data.Split(new char[1] { ';' }); string[] array2 = array[0].Split(new char[1] { ',' }); Rect block = default(Rect); ((Rect)(ref block))..ctor(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]), float.Parse(array2[3])); if (array.Length > 1) { string text = array[1].Replace(" ", ""); text = ((text[0] == '#') ? text : ("#" + text)); Color value = default(Color); if (!ColorUtility.TryParseHtmlString(text, ref value)) { StageBlocks.Log.LogWarning((object)"Failed to load colour. Is it in the right format? e.g. #1a1a22"); return new StageBlock(block); } return new StageBlock(block, value); } return new StageBlock(block); } }