using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using BitCode.AssetManagement;
using BroMakerLib.Abilities;
using BroMakerLib.Attributes;
using BroMakerLib.CustomObjects;
using BroMakerLib.CustomObjects.Bros;
using BroMakerLib.CustomObjects.Projectiles;
using BroMakerLib.Cutscenes;
using BroMakerLib.Infos;
using BroMakerLib.Loaders;
using BroMakerLib.Loggers;
using BroMakerLib.Menus;
using BroMakerLib.Storages;
using BroMakerLib.Triggers;
using BroMakerLib.Unlocks;
using HarmonyLib;
using Networking;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RocketLib;
using RocketLib.CustomTriggers;
using RocketLib.JsonConverters;
using RocketLib.Menus.Core;
using RocketLib.Menus.Elements;
using RocketLib.Menus.Layout;
using RocketLib.Utils;
using TFBGames.Management.Asset;
using TFBGames.Systems;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityModManagerNet;
using World.Generation.MapGenV4;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BroMakerLib")]
[assembly: AssemblyCompany("Gorzontrok")]
[assembly: AssemblyProduct("BroMakerLib")]
[assembly: AssemblyCopyright("Copyright © Gorzontrok 2023")]
[assembly: ComVisible(false)]
[assembly: Guid("1d628cee-72b0-4318-b136-aa16203256ff")]
[assembly: AssemblyFileVersion("2.6.0")]
[assembly: InternalsVisibleTo("BroMakerLib.UnityMod")]
[assembly: InternalsVisibleTo("BroMakerLib.Editor")]
[assembly: AssemblyVersion("2.6.0.0")]
namespace BroMakerLib
{
public class HeroPresetAttribute : CustomObjectPresetAttribute
{
public HeroType baseType;
public HeroPresetAttribute(string name, HeroType baseType = 0)
: base(name)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Invalid comparison between Unknown and I4
//IL_0037: 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)
if ((int)baseType == -1 || (int)baseType == 1000 || (int)baseType == 1500 || (int)baseType == 52)
{
throw new Exception($"Can't assign HeroType of type {baseType}");
}
this.baseType = baseType;
}
}
public static class BroMaker
{
internal static Harmony harmony;
private static bool _hasInit;
public static void Initialize()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (!_hasInit)
{
BMLogger.Log("Initialization of BroMaker", (LogType)3);
harmony = new Harmony("BroMakerLib");
harmony.PatchAll(Assembly.GetExecutingAssembly());
Settings.Load();
DirectoriesManager.Initialize();
BroMakerStorage.Initialize();
PresetManager.Initialize();
if (harmony != null)
{
ApplyBroPatches(harmony);
}
CustomTriggerManager.RegisterCustomTrigger(typeof(ForceBroAction), typeof(ForceBroActionInfo), "BroMaker - Force Custom Bro", "Custom Bros", 10);
CustomTriggerManager.RegisterCustomTrigger(typeof(HeroUnlockCutsceneAction), typeof(HeroUnlockCutsceneActionInfo), "BroMaker - Play Custom Bro Cutscene", "Custom Bros", 9);
_hasInit = true;
BMLogger.Log("Finish Initialization", (LogType)3);
}
}
public static void ApplyBroPatches(Harmony harmony)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
GameObject val = new GameObject();
val.SetActive(false);
foreach (KeyValuePair<string, Type> item in PresetManager.heroesPreset)
{
if (typeof(CustomHero).IsAssignableFrom(item.Value))
{
CustomHero customHero = val.AddComponent(item.Value) as CustomHero;
customHero.HarmonyPatches(harmony);
customHero.RegisterCustomTriggers();
}
}
}
public static void PreloadBroAssets()
{
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Expected O, but got Unknown
for (int i = 0; i < BroMakerStorage.Bros.Length; i++)
{
CustomBroInfo info = BroMakerStorage.Bros[i].GetInfo();
List<string> list = new List<string>();
List<string> list2 = new List<string>();
if (info.parameters.ContainsKey("Sprite"))
{
if (info.parameters["Sprite"] is string item)
{
list.Add(item);
}
else
{
object obj = info.parameters["Sprite"];
JArray val = (JArray)((obj is JArray) ? obj : null);
if (val != null)
{
foreach (JToken item6 in val)
{
string text = item6.ToObject<string>();
if (!string.IsNullOrEmpty(text))
{
list.Add(text);
}
}
}
}
}
if (info.parameters.ContainsKey("GunSprite"))
{
if (info.parameters["GunSprite"] is string item2)
{
list.Add(item2);
}
else
{
object obj2 = info.parameters["GunSprite"];
JArray val2 = (JArray)((obj2 is JArray) ? obj2 : null);
if (val2 != null)
{
foreach (JToken item7 in val2)
{
string text2 = item7.ToObject<string>();
if (!string.IsNullOrEmpty(text2))
{
list.Add(text2);
}
}
}
}
}
if (info.parameters.ContainsKey("SpecialIcons"))
{
if (info.parameters["SpecialIcons"] is string item3)
{
list.Add(item3);
}
else
{
object obj3 = info.parameters["SpecialIcons"];
JArray val3 = (JArray)((obj3 is JArray) ? obj3 : null);
if (val3 != null)
{
foreach (JToken item8 in val3)
{
JArray val4 = (JArray)(object)((item8 is JArray) ? item8 : null);
if (val4 != null)
{
foreach (JToken item9 in val4)
{
string text3 = item9.ToObject<string>();
if (!string.IsNullOrEmpty(text3))
{
list.Add(text3);
}
}
}
else
{
string text4 = item8.ToObject<string>();
if (!string.IsNullOrEmpty(text4))
{
list.Add(text4);
}
}
}
}
}
}
if (info.parameters.ContainsKey("Avatar"))
{
if (info.parameters["Avatar"] is string item4)
{
list.Add(item4);
}
else
{
object obj4 = info.parameters["Avatar"];
JArray val5 = (JArray)((obj4 is JArray) ? obj4 : null);
if (val5 != null)
{
foreach (JToken item10 in val5)
{
string text5 = item10.ToObject<string>();
if (!string.IsNullOrEmpty(text5))
{
list.Add(text5);
}
}
}
}
}
if (info.parameters.ContainsKey("SpecialMaterials"))
{
object obj5 = info.parameters["SpecialMaterials"];
JArray val6 = (JArray)((obj5 is JArray) ? obj5 : null);
if (val6 != null)
{
foreach (JToken item11 in val6)
{
JArray val7 = (JArray)(object)((item11 is JArray) ? item11 : null);
if (val7 != null)
{
foreach (JToken item12 in val7)
{
string text6 = item12.ToObject<string>();
if (!string.IsNullOrEmpty(text6))
{
list.Add(text6);
}
}
}
else
{
string text7 = item11.ToObject<string>();
if (!string.IsNullOrEmpty(text7))
{
list.Add(text7);
}
}
}
}
}
if (info.parameters.ContainsKey("FirstAvatar"))
{
if (info.parameters["FirstAvatar"] is string item5)
{
list.Add(item5);
}
else
{
object obj6 = info.parameters["FirstAvatar"];
JArray val8 = (JArray)((obj6 is JArray) ? obj6 : null);
if (val8 != null)
{
foreach (JToken item13 in val8)
{
string text8 = item13.ToObject<string>();
if (!string.IsNullOrEmpty(text8))
{
list.Add(text8);
}
}
}
}
}
foreach (CustomIntroCutscene item14 in info.Cutscene)
{
if (item14.spritePath != string.Empty)
{
list.Add(item14.spritePath);
}
if (item14.barkPath != string.Empty)
{
list2.Add(item14.barkPath);
}
if (item14.fanfarePath != string.Empty)
{
list2.Add(item14.fanfarePath);
}
}
CustomHero.PreloadSprites(info.path, list);
CustomHero.PreloadSounds(info.path, list2);
}
GameObject val9 = new GameObject();
val9.SetActive(false);
foreach (KeyValuePair<string, Type> item15 in PresetManager.heroesPreset)
{
if (!typeof(CustomHero).IsAssignableFrom(item15.Value))
{
continue;
}
try
{
CustomHero customHero = val9.AddComponent(item15.Value) as CustomHero;
try
{
customHero.AssignDirectoryPaths(BroMakerStorage.GetStoredHeroByCustomHeroType(item15.Value).GetInfo().path);
}
catch
{
}
customHero.PreloadAssets();
}
catch (Exception exception)
{
BMLogger.ExceptionLog("Exception occurred while preloading " + item15.Key + "'s assets:", exception);
}
}
}
public static void ReloadFiles()
{
BroMakerStorage.Initialize();
}
}
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class CustomObjectPresetAttribute : Attribute
{
public string name;
public CustomObjectPresetAttribute(string name)
{
this.name = name;
}
}
public static class BroMakerUtilities
{
public static T GetVariantValue<T>(List<T> list, int variantIndex)
{
if (list == null || list.Count == 0)
{
return default(T);
}
if (list.Count == 1)
{
return list[0];
}
if (variantIndex < list.Count)
{
return list[variantIndex];
}
return list[0];
}
public static bool IsBoss(Unit unit)
{
if (!((Component)unit).CompareTag("Boss") && !(unit is DolphLundrenSoldier) && !(unit is SatanMiniboss) && (!(unit is AlienSandWorm) || unit is AlienWormFacehuggerLauncher) && !(unit is TankBig) && !(unit is Mookopter) && !(unit is GoliathMech))
{
return unit is MechWeapon;
}
return true;
}
public static void SetSpecialMaterials(int playerNum, List<Material> specialMaterials, Vector2 offset, float spacing)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_001e: 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)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
PlayerHUD hud = HeroController.players[playerNum].hud;
for (int i = 0; i < hud.grenadeIcons.Length; i++)
{
if (playerNum % 2 == 0)
{
((SpriteBase)hud.grenadeIcons[i]).SetOffset(new Vector3(offset.x + (float)i * spacing, offset.y, 0f));
}
else
{
((SpriteBase)hud.grenadeIcons[i]).SetOffset(new Vector3(-1f * (offset.x + (float)i * spacing), offset.y, 0f));
}
}
if (specialMaterials == null)
{
return;
}
if (specialMaterials.Count() > 1)
{
for (int j = 0; j < specialMaterials.Count(); j++)
{
((Component)hud.grenadeIcons[j]).GetComponent<Renderer>().material = specialMaterials[j];
}
}
else if (specialMaterials.Count() > 0)
{
for (int k = 0; k < hud.grenadeIcons.Count(); k++)
{
((Component)hud.grenadeIcons[k]).GetComponent<Renderer>().material = specialMaterials[0];
}
}
}
public static void SetSpecialMaterials(int playerNum, Material specialMaterial, Vector2 offset, float spacing)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_001e: 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)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
PlayerHUD hud = HeroController.players[playerNum].hud;
for (int i = 0; i < hud.grenadeIcons.Length; i++)
{
if (playerNum % 2 == 0)
{
((SpriteBase)hud.grenadeIcons[i]).SetOffset(new Vector3(offset.x + (float)i * spacing, offset.y, 0f));
}
else
{
((SpriteBase)hud.grenadeIcons[i]).SetOffset(new Vector3(-1f * (offset.x + (float)i * spacing), offset.y, 0f));
}
}
if ((Object)(object)specialMaterial != (Object)null)
{
for (int j = 0; j < hud.grenadeIcons.Count(); j++)
{
((Component)hud.grenadeIcons[j]).GetComponent<Renderer>().material = specialMaterial;
}
}
}
public static Gib CreateGibPrefab(string name, Vector2 lowerLeftPixel, Vector2 pixelDimensions, float spriteWidth, float spriteHeight, Vector3 spriteOffset, Vector3 localPositionOffset, bool doesRotate, DoodadGibsType gibType, float size = 3f, bool hasBloodTrail = true, BloodColor color = 3, float bloodyM = 1f, bool shrink = false, int rotateFrames = 8, bool rotateAtRightAngles = false, bool hasSmokeTrail = false, int smokeTrailBounces = 3, float forceMultiplier = 1f, float startLife = 1f, float lifeM = 1f, float randomLifeM = 1f, float r = 0f, float rotationSpeedMultiplier = 1f, float bounceM = 0.4f, float frictionM = 0.5f, float drag = 0f, bool randomiseGravityM = false, float gravityMrandomRange = 0.1f, AudioClip[] fallHitSound = null, bool isOnFire = false)
{
//IL_003b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_0062: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_018b: Unknown result type (might be due to invalid IL or missing references)
Gib component = new GameObject(name, new Type[4]
{
typeof(MeshFilter),
typeof(MeshRenderer),
typeof(SpriteSM),
typeof(Gib)
}).GetComponent<Gib>();
SpriteSM component2 = ((Component)component).gameObject.GetComponent<SpriteSM>();
((SpriteBase)component2).plane = (SPRITE_PLANE)0;
component2.lowerLeftPixel = lowerLeftPixel;
component2.pixelDimensions = pixelDimensions;
((SpriteBase)component2).offset = spriteOffset;
((SpriteBase)component2).width = spriteWidth;
((SpriteBase)component2).height = spriteHeight;
Traverse val = Traverse.Create((object)component);
HarmonyExtensions.SetFieldValue<Vector2>((object)val, "lowerLeftPixel", lowerLeftPixel);
HarmonyExtensions.SetFieldValue<Vector2>((object)val, "pixelDimensions", pixelDimensions);
((Component)component).transform.localPosition = localPositionOffset;
component.doesRotate = doesRotate;
component.gibType = gibType;
((Shrapnel)component).size = size;
((BloodyShrapnel)component).hasBloodTrail = hasBloodTrail;
((BloodyShrapnel)component).color = color;
((BloodyShrapnel)component).bloodyM = bloodyM;
((Shrapnel)component).shrink = shrink;
component.rotateFrames = rotateFrames;
((Shrapnel)component).rotateAtRightAngles = rotateAtRightAngles;
component.hasSmokeTrail = hasSmokeTrail;
HarmonyExtensions.SetFieldValue<int>((object)val, "smokeTrailBounces", smokeTrailBounces);
component.forceMultiplier = forceMultiplier;
HarmonyExtensions.SetFieldValue<float>((object)val, "startLife", startLife);
((Shrapnel)component).lifeM = lifeM;
((Shrapnel)component).randomLifeM = randomLifeM;
((Shrapnel)component).r = r;
((Shrapnel)component).rotationSpeedMultiplier = rotationSpeedMultiplier;
((Shrapnel)component).bounceM = bounceM;
((Shrapnel)component).frictionM = frictionM;
((Shrapnel)component).drag = drag;
component.randomiseGravityM = randomiseGravityM;
component.gravityMrandomRange = gravityMrandomRange;
if (fallHitSound != null)
{
component.soundHolder = new GameObject(name + "soundHolder", new Type[1] { typeof(SoundHolder) }).GetComponent<SoundHolder>();
component.soundHolder.fallHitSound = fallHitSound;
}
component.isOnFire = isOnFire;
return component;
}
}
public class CutsceneSpriteAnimatedJsonConverter : JsonConverter
{
private class CutsceneSpriteAnimated
{
public float FrameRate;
public float TotalFrames;
public float FrameWidth;
public Vector3 ToVector3()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(FrameRate, TotalFrames, FrameWidth);
}
}
public override bool CanConvert(Type objectType)
{
if ((object)objectType == typeof(Vector3))
{
return true;
}
return false;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//IL_0009: 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)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_0063: 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)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
object obj = serializer.Deserialize(reader);
Vector3 val = Vector3.zero;
try
{
val = JsonConvert.DeserializeObject<CutsceneSpriteAnimated>(obj.ToString()).ToVector3();
}
catch (Exception exception)
{
BMLogger.ExceptionLog("'spriteAnimRateFramesWidth' Cant convert to 'CutsceneSpriteAnimated'", exception);
}
if (val != Vector3.zero)
{
return val;
}
try
{
val = JsonConvert.DeserializeObject<Vector3>(obj.ToString());
}
catch (Exception exception2)
{
BMLogger.ExceptionLog("'spriteAnimRateFramesWidth' Cant convert to Vector3", exception2);
}
return val;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
//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_0019: 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_0047: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (Vector3)value;
writer.WriteStartObject();
writer.WritePropertyName("FrameRate");
writer.WriteValue(val.x);
writer.WritePropertyName("TotalFrames");
writer.WriteValue(val.y);
writer.WritePropertyName("FrameWidth");
writer.WriteValue(val.z);
writer.WriteEndObject();
}
}
internal static class Main
{
public static ModEntry mod;
public static bool enabled;
private static bool Load(ModEntry modEntry)
{
mod = modEntry;
modEntry.OnGUI = OnGUI;
modEntry.OnToggle = OnToggle;
modEntry.OnSaveGUI = OnSaveGUI;
modEntry.OnUnload = OnUnload;
modEntry.Info.DisplayName = "<color=\"#d68c16\">BroMaker Unity</color>";
try
{
BroMaker.Initialize();
BroUnlockManager.Initialize();
BroMaker.PreloadBroAssets();
}
catch (Exception ex)
{
Log("Error while loading BroMaker.\n" + ex);
}
try
{
ModUI.Initialize();
}
catch (Exception ex2)
{
Log("Error while intializing the GUI.\n" + ex2);
}
try
{
MenuRegistry.RegisterAction("CUSTOM BROS", (Action<Menu>)delegate(Menu menu)
{
CustomBrosGridMenu.Show(menu);
}, (TargetMenu)0, (PositionMode)2, "START", 100, (Func<Menu, bool>)null);
}
catch (Exception ex3)
{
Log("Error while registering Custom Bros menu.\n" + ex3);
}
for (int i = 0; i < BMLogger.logs.Count; i++)
{
Log(BMLogger.logs[i], "[BroMakerLib]");
}
return true;
}
private static void OnGUI(ModEntry modEntry)
{
try
{
ModUI.UI();
}
catch (Exception ex)
{
Log("UI\n" + ex);
}
}
private static bool OnToggle(ModEntry modEntry, bool value)
{
enabled = value;
return true;
}
private static bool OnUnload(ModEntry modEntry)
{
BroUnlockManager.OnModUnload();
return true;
}
public static void Log(object str)
{
mod.Logger.Log(str.ToString());
}
public static void Log(object str, string prefix)
{
Logger.Log(str.ToString(), prefix);
}
private static void OnSaveGUI(ModEntry modEntry)
{
SaveAll();
}
public static void SaveAll()
{
CustomHero.SaveAll();
Settings.instance.Save();
BroUnlockManager.SaveProgressData();
}
}
internal static class ModUI
{
private static readonly Dictionary<string, Action> _tabs = new Dictionary<string, Action>
{
{ "Custom Bros", Spawner },
{ "Settings", Settings }
};
private static int selectedPlayerNum = 0;
private static object _objectToEdit = null;
private static GUIStyle _toolTipStyle = new GUIStyle();
private static int _tabSelected = 0;
private static readonly GUIStyle _errorSwapingMessageStyle = new GUIStyle();
private static Rect _toolTipRect = Rect.zero;
private static int _selectedCustomBrosIndex = -1;
private static int _selectedModIndex = -1;
private static StoredHero _selectedBro;
private static CustomHero _selectedHero;
private static GameObject heroHolder;
private static bool heroCreated = false;
private static Vector2 _spawnerScrollView;
private static readonly int _broPerLines = 6;
private static GUIStyle _buttonStyle = null;
private static GUIStyle _warningStyle = null;
private static GUIStyle _incompatibleStyle = null;
private static GUIStyle _enabledStyle = null;
private static GUIStyle _disabledStyle = null;
private static GUIStyle _enabledStyleButton = null;
private static GUIStyle _disabledStyleButton = null;
private static GUIStyle _headerStyle;
private static float _windowWidth = -1f;
public static List<BroMakerMod> Mods => BroMakerStorage.mods;
public static List<BroMakerMod> IncompatibleMods => BroMakerStorage.incompatibleMods;
public static void Initialize()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0038: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
_errorSwapingMessageStyle.normal.textColor = Color.yellow;
_errorSwapingMessageStyle.alignment = (TextAnchor)4;
_toolTipStyle = new GUIStyle
{
fontStyle = (FontStyle)1,
fontSize = 15
};
_toolTipStyle.normal.textColor = Color.white;
BroSpawnManager.CheckForDeletedBros();
}
public static void UI()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_003d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00b8: 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)
//IL_00dd: Expected O, but got Unknown
//IL_00e7: 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)
//IL_010c: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: 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_01e2: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
if (_windowWidth < 0f)
{
try
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if ((int)Event.current.type == 7)
{
Rect rect = GUILayoutUtility.GetRect(0f, 0f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if (((Rect)(ref rect)).width > 1f)
{
_windowWidth = ((Rect)(ref rect)).width;
}
}
GUILayout.Label(" ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.EndHorizontal();
return;
}
catch (Exception)
{
return;
}
}
if (_buttonStyle == null)
{
_buttonStyle = new GUIStyle(GUI.skin.button);
}
if (_warningStyle == null)
{
_warningStyle = new GUIStyle(GUI.skin.label);
_warningStyle.normal.textColor = Color.yellow;
}
if (_incompatibleStyle == null)
{
_incompatibleStyle = new GUIStyle(GUI.skin.label);
_incompatibleStyle.normal.textColor = Color.red;
}
if (_headerStyle == null)
{
_headerStyle = new GUIStyle(GUI.skin.button);
_headerStyle.fontStyle = (FontStyle)1;
_headerStyle.normal.textColor = new Color(0.639216f, 0.909804f, 1f);
}
if (_enabledStyle == null)
{
_enabledStyle = new GUIStyle(GUI.skin.label);
_enabledStyle.normal.textColor = Color.green;
}
if (_disabledStyle == null)
{
_disabledStyle = new GUIStyle(GUI.skin.label);
_disabledStyle.normal.textColor = Color.red;
}
if (_enabledStyleButton == null)
{
_enabledStyleButton = new GUIStyle(GUI.skin.button);
_enabledStyleButton.normal.textColor = Color.green;
}
if (_disabledStyleButton == null)
{
_disabledStyleButton = new GUIStyle(GUI.skin.button);
_disabledStyleButton.normal.textColor = Color.red;
}
string[] array = _tabs.Keys.ToArray();
_tabSelected = GUILayout.SelectionGrid(_tabSelected, array, 4, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(15f);
_toolTipRect = GUILayoutUtility.GetLastRect();
GUILayout.Space(10f);
GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
_tabs.TryGetValue(array[_tabSelected], out var value);
value();
GUILayout.EndVertical();
if (!BroMakerLib.Settings.instance.disableTooltips)
{
GUI.Label(_toolTipRect, GUI.tooltip, _toolTipStyle);
}
}
private static GUILayoutOption ScaledWidth(float width)
{
return GUILayout.Width(width * CalculateWidthScaleFactor());
}
private static void ScaledWidthSpace(float width)
{
GUILayout.Space(width * CalculateWidthScaleFactor());
}
private static float CalculateWidthScaleFactor()
{
if (BroMakerLib.Settings.instance.scaleUIWithWindowWidth && _windowWidth > 0f)
{
return _windowWidth / 1200f;
}
return 1f;
}
public static void Spawner()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_0202: 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_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0639: Unknown result type (might be due to invalid IL or missing references)
//IL_0656: Expected O, but got Unknown
//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
//IL_06ea: Expected O, but got Unknown
GUILayout.Label(BMLogger.errorSwapingMessage, _errorSwapingMessageStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (BroMakerLib.Settings.instance.developerMode)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button(new GUIContent("Reload Mods", "Reloads all BroMaker mods"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
BroMakerStorage.Initialize();
}
if (GUILayout.Button(new GUIContent("Reload Bros", "Reloads all custom bros in the currently loaded BroMaker mods"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
ReloadFiles();
PresetManager.disableWarnings = true;
PresetManager.Initialize();
PresetManager.disableWarnings = false;
BroSpawnManager.CheckForDeletedBros();
}
if (GUILayout.Button(new GUIContent("Reload Preset", "Reloads custom bro presets"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
PresetManager.Initialize();
}
GUILayout.EndHorizontal();
GUILayout.Space(15f);
}
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (Mods.Count <= 0 && IncompatibleMods.Count <= 0)
{
GUILayout.Label("No mods installed.", (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.EndVertical();
return;
}
GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Label("Name", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(150f) });
ScaledWidthSpace(50f);
GUILayout.Label("Author", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label("Version", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label("BroMaker Version", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label("Autospawn Enabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label("Unlock Status", (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.EndHorizontal();
GUILayout.Space(15f);
if (Mods.Count > 8 && !BroMakerLib.Settings.instance.scaleUIHeight)
{
_spawnerScrollView = GUILayout.BeginScrollView(_spawnerScrollView, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(320f) });
}
int num = 0;
int num2 = 0;
try
{
foreach (BroMakerMod mod in Mods)
{
if (IEnumerableExtensions.IsNullOrEmpty<StoredHero>((IEnumerable<StoredHero>)mod.StoredHeroes))
{
continue;
}
string name = mod.Name;
if (mod.StoredHeroes.Length == 1)
{
SpawnerUIOneHero(mod, num);
num++;
}
else
{
GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (_selectedModIndex == num2 != GUILayout.Toggle(_selectedModIndex == num2, name, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(150f) }))
{
if (_selectedModIndex == num2)
{
_selectedModIndex = -1;
}
else
{
_selectedModIndex = num2;
}
}
ScaledWidthSpace(50f);
GUILayout.Label(mod.Author, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label(mod.Version, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
if (mod.ErrorMessage == string.Empty)
{
GUILayout.Label(mod.BroMakerVersion, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
else
{
GUILayout.Label(mod.BroMakerVersion, _warningStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
GUILayout.EndHorizontal();
if (_selectedModIndex == num2)
{
GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
bool flag = false;
int num3 = 0;
bool flag2 = false;
int num4 = 0;
StoredHero[] storedHeroes = mod.StoredHeroes;
foreach (StoredHero selectedBro in storedHeroes)
{
if (num3 == 0)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
flag = true;
}
if (_selectedCustomBrosIndex == num != GUILayout.Toggle(_selectedCustomBrosIndex == num, mod.StoredHeroes[num4].name, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(150f) }))
{
if (_selectedCustomBrosIndex == num)
{
_selectedCustomBrosIndex = -1;
}
else
{
_selectedCustomBrosIndex = num;
_selectedBro = selectedBro;
_objectToEdit = _selectedBro.GetInfo();
CreateSelectedBro();
}
}
if (_selectedCustomBrosIndex == num)
{
flag2 = true;
}
if (num3 == _broPerLines)
{
num3 = 0;
flag = false;
GUILayout.EndHorizontal();
if (flag2)
{
SelectedBroUI(_selectedBro, mod);
}
}
num++;
num3++;
num4++;
}
if (flag)
{
GUILayout.EndHorizontal();
if (flag2)
{
SelectedBroUI(_selectedBro, mod);
}
}
GUILayout.EndVertical();
}
else
{
num += mod.StoredHeroes.Length;
}
GUILayout.Space(13f);
}
num2++;
}
foreach (BroMakerMod incompatibleMod in IncompatibleMods)
{
GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (_selectedModIndex == num2 != GUILayout.Toggle(_selectedModIndex == num2, incompatibleMod.Name, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(150f) }))
{
if (_selectedModIndex == num2)
{
_selectedModIndex = -1;
}
else
{
_selectedModIndex = num2;
}
}
ScaledWidthSpace(50f);
GUILayout.Label(incompatibleMod.Author, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label(incompatibleMod.Version, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label(incompatibleMod.BroMakerVersion, _incompatibleStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.EndHorizontal();
if (_selectedModIndex == num2)
{
GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Label(incompatibleMod.ErrorMessage, _incompatibleStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.EndVertical();
}
num2++;
}
GUILayout.Space(5f);
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button(new GUIContent("Enable All", "Enable autospawn for all custom bros"), (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(100f) }))
{
foreach (BroMakerMod mod2 in Mods)
{
StoredHero[] storedHeroes2 = mod2.StoredHeroes;
foreach (StoredHero storedHero in storedHeroes2)
{
BroSpawnManager.SetBroEnabled(storedHero.name, enabled: true);
}
}
}
GUILayout.Space(5f);
if (GUILayout.Button(new GUIContent("Disable All", "Disable autospawn for all custom bros"), (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(100f) }))
{
foreach (BroMakerMod mod3 in Mods)
{
StoredHero[] storedHeroes3 = mod3.StoredHeroes;
foreach (StoredHero storedHero2 in storedHeroes3)
{
BroSpawnManager.SetBroEnabled(storedHero2.name, enabled: false);
}
}
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
if (Mods.Count > 8 && !BroMakerLib.Settings.instance.scaleUIHeight)
{
GUILayout.EndScrollView();
}
}
catch (Exception message)
{
BMLogger.ExceptionLog(message);
}
}
private static void CreateSelectedBro()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
try
{
if ((Object)(object)_selectedHero != (Object)null)
{
ObjectExtensions.DestroyMe((Object)(object)_selectedHero);
}
string characterPreset = (_objectToEdit as CustomBroInfo).CharacterPreset;
if (IEnumerableExtensions.IsNullOrEmpty<char>((IEnumerable<char>)characterPreset))
{
throw new NullReferenceException("'characterPreset' is null or empty");
}
if (!PresetManager.heroesPreset.ContainsKey(characterPreset))
{
throw new Exception("'characterPreset': " + characterPreset + " doesn't exist. Check if you have the preset installed or if there is a typo.");
}
if ((Object)(object)heroHolder == (Object)null)
{
heroHolder = new GameObject();
heroHolder.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)heroHolder);
}
_selectedHero = heroHolder.AddComponent(PresetManager.heroesPreset[characterPreset]) as CustomHero;
_selectedHero.AssignDirectoryPaths(_selectedBro.info.path);
_selectedHero.LoadSettings();
((Behaviour)_selectedHero).enabled = false;
heroCreated = true;
}
catch (Exception ex)
{
BMLogger.Log(ex.ToString(), (LogType)3);
heroCreated = false;
}
}
private static void SelectedBroUI(StoredHero bro, BroMakerMod mod)
{
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Expected O, but got Unknown
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Expected O, but got Unknown
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Expected O, but got Unknown
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Expected O, but got Unknown
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0321: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
if (bro.Equals(null))
{
return;
}
GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (mod.ErrorMessage != string.Empty)
{
GUILayout.Label(mod.ErrorMessage, _warningStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
}
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.ExpandWidth(false),
ScaledWidth(500f)
});
for (int i = 0; i < 4; i++)
{
if (selectedPlayerNum == i != GUILayout.Toggle(selectedPlayerNum == i, new GUIContent("Player " + (i + 1), "Select which player to switch to this custom bro when you press switch to bro"), _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
selectedPlayerNum = i;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
if (GUILayout.Button(new GUIContent("Switch to Bro", "Switch selected player to this custom bro"), (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(300f) }))
{
LoadHero.previousSpawnInfo[selectedPlayerNum] = (SpawnType)7;
LoadHero.wasFirstDeployment[selectedPlayerNum] = false;
bro.LoadBro(selectedPlayerNum);
}
bool flag = BroSpawnManager.IsBroEnabled(bro.name);
bool flag2 = BroUnlockManager.IsBroUnlocked(bro.name);
if (GUILayout.Button(new GUIContent("Play Unlock Cutscene", "Play this bro's unlock cutscene if in-game"), (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(300f) }))
{
try
{
List<CustomIntroCutscene> cutscene = bro.GetInfo().Cutscene;
if (cutscene.Count <= 0)
{
throw new ArgumentNullException("The bro has no cutscene");
}
int index = Random.Range(0, cutscene.Count);
CustomCutsceneController.LoadHeroCutscene(cutscene[index]);
}
catch (ArgumentNullException ex)
{
BMLogger.ExceptionLog("The bro has no cutscene: " + ex.ToString());
}
catch (Exception message)
{
BMLogger.ExceptionLog(message);
}
}
ScaledWidthSpace(200f);
if (!BroMakerLib.Settings.instance.automaticSpawn)
{
GUILayout.Button(new GUIContent("Disabled in Settings", "Automatic spawning of bros is disabled in Spawn Options in the Settings tab"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(130f) });
ScaledWidthSpace(70f);
}
else if (!flag2)
{
GUILayout.Button(new GUIContent("Locked", "Bro is not unlocked yet"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) });
ScaledWidthSpace(90f);
}
else if (flag)
{
if (GUILayout.Button(new GUIContent("Enabled", "Click to disable autospawn for this bro"), _enabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) }))
{
BroSpawnManager.SetBroEnabled(bro.name, enabled: false);
}
ScaledWidthSpace(90f);
}
else
{
if (GUILayout.Button(new GUIContent("Disabled", "Click to enable autospawn for this bro"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) }))
{
BroSpawnManager.SetBroEnabled(bro.name, enabled: true);
}
ScaledWidthSpace(90f);
}
if (flag2)
{
GUILayout.Label(new GUIContent("Unlocked", "Bro is unlocked"), _enabledStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
else
{
GUILayout.Label(new GUIContent("Locked", "Bro is locked, rescue more lives or play their unlock level to unlock them"), _disabledStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
GUILayout.EndHorizontal();
if ((Object)(object)_selectedHero != (Object)null)
{
try
{
_selectedHero.UIOptions();
}
catch
{
}
}
else if (heroCreated)
{
CreateSelectedBro();
}
GUILayout.EndVertical();
}
private static void SpawnerUIOneHero(BroMakerMod mod, int broIndex)
{
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Expected O, but got Unknown
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Expected O, but got Unknown
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Expected O, but got Unknown
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Expected O, but got Unknown
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Expected O, but got Unknown
GUILayout.BeginHorizontal(GUIStyle.op_Implicit("box"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (_selectedCustomBrosIndex == broIndex != GUILayout.Toggle(_selectedCustomBrosIndex == broIndex, mod.StoredHeroes[0].name, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(150f) }))
{
if (_selectedCustomBrosIndex == broIndex)
{
_selectedCustomBrosIndex = -1;
}
else
{
_selectedCustomBrosIndex = broIndex;
_selectedBro = mod.StoredHeroes[0];
_objectToEdit = _selectedBro.GetInfo();
CreateSelectedBro();
}
}
ScaledWidthSpace(50f);
GUILayout.Label(mod.Author, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
GUILayout.Label(mod.Version, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
if (mod.ErrorMessage == string.Empty)
{
GUILayout.Label(mod.BroMakerVersion, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
else
{
GUILayout.Label(mod.BroMakerVersion, _warningStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
bool flag = BroSpawnManager.IsBroEnabled(mod.StoredHeroes[0].name);
bool flag2 = BroUnlockManager.IsBroUnlocked(mod.StoredHeroes[0].name);
if (!BroMakerLib.Settings.instance.automaticSpawn)
{
GUILayout.Button(new GUIContent("Disabled in Settings", "Automatic spawning of bros is disabled in Spawn Options in the Settings tab"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(130f) });
ScaledWidthSpace(70f);
}
else if (!flag2)
{
GUILayout.Button(new GUIContent("Locked", "Bro is not unlocked yet"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) });
ScaledWidthSpace(90f);
}
else if (flag)
{
if (GUILayout.Button(new GUIContent("Enabled", "Click to disable autospawn for this bro"), _enabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) }))
{
BroSpawnManager.SetBroEnabled(mod.StoredHeroes[0].name, enabled: false);
}
ScaledWidthSpace(90f);
}
else
{
if (GUILayout.Button(new GUIContent("Disabled", "Click to enable autospawn for this bro"), _disabledStyleButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(110f) }))
{
BroSpawnManager.SetBroEnabled(mod.StoredHeroes[0].name, enabled: true);
}
ScaledWidthSpace(90f);
}
if (flag2)
{
GUILayout.Label(new GUIContent("Unlocked", "Bro is unlocked"), _enabledStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
else
{
GUILayout.Label(new GUIContent("Locked", "Bro is locked, rescue more lives or play their unlock level to unlock them"), _disabledStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { ScaledWidth(200f) });
}
GUILayout.EndHorizontal();
if (_selectedCustomBrosIndex == broIndex)
{
SelectedBroUI(_selectedBro, mod);
GUILayout.Space(25f);
}
else
{
GUILayout.Space(13f);
}
}
public static void Settings()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
BroMakerLib.Settings.instance.showGeneralSettings = GUILayout.Toggle(BroMakerLib.Settings.instance.showGeneralSettings, new GUIContent("General Options", "Click to " + (BroMakerLib.Settings.instance.showGeneralSettings ? "collapse" : "expand") + " section"), _headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (BroMakerLib.Settings.instance.showGeneralSettings)
{
ShowGeneralSettings();
}
BroMakerLib.Settings.instance.showSpawnSettings = GUILayout.Toggle(BroMakerLib.Settings.instance.showSpawnSettings, new GUIContent("Spawn Options", "Click to " + (BroMakerLib.Settings.instance.showSpawnSettings ? "collapse" : "expand") + " section"), _headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (BroMakerLib.Settings.instance.showSpawnSettings)
{
ShowSpawnSettings();
}
BroMakerLib.Settings.instance.showDeveloperSettings = GUILayout.Toggle(BroMakerLib.Settings.instance.showDeveloperSettings, new GUIContent("Developer Options", "Click to " + (BroMakerLib.Settings.instance.showDeveloperSettings ? "collapse" : "expand") + " section"), _headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
if (BroMakerLib.Settings.instance.showDeveloperSettings)
{
ShowDeveloperSettings();
}
}
private static void ShowGeneralSettings()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
GUILayout.Space(15f);
BroMakerLib.Settings.instance.scaleUIWithWindowWidth = GUILayout.Toggle(BroMakerLib.Settings.instance.scaleUIWithWindowWidth, new GUIContent("Scale UI width based on window width", "Scales BroMaker settings UI elements based on the width of the UnityModManager window"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(5f);
BroMakerLib.Settings.instance.scaleUIHeight = GUILayout.Toggle(BroMakerLib.Settings.instance.scaleUIHeight, new GUIContent("Scale UI height based on bro count", "Increases the height of the BroMaker settings window when more than 8 bros are installed rather than switching to using a scrollbar."), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(5f);
BroMakerLib.Settings.instance.disableTooltips = GUILayout.Toggle(BroMakerLib.Settings.instance.disableTooltips, new GUIContent("Disable Tooltips", "Disables tooltips in the BroMaker settings"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(15f);
}
private static void ShowSpawnSettings()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Expected O, but got Unknown
GUILayout.Space(15f);
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
BroMakerLib.Settings.instance.automaticSpawn = GUILayout.Toggle(BroMakerLib.Settings.instance.automaticSpawn, new GUIContent("Automatic Spawn", "Enable automatic spawning of custom bros"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
_ = BroMakerLib.Settings.instance.equalSpawnProbability;
bool flag = (BroMakerLib.Settings.instance.equalSpawnProbability = GUILayout.Toggle(BroMakerLib.Settings.instance.equalSpawnProbability, new GUIContent("Custom bros have an equal chance of spawning as vanilla bros", "Automatically adjusts spawn probability so that custom bros have the same probability of spawning as vanilla bros"), (GUILayoutOption[])(object)new GUILayoutOption[0]));
GUILayout.EndHorizontal();
GUILayout.Space(15f);
if (BroMakerLib.Settings.instance.equalSpawnProbability)
{
float num = BroSpawnManager.CalculateSpawnProbability();
float num2 = RGUI.HorizontalSlider("Spawn Probability: ", "Probability of a custom bro spawning. The probability of any given custom bro spawning is equal to this divided by however many bros you have installed and enabled, which is " + BroSpawnManager.CalculateSpawnProbability() / (float)BroSpawnManager.EnabledBros.Count + "%", BroSpawnManager.CalculateSpawnProbability(), 0f, 100f, 500f);
if (num != num2)
{
BroMakerLib.Settings.instance.automaticSpawnProbabilty = num2;
BroMakerLib.Settings.instance.equalSpawnProbability = false;
}
}
else
{
BroMakerLib.Settings.instance.automaticSpawnProbabilty = RGUI.HorizontalSlider("Spawn Probability: ", "Probability of a custom bro spawning. The probability of any given custom bro spawning is equal to this divided by however many bros you have installed and enabled, which is " + BroSpawnManager.CalculateSpawnProbability() / (float)BroSpawnManager.EnabledBros.Count + "%", BroSpawnManager.CalculateSpawnProbability(), 0f, 100f, 500f);
}
GUILayout.Space(15f);
BroMakerLib.Settings.instance.onlyCustomInHardcore = GUILayout.Toggle(BroMakerLib.Settings.instance.onlyCustomInHardcore, new GUIContent("Only custom characters will spawn in IronBro mode", "Only custom bros will be unlockable in IronBro, once you have unlocked them all you will be unable to gain more lives"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(15f);
BroMakerLib.Settings.instance.maxHealthAtOne = GUILayout.Toggle(BroMakerLib.Settings.instance.maxHealthAtOne, new GUIContent("Max health always at 1", "This makes sure that bros default to 1 health even if it's not explicitly set in the json file"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(15f);
BroMakerLib.Settings.instance.disableCustomAvatarFlash = GUILayout.Toggle(BroMakerLib.Settings.instance.disableCustomAvatarFlash, new GUIContent("Disable avatar flashing for custom bros", "Prevents avatar flash effect on custom bros that plays when invulnerable or idle. This is disabled on vanilla bros by default."), (GUILayoutOption[])(object)new GUILayoutOption[0]);
}
private static void ShowDeveloperSettings()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
GUILayout.Space(15f);
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button(new GUIContent("Check Directories", "Creates BroMaker_Storage directory if it doesn't already exist"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
DirectoriesManager.Initialize();
}
if (GUILayout.Button(new GUIContent("Show Presets", "Lists all available presets to the log"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
foreach (KeyValuePair<string, Type> item in PresetManager.heroesPreset)
{
Main.Log($"{item.Key}\t{item.Value}");
}
}
GUILayout.EndHorizontal();
GUILayout.Space(15f);
BroMakerLib.Settings.instance.debugLogs = GUILayout.Toggle(BroMakerLib.Settings.instance.debugLogs, new GUIContent("Debug Logs", "Enables debug logging which can be viewed in the UnityModManager log"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
BroMakerLib.Settings.instance.developerMode = GUILayout.Toggle(BroMakerLib.Settings.instance.developerMode, new GUIContent("Developer Mode", "Enables more options in the BroMakerSettings window for bro developers"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
GUILayout.Space(10f);
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
if (GUILayout.Button("Unlock All Bros", (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
BroUnlockManager.UnlockAllBros();
}
if (GUILayout.Button("Lock All Bros", (GUILayoutOption[])(object)new GUILayoutOption[0]))
{
BroUnlockManager.LockAllBros();
}
GUILayout.EndHorizontal();
}
private static void ReloadFiles()
{
BroMaker.ReloadFiles();
_selectedCustomBrosIndex = -1;
}
}
public class BroMakerMod
{
public string Name = string.Empty;
public string Version = "0.0.0";
public string BroMakerVersion = "0.0.0";
public string Author = string.Empty;
public string ErrorMessage = string.Empty;
public bool HasHarmonyPatch;
public string[] Assemblies = new string[0];
public object[] CustomBros = new object[0];
public object[] Abilities = new object[0];
public object[] Grenades = new object[0];
[JsonIgnore]
public Harmony Harmony;
[JsonIgnore]
public string Path { get; protected set; }
[JsonIgnore]
public string[] BrosNames { get; protected set; }
[JsonIgnore]
public StoredHero[] StoredHeroes { get; set; }
[JsonIgnore]
public StoredAbility[] StoredAbilities { get; set; }
public static BroMakerMod TryLoad(string path)
{
BroMakerMod broMakerMod = JsonConvert.DeserializeObject<BroMakerMod>(File.ReadAllText(path));
if (broMakerMod != null)
{
broMakerMod.Path = Directory.GetParent(path).ToString();
}
return broMakerMod;
}
public void Initialize()
{
if (IEnumerableExtensions.IsNullOrEmpty<char>((IEnumerable<char>)Name))
{
Name = Path.Substring(Directory.GetCurrentDirectory().Length - 1, Path.Length);
}
CustomBros = CheckFiles<CustomBroInfo>(CustomBros);
Abilities = CheckFiles<AbilityInfo>(Abilities);
BrosNames = GetNames<CustomBroforceObjectInfo>(CustomBros);
}
public virtual string SerializeJSON(string folderPath, string fileName)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
Name = fileName;
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
JsonSerializerSettings val = new JsonSerializerSettings
{
ReferenceLoopHandling = (ReferenceLoopHandling)1
};
string text = JsonConvert.SerializeObject((object)this, (Formatting)1, val);
File.WriteAllText(System.IO.Path.Combine(folderPath, fileName + ".mod.json"), text);
return text;
}
private object[] CheckFiles<T>(object[] objects) where T : CustomBroforceObjectInfo
{
if (IEnumerableExtensions.IsNullOrEmpty<object>((IEnumerable<object>)objects))
{
return new object[0];
}
List<object> list = new List<object>();
foreach (object obj in objects)
{
if (obj == null)
{
continue;
}
if (obj is string && IEnumerableExtensions.IsNotNullOrEmpty<char>((IEnumerable<char>)ObjectExtensions.As<string>(obj)))
{
string text = System.IO.Path.Combine(Path, ObjectExtensions.As<string>(obj));
if (File.Exists(text))
{
list.Add(obj);
}
else
{
BMLogger.Warning($"Can't find '{obj}' at '{text}'");
}
}
else if (obj is JObject && ((JContainer)ObjectExtensions.As<JObject>(obj)).Count > 0)
{
T val = ((JToken)ObjectExtensions.As<JObject>(obj)).ToObject<T>();
if (val != null)
{
list.Add(val);
}
}
}
return list.ToArray();
}
private string[] GetNames<T>(object[] objects) where T : CustomBroforceObjectInfo
{
if (IEnumerableExtensions.IsNullOrEmpty<object>((IEnumerable<object>)objects))
{
return new string[0];
}
List<string> list = new List<string>();
foreach (object obj in objects)
{
if (obj == null)
{
continue;
}
if (obj is string && IEnumerableExtensions.IsNotNullOrEmpty<char>((IEnumerable<char>)ObjectExtensions.As<string>(obj)))
{
string text = System.IO.Path.Combine(Path, ObjectExtensions.As<string>(obj));
if (File.Exists(text))
{
T val = CustomBroforceObjectInfo.DeserializeJSON<T>(text);
list.Add(val.name);
}
else
{
BMLogger.Warning($"Can't find '{obj}' at '{text}'");
}
}
else if (obj is T)
{
list.Add(ObjectExtensions.As<T>(obj).name);
}
}
return list.ToArray();
}
}
public static class Info
{
public const string NAME = "BroMakerLib";
public const string AUTHOR = "Gorzontrok";
public const string VERSION = "2.6.0";
public const string SUGGESTEDMINIMUMVERSION = "2.6.0";
public const string MINIMUMVERSION = "2.6.0";
private static Version _parsedVersion;
private static Version _parsedSuggestedMinimumVersion;
private static Version _parsedMinimumVersion;
public static Version ParsedVersion
{
get
{
if (_parsedVersion == null)
{
_parsedVersion = UnityModManager.ParseVersion("2.6.0");
}
return _parsedVersion;
}
}
public static Version ParsedSuggestedMinimumVersion
{
get
{
if (_parsedSuggestedMinimumVersion == null)
{
_parsedSuggestedMinimumVersion = UnityModManager.ParseVersion("2.6.0");
}
return _parsedSuggestedMinimumVersion;
}
}
public static Version ParsedMinimumVersion
{
get
{
if (_parsedMinimumVersion == null)
{
_parsedMinimumVersion = UnityModManager.ParseVersion("2.6.0");
}
return _parsedMinimumVersion;
}
}
}
public class EditorIgnoreAttribute : Attribute
{
}
public class CantBeNullAttribute : Attribute
{
}
public static class ICustomHeroExtensions
{
[AllowedRPC]
public static void AssignNullVariables(this ICustomHero hero, BroBase character)
{
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hero.Character == (Object)null)
{
throw new NullReferenceException("AssignNullVariables: ICustomHero.character is null");
}
BroBase character2 = hero.Character;
BMLogger.Debug($"AssignNullVariables: {((object)character2).GetType()}: Start Assigning null variables from {((object)character).GetType()}.", (LogType)3);
HarmonyExtensions.SetFieldValue<SpriteSM>((object)character2, "sprite", TestVanDammeAnimExtensions.Sprite((TestVanDammeAnim)(object)character2));
((TestVanDammeAnim)character2).gunSprite = ((TestVanDammeAnim)character).gunSprite;
((TestVanDammeAnim)character2).soundHolder = ((TestVanDammeAnim)character2).soundHolder ?? ((TestVanDammeAnim)character).soundHolder;
((TestVanDammeAnim)character2).soundHolderFootSteps = ((TestVanDammeAnim)character2).soundHolderFootSteps ?? ((TestVanDammeAnim)character).soundHolderFootSteps;
character2.soundHolderVoice = character2.soundHolderVoice ?? character.soundHolderVoice;
((TestVanDammeAnim)character2).gibs = ((TestVanDammeAnim)character).gibs;
((TestVanDammeAnim)character2).player1Bubble = ((TestVanDammeAnim)character).player1Bubble;
((TestVanDammeAnim)character2).player2Bubble = ((TestVanDammeAnim)character).player2Bubble;
((TestVanDammeAnim)character2).player3Bubble = ((TestVanDammeAnim)character).player3Bubble;
((TestVanDammeAnim)character2).player4Bubble = ((TestVanDammeAnim)character).player4Bubble;
((TestVanDammeAnim)character2).blood = ((TestVanDammeAnim)character).blood;
((TestVanDammeAnim)character2).heroTrailPrefab = ((TestVanDammeAnim)character).heroTrailPrefab;
((TestVanDammeAnim)character2).high5Bubble = ((TestVanDammeAnim)character).high5Bubble;
((Unit)character2).projectile = ((Unit)character).projectile;
character2.jetPackSprite = character.jetPackSprite;
((TestVanDammeAnim)character2).specialGrenade = LoadBroforceObjects.GetGrenadeFromName(string.Empty);
((TestVanDammeAnim)character2).specialGrenade.playerNum = ((NetworkedUnit)character2).playerNum;
((TestVanDammeAnim)character2).heroType = ((TestVanDammeAnim)character).heroType;
HarmonyExtensions.SetFieldValue<AudioSource>((object)character2, "wallDragAudio", HarmonyExtensions.GetFieldValue<AudioSource>((object)character, "wallDragAudio"));
((TestVanDammeAnim)character2).parachute = ((Component)character2).GetComponentInChildren<Parachute>();
((NetworkObject)character2).SetOwner(((NetworkObject)character).Owner);
BMLogger.Debug($"AssignNullVariables: {((object)character2).GetType()}: Has finish assigning null variables.", (LogType)3);
}
[AllowedRPC]
public static void FixOtherComponentValues(this ICustomHero hero)
{
if ((Object)(object)hero.Character == (Object)null)
{
throw new NullReferenceException("FixOtherComponentValues: ICustomHero.character is null");
}
BroBase character = hero.Character;
if ((Object)(object)((TestVanDammeAnim)character).parachute != (Object)null)
{
((TestVanDammeAnim)character).parachute.tvd = (TestVanDammeAnim)(object)character;
BMLogger.Debug("FixOtherComponentValues: Has set 'tvd' of 'Parachute' component.", (LogType)3);
}
else
{
BMLogger.Debug("FixOtherComponentValues: Parachute Not Found", (LogType)3);
}
ComponentExtensions.RemoveComponent<WavyGrassEffector>((Component)(object)character);
BMLogger.Debug("FixOtherComponentValues: Removed 'WavyGrassEffector' component.", (LogType)3);
ComponentExtensions.RemoveComponent<PathAgent>((Component)(object)character);
BMLogger.Debug("FixOtherComponentValues: Removed 'PathAgent' component.", (LogType)3);
}
public static BroBase GetTheOtherBroBaseComponent(this ICustomHero hero)
{
BroBase character = hero.Character;
BroBase result = null;
BroBase[] components = ((Component)character).GetComponents<BroBase>();
BMLogger.Debug($"GetTheOtherBroBaseComponent: {((object)character).GetType()}: Has got BroBase components.", (LogType)3);
if (components.Length > 2)
{
throw new Exception($"GetTheOtherBroBaseComponent: {components.Length} components found: {Extensions.ValuesAsString<BroBase>(components)}");
}
BroBase[] array = components;
foreach (BroBase val in array)
{
BMLogger.Debug($"GetTheOtherBroBaseComponent: Find component of {((object)val).GetType()}.", (LogType)3);
if ((Object)(object)val != (Object)(object)character)
{
result = val;
}
}
BMLogger.Debug($"GetTheOtherBroBaseComponent: {((object)character).GetType()}: Has loop throught the Brobase components.", (LogType)3);
return result;
}
[AllowedRPC]
public static void SetupCustomHero(this ICustomHero hero)
{
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
BroBase theOtherBroBaseComponent = hero.GetTheOtherBroBaseComponent();
if ((Object)(object)theOtherBroBaseComponent != (Object)null)
{
hero.AssignNullVariables(theOtherBroBaseComponent);
Type type = ((object)theOtherBroBaseComponent).GetType();
Object.DestroyImmediate((Object)(object)theOtherBroBaseComponent);
BMLogger.Debug($"SetupCustomHero: Has destroy {type} component.", (LogType)3);
hero.Info.ReadParameters(hero.Character);
BMLogger.Debug("SetupCustomHero: Has read parameters", (LogType)3);
}
else
{
BMLogger.Debug("SetupCustomHero: No other bro component founded", (LogType)3);
}
hero.FixOtherComponentValues();
hero.RemoveDuplicateGlowLight();
((BroforceObject)hero.Character).maxHealth = 1;
CustomBroInfo info = hero.Info;
if (!info.beforeAwake.ContainsKey("specialGrenade.playerNum"))
{
info.beforeAwake.Add("specialGrenade.playerNum", LoadHero.playerNum);
}
if (!info.beforeAwake.ContainsKey("health"))
{
info.beforeAwake.Add("health", 1);
}
if (Settings.instance.maxHealthAtOne)
{
if (info.afterStart.ContainsKey("health"))
{
info.afterStart["health"] = 1;
}
else
{
info.afterStart.Add("health", 1);
}
if (info.afterStart.ContainsKey("maxHealth"))
{
info.afterStart["maxHealth"] = 1;
}
else
{
info.afterStart.Add("maxHealth", 1);
}
}
DetermineVariantCount(hero.Info);
ValidateVariantLists(hero.Info);
if (!info.beforeAwake.ContainsKey("canCeilingHang"))
{
info.beforeAwake.Add("canCeilingHang", true);
}
if (!(hero is CustomHero))
{
hero.CurrentVariant = Random.Range(0, hero.Info.VariantCount);
hero.CurrentGunSpriteOffset = BroMakerUtilities.GetVariantValue(hero.Info.GunSpriteOffset, hero.CurrentVariant);
hero.CurrentSpecialMaterials = BroMakerUtilities.GetVariantValue(hero.Info.SpecialMaterials, hero.CurrentVariant);
hero.CurrentSpecialMaterialOffset = BroMakerUtilities.GetVariantValue(hero.Info.SpecialMaterialOffset, hero.CurrentVariant);
hero.CurrentSpecialMaterialSpacing = BroMakerUtilities.GetVariantValue(hero.Info.SpecialMaterialSpacing, hero.CurrentVariant);
hero.CurrentFirstAvatar = BroMakerUtilities.GetVariantValue(hero.Info.FirstAvatar, hero.CurrentVariant);
((TestVanDammeAnim)hero.Character).specialGrenade.playerNum = LoadHero.playerNum;
}
}
[AllowedRPC]
public static void RemoveDuplicateGlowLight(this ICustomHero hero)
{
Transform transform = ((Component)hero.Character).transform;
int childCount = transform.childCount;
int num = 0;
GameObject val = null;
for (int i = 0; i < childCount; i++)
{
Transform child = transform.GetChild(i);
if (((Object)((Component)child).gameObject).name.Contains("Glow Light"))
{
num++;
val = ((Component)child).gameObject;
}
}
if (num > 1 && (Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
BMLogger.Debug("GlowLight Destroyed", (LogType)3);
}
}
private static void DetermineVariantCount(CustomBroInfo info)
{
int num = 1;
List<string> spritePath = info.SpritePath;
if (spritePath != null && spritePath.Count > num)
{
num = info.SpritePath.Count;
}
List<string> gunSpritePath = info.GunSpritePath;
if (gunSpritePath != null && gunSpritePath.Count > num)
{
num = info.GunSpritePath.Count;
}
List<Vector2> gunSpriteOffset = info.GunSpriteOffset;
if (gunSpriteOffset != null && gunSpriteOffset.Count > num)
{
num = info.GunSpriteOffset.Count;
}
List<List<Material>> specialMaterials = info.SpecialMaterials;
if (specialMaterials != null && specialMaterials.Count > num)
{
num = info.SpecialMaterials.Count;
}
List<Vector2> specialMaterialOffset = info.SpecialMaterialOffset;
if (specialMaterialOffset != null && specialMaterialOffset.Count > num)
{
num = info.SpecialMaterialOffset.Count;
}
List<float> specialMaterialSpacing = info.SpecialMaterialSpacing;
if (specialMaterialSpacing != null && specialMaterialSpacing.Count > num)
{
num = info.SpecialMaterialSpacing.Count;
}
List<Material> firstAvatar = info.FirstAvatar;
if (firstAvatar != null && firstAvatar.Count > num)
{
num = info.FirstAvatar.Count;
}
List<CustomIntroCutscene> cutscene = info.Cutscene;
if (cutscene != null && cutscene.Count > num)
{
num = info.Cutscene.Count;
}
info.VariantCount = num;
}
private static void ValidateVariantLists(CustomBroInfo info)
{
ValidateList(info.SpritePath, "SpritePath", info.VariantCount);
ValidateList(info.GunSpritePath, "GunSpritePath", info.VariantCount);
ValidateList(info.GunSpriteOffset, "GunSpriteOffset", info.VariantCount);
ValidateList(info.SpecialMaterials, "SpecialMaterials", info.VariantCount);
ValidateList(info.SpecialMaterialOffset, "SpecialMaterialOffset", info.VariantCount);
ValidateList(info.SpecialMaterialSpacing, "SpecialMaterialSpacing", info.VariantCount);
ValidateList(info.FirstAvatar, "FirstAvatar", info.VariantCount);
ValidateList(info.Cutscene, "Cutscene", info.VariantCount);
}
private static void ValidateList<T>(List<T> list, string propertyName, int expectedCount)
{
if (list != null && list.Count > 1 && list.Count != expectedCount)
{
throw new InvalidOperationException($"{propertyName} has {list.Count} items but VariantCount is {expectedCount}. " + $"Lists must have either 1 item (shared across variants) or exactly {expectedCount} items (one per variant).");
}
}
public static void SetSprites(this ICustomHero bro)
{
string variantValue = BroMakerUtilities.GetVariantValue(bro.Info.SpritePath, bro.CurrentVariant);
string variantValue2 = BroMakerUtilities.GetVariantValue(bro.Info.GunSpritePath, bro.CurrentVariant);
BroBase character = bro.Character;
if (!string.IsNullOrEmpty(variantValue))
{
Material val = (((TestVanDammeAnim)character).material = ResourcesController.GetMaterial(bro.Info.path, variantValue));
HarmonyExtensions.SetFieldValue<Material>((object)character, "defaultMaterial", val);
}
if (!string.IsNullOrEmpty(variantValue2))
{
Material material2 = ResourcesController.GetMaterial(bro.Info.path, variantValue2);
((TestVanDammeAnim)character).gunSprite.meshRender.sharedMaterial = material2;
HarmonyExtensions.SetFieldValue<Material>((object)character, "gunMaterial", material2);
}
if (character is CustomHero customHero)
{
customHero.SetupAdditionalSprites();
}
}
public static void StandardBeforeAwake(this ICustomHero hero, Action fixNullVariableLocal = null)
{
hero.Character = (BroBase)((hero is BroBase) ? hero : null);
hero.Info = LoadHero.currentInfo;
fixNullVariableLocal?.Invoke();
hero.SetupCustomHero();
hero.Info.BeforeAwake(hero);
}
public static void StandardAfterAwake(this ICustomHero hero)
{
hero.SetSprites();
hero.Info.AfterAwake(hero);
}
public static void StandardBeforeStart(this ICustomHero hero)
{
hero.Info.BeforeStart(hero);
}
public static void StandardAfterStart(this ICustomHero hero)
{
hero.Info.AfterStart(hero);
}
}
public static class InvulnerabilityFlashExtensions
{
public static void SetCharacter(this InvulnerabilityFlash flash, TestVanDammeAnim character)
{
if ((Object)(object)flash == (Object)null || (Object)(object)character == (Object)null)
{
return;
}
try
{
HarmonyExtensions.SetFieldValue<TestVanDammeAnim>((object)flash, "hero", character);
HarmonyExtensions.SetFieldValue<SpriteSM>((object)flash, "heroSprite", TestVanDammeAnimExtensions.Sprite(character));
HarmonyExtensions.SetFieldValue<SpriteSM>((object)flash, "gunSprite", character.gunSprite);
}
catch (Exception exception)
{
BMLogger.ExceptionLog("InvulnerabilityFlashExtensions.SetCharacter: Failed to set character", exception);
}
}
}
public static class Parameters
{
[Parameter]
public static void Halo(object obj, bool value)
{
//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)
TestVanDammeAnim val = (TestVanDammeAnim)((obj is TestVanDammeAnim) ? obj : null);
if (!Object.op_Implicit((Object)(object)val))
{
BMLogger.Warning("HaloPreset parameter works only with characters.");
}
else if (value)
{
BroHalo halo = HeroController.GetHeroPrefab((HeroType)47).halo;
val.halo = Object.Instantiate<BroHalo>(halo, ((Component)halo).transform.localPosition, Quaternion.identity);
((Component)val.halo).transform.parent = ((Component)val).transform;
}
}
[Parameter]
public static void HaloPreset(object obj, string value)
{
if (value != null || IEnumerableExtensions.IsNullOrEmpty<char>((IEnumerable<char>)value))
{
BMLogger.Warning("HaloPreset is empty or null");
return;
}
TestVanDammeAnim val = (TestVanDammeAnim)((obj is TestVanDammeAnim) ? obj : null);
Type value2;
if (!Object.op_Implicit((Object)(object)val))
{
BMLogger.Warning("HaloPreset parameter works only with characters.");
}
else if ((Object)(object)val.halo == (Object)null)
{
BMLogger.Warning("Halo is null, can't apply preset.");
}
else if (PresetManager.customObjectsPreset.TryGetValue(value, out value2))
{
((Component)val.halo).gameObject.AddComponent(value2);
}
else
{
BMLogger.Log("Halo preset " + value + " not founded.", (LogType)2);
}
}
[Parameter]
public static void BetterAnimation(object obj, bool value)
{
TestVanDammeAnim val = (TestVanDammeAnim)((obj is TestVanDammeAnim) ? obj : null);
if (!Object.op_Implicit((Object)(object)val))
{
BMLogger.Warning("BetterAnimation parameter works only with characters.");
}
else if (value)
{
val.doRollOnLand = true;
val.useDashFrames = true;
val.useNewFrames = true;
val.useNewKnifingFrames = true;
val.useNewLedgeGrappleFrames = true;
val.useNewThrowingFrames = true;
val.useNewHighFivingFrames = true;
HarmonyExtensions.SetFieldValue<bool>((object)val, "hasNewAirFlexFrames", true);
val.useNewKnifeClimbingFrames = true;
val.useDuckingFrames = true;
val.useNewDuckingFrames = true;
}
}
[Parameter]
public static void JetPackSprite(object obj, bool value)
{
//IL_0033: 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)
BroBase val = (BroBase)((obj is BroBase) ? obj : null);
if (!Object.op_Implicit((Object)(object)val))
{
BMLogger.Warning("JetPackSprite parameter works only with Bros.");
return;
}
SpriteSM jetPackSprite = ObjectExtensions.As<BroBase>((object)HeroController.GetHeroPrefab((HeroType)0)).jetPackSprite;
val.jetPackSprite = Object.Instantiate<SpriteSM>(jetPackSprite, ((Component)jetPackSprite).transform.localPosition, Quaternion.identity);
((Component)val.jetPackSprite).transform.parent = ((Component)val).transform;
}
[Parameter]
public static void SpecialIcons(object obj, object value)
{
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("SpecialIcons parameter works only with Bros.");
}
else
{
if (customHero.Info.SpecialMaterials.Count > 1 || (customHero.Info.SpecialMaterials.Count == 1 && customHero.Info.SpecialMaterials[0].Count > 0))
{
return;
}
customHero.Info.SpecialMaterials.Clear();
if (value is string)
{
string fileName = value as string;
Material material = ResourcesController.GetMaterial(customHero.Info.path, fileName);
customHero.Info.SpecialMaterials.Add(new List<Material> { material });
return;
}
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
if (((JContainer)val).Count <= 0)
{
return;
}
if (val[0] is JArray)
{
foreach (JToken item in val)
{
List<Material> list = new List<Material>();
JArray val2 = (JArray)(object)((item is JArray) ? item : null);
if (val2 != null)
{
foreach (JToken item2 in val2)
{
string fileName2 = item2.ToObject<string>();
Material material2 = ResourcesController.GetMaterial(customHero.Info.path, fileName2);
list.Add(material2);
}
}
customHero.Info.SpecialMaterials.Add(list);
}
return;
}
{
foreach (JToken item3 in val)
{
string fileName3 = item3.ToObject<string>();
Material material3 = ResourcesController.GetMaterial(customHero.Info.path, fileName3);
customHero.Info.SpecialMaterials.Add(new List<Material> { material3 });
}
return;
}
}
if (value is string[])
{
string[] array = value as string[];
for (int i = 0; i < array.Length; i++)
{
Material material4 = ResourcesController.GetMaterial(customHero.Info.path, array[i]);
customHero.Info.SpecialMaterials.Add(new List<Material> { material4 });
}
}
else
{
BMLogger.Warning($"SpecialIcons value is type of {value.GetType()} it must be a String, String Array, or Array of String Arrays");
}
}
}
[Parameter]
public static void SpecialIconOffset(object obj, object value)
{
//IL_0055: 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_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("SpecialIconOffset parameter works only with Bros.");
return;
}
try
{
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
if (customHero.Info.SpecialMaterialOffset.Count > 1 || (customHero.Info.SpecialMaterialOffset.Count == 1 && customHero.Info.SpecialMaterialOffset[0] != Vector2.zero))
{
return;
}
customHero.Info.SpecialMaterialOffset.Clear();
{
foreach (JToken item in val)
{
JObject val2 = (JObject)(object)((item is JObject) ? item : null);
if (val2 != null)
{
float num = Convert.ToSingle(val2.GetValue("x").ToObject<object>());
float num2 = Convert.ToSingle(val2.GetValue("y").ToObject<object>());
customHero.Info.SpecialMaterialOffset.Add(new Vector2(num, num2));
}
}
return;
}
}
if (value is JObject)
{
if (customHero.Info.SpecialMaterialOffset.Count <= 1)
{
JToken value2 = ObjectExtensions.As<JObject>(value).GetValue("x");
JToken value3 = ObjectExtensions.As<JObject>(value).GetValue("y");
float num3 = Convert.ToSingle(value2.ToObject<object>());
float num4 = Convert.ToSingle(value3.ToObject<object>());
if (customHero.Info.SpecialMaterialOffset.Count == 0)
{
customHero.Info.SpecialMaterialOffset.Add(new Vector2(num3, num4));
}
else if (customHero.Info.SpecialMaterialOffset[0] == Vector2.zero)
{
customHero.Info.SpecialMaterialOffset[0] = new Vector2(num3, num4);
}
}
}
else
{
BMLogger.Error("Can't load SpecialIconOffset value. It should be { \"x\": 0, \"y\": 0 } or an array of such objects");
}
}
catch (Exception message)
{
BMLogger.ExceptionLog(message);
}
}
[Parameter]
public static void SpecialIconSpacing(object obj, object value)
{
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("SpecialIconSpacing parameter works only with Bros.");
return;
}
try
{
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
if (customHero.Info.SpecialMaterialSpacing.Count > 1 || (customHero.Info.SpecialMaterialSpacing.Count == 1 && customHero.Info.SpecialMaterialSpacing[0] != 0f))
{
return;
}
customHero.Info.SpecialMaterialSpacing.Clear();
{
foreach (JToken item in val)
{
customHero.Info.SpecialMaterialSpacing.Add(Convert.ToSingle(item));
}
return;
}
}
if (customHero.Info.SpecialMaterialSpacing.Count <= 1)
{
if (customHero.Info.SpecialMaterialSpacing.Count == 0)
{
customHero.Info.SpecialMaterialSpacing.Add(Convert.ToSingle(value));
}
else if (customHero.Info.SpecialMaterialSpacing[0] == 0f)
{
customHero.Info.SpecialMaterialSpacing[0] = Convert.ToSingle(value);
}
}
}
catch (Exception message)
{
BMLogger.ExceptionLog(message);
}
}
[Parameter]
public static void Avatar(object obj, object value)
{
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("Avatar parameter works only with Bros.");
return;
}
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
if (customHero.Info.FirstAvatar.Count > 1 || (customHero.Info.FirstAvatar.Count == 1 && (Object)(object)customHero.Info.FirstAvatar[0] != (Object)null))
{
return;
}
customHero.Info.FirstAvatar.Clear();
{
foreach (JToken item in val)
{
string fileName = item.ToObject<string>();
customHero.Info.FirstAvatar.Add(ResourcesController.GetMaterial(customHero.Info.path, fileName));
}
return;
}
}
if (value is string[] array)
{
if (customHero.Info.FirstAvatar.Count <= 1 && (customHero.Info.FirstAvatar.Count != 1 || !((Object)(object)customHero.Info.FirstAvatar[0] != (Object)null)))
{
customHero.Info.FirstAvatar.Clear();
string[] array2 = array;
foreach (string fileName2 in array2)
{
customHero.Info.FirstAvatar.Add(ResourcesController.GetMaterial(customHero.Info.path, fileName2));
}
}
}
else if (value is string && customHero.Info.FirstAvatar.Count <= 1)
{
if (customHero.Info.FirstAvatar.Count == 0)
{
customHero.Info.FirstAvatar.Add(ResourcesController.GetMaterial(customHero.Info.path, value as string));
}
else if ((Object)(object)customHero.Info.FirstAvatar[0] == (Object)null)
{
customHero.Info.FirstAvatar[0] = ResourcesController.GetMaterial(customHero.Info.path, value as string);
}
}
}
[Parameter]
public static void GunSpriteOffset(object obj, object value)
{
//IL_0055: 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_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("GunSpriteOffset parameter works only with Bros.");
return;
}
try
{
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
if (customHero.Info.GunSpriteOffset.Count > 1 || (customHero.Info.GunSpriteOffset.Count == 1 && customHero.Info.GunSpriteOffset[0] != Vector2.zero))
{
return;
}
customHero.Info.GunSpriteOffset.Clear();
{
foreach (JToken item in val)
{
JObject val2 = (JObject)(object)((item is JObject) ? item : null);
if (val2 != null)
{
float num = Convert.ToSingle(val2.GetValue("x").ToObject<object>());
float num2 = Convert.ToSingle(val2.GetValue("y").ToObject<object>());
customHero.Info.GunSpriteOffset.Add(new Vector2(num, num2));
}
}
return;
}
}
if (value is JObject)
{
if (customHero.Info.GunSpriteOffset.Count <= 1)
{
JToken value2 = ObjectExtensions.As<JObject>(value).GetValue("x");
JToken value3 = ObjectExtensions.As<JObject>(value).GetValue("y");
float num3 = Convert.ToSingle(value2.ToObject<object>());
float num4 = Convert.ToSingle(value3.ToObject<object>());
if (customHero.Info.GunSpriteOffset.Count == 0)
{
customHero.Info.GunSpriteOffset.Add(new Vector2(num3, num4));
}
else if (customHero.Info.GunSpriteOffset[0] == Vector2.zero)
{
customHero.Info.GunSpriteOffset[0] = new Vector2(num3, num4);
}
}
}
else
{
BMLogger.Error("Can't load GunSpriteOffset value. It should be { \"x\": 0, \"y\": 0 } or an array of such objects");
}
}
catch (Exception message)
{
BMLogger.ExceptionLog(message);
}
}
[Parameter]
public static void Sprite(object obj, object value)
{
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("Sprite parameter works only with Bros.");
}
else
{
if (customHero.Info.SpritePath.Count != 0)
{
return;
}
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
customHero.Info.SpritePath.Clear();
{
foreach (JToken item in val)
{
customHero.Info.SpritePath.Add(item.ToObject<string>());
}
return;
}
}
if (value is string[] collection)
{
customHero.Info.SpritePath.Clear();
customHero.Info.SpritePath.AddRange(collection);
}
else if (value is string)
{
if (customHero.Info.SpritePath.Count == 0)
{
customHero.Info.SpritePath.Add(value as string);
}
else if (customHero.Info.SpritePath.Count == 1)
{
customHero.Info.SpritePath[0] = value as string;
}
}
}
}
[Parameter]
public static void GunSprite(object obj, object value)
{
if (!(obj is ICustomHero customHero))
{
BMLogger.Warning("GunSprite parameter works only with Bros.");
}
else
{
if (customHero.Info.GunSpritePath.Count != 0)
{
return;
}
JArray val = (JArray)((value is JArray) ? value : null);
if (val != null)
{
customHero.Info.GunSpritePath.Clear();
{
foreach (JToken item in val)
{
customHero.Info.GunSpritePath.Add(item.ToObject<string>());
}
return;
}
}
if (value is string[] collection)
{
customHero.Info.GunSpritePath.Clear();
customHero.Info.GunSpritePath.AddRange(collection);
}
else if (value is string)
{
if (customHero.Info.GunSpritePath.Count == 0)
{
customHero.Info.GunSpritePath.Add(value as string);
}
else if (customHero.Info.GunSpritePath.Count == 1)
{
customHero.Info.GunSpritePath[0] = value as string;
}
}
}
}
}
public static class PresetManager
{
public static Dictionary<string, MethodInfo> parameters;
public static Dictionary<string, Type> heroesPreset;
public static Dictionary<string, Type> customObjectsPreset;
public static Dictionary<string, Type> abilities;
public static Dictionary<string, Type> grenades;
public static bool disableWarnings;
static PresetManager()
{
parameters = new Dictionary<string, MethodInfo>();
heroesPreset = new Dictionary<string, Type>();
customObjectsPreset = new Dictionary<string, Type>();
abilities = new Dictionary<string, Type>();
grenades = new Dictionary<string, Type>();
disableWarnings = false;
}
public static void Initialize()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
heroesPreset = new Dictionary<string, Type>();
customObjectsPreset = new Dictionary<string, Type>();
abilities = new Dictionary<string, Type>();
parameters = new Dictionary<string, MethodInfo>();
CheckAssembly(Assembly.GetExecutingAssembly());
foreach (BroMakerMod mod in BroMakerStorage.mods)
{
if (mod.HasHarmonyPatch)
{
mod.Harmony = new Harmony(mod.Name);
}
string[] assemblies = mod.Assemblies;
foreach (string text in assemblies)
{
string text2 = Path.Combine(mod.Path, text);
if (!File.Exists(text2))
{
continue;
}
string text3 = text2 + ".cache";
if (!File.Exists(text3))
{
File.Copy(text2, text3);
}
Assembly assembly = Assembly.LoadFile(text2);
if (CheckAssembly(assembly) && mod.Harmony != null)
{
try
{
mod.Harmony.PatchAll(assembly);
BMLogger.Log(text + " patched!", (LogType)3);
}
catch (Exception exception)
{
BMLogger.ExceptionLog("Error patching " + text, exception);
}
}
}
}
}
public static Type GetHeroPreset(string presetName)
{
if (!heroesPreset.ContainsKey(presetName))
{
return null;
}
return heroesPreset[presetName];
}
public static Type GetAbilityPreset(string name)
{
if (!abilities.ContainsKey(name))
{
return null;
}
return abilities[name];
}
public static Type GetGrenadePreset(string name)
{
if (!grenades.ContainsKey(name))
{
return null;
}
return grenades[name];
}
public static MethodInfo GetParameterMethod(string name)
{
if (!parameters.ContainsKey(name))
{
return null;
}
return parameters[name];
}
public static bool CheckAssembly(Assembly assembly)
{
if ((object)assembly == null)
{
return false;
}
try
{
Type[] types = assembly.GetTypes();
if (types.Length == 0)
{
BMLogger.Warning("Assembly '" + assembly.GetName().Name + "' is somehow empty ( \u0360° \u035fʖ \u0361°)");
return false;
}
RetrieveParameters(types);
Type[] types2 = FindPresets(types);
AddPresets(types2);
}
catch (Exception ex)
{
BMLogger.ExceptionLog(assembly.FullName + " - " + ex);
return false;
}
return true;
}
private static void RetrieveParameters(Type[] types)
{
Type type = types.FirstOrDefault((Type t) => t.Name == "Parameters");
if ((object)type == null || type.Name != "Parameters")
{
return;
}
MethodInfo[] methods = type.GetMethods();
MethodInfo[] array = methods;
foreach (MethodInfo methodInfo in array)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(ParameterAttribute), inherit: true);
if (IEnumerableExtensions.IsNotNullOrEmpty<object>((IEnumerable<object>)customAttributes))
{
if (methodInfo.GetParameters().Length != 2)
{
BMLogger.Warning("Parameter '" + methodInfo.Name + "' should have two parameter.");
}
else if (parameters.ContainsKey(methodInfo.Name))
{
BMLogger.Warning("Parameter of name " + methodInfo.Name + " already exist in assembly " + type.Assembly.FullName);
}
else
{
parameters.Add(methodInfo.Name, methodInfo);
}
}
}
}
private static Type[] FindPresets(Type[] types)
{
List<Type> list = new List<Type>();
foreach (Type type in types)
{
object[] customAttributes = type.GetCustomAttributes(typeof(CustomObjectPresetAttribute), inherit: true);
if (IEnumerableExtensions.IsNotNullOrEmpty<object>((IEnumerable<object>)customAttributes))
{
list.Add(type);
}
}
return list.ToArray();
}
private static void AddPresets(Type[] types)
{
foreach (Type type in types)
{
object[] customAttributes = type.GetCustomAttributes(typeof(CustomObjectPresetAttribute), inherit: true);
if (!IEnumerableExtensions.IsNotNullOrEmpty<object>((IEnumerable<object>)customAttributes))
{
continue;
}
object obj = customAttributes[0];
try
{
Dictionary<string, Type> presetCollection = GetPresetCollection(obj);
if (presetCollection != null)
{
AddPresetToCollection(presetCollection, type, ObjectExtensions.As<CustomObjectPresetAttribute>(obj).name, GetCollectionName(obj));
}
}
catch (Exception exception)
{
BMLogger.ExceptionLog(ObjectExtensions.As<CustomObjectPresetAttribute>(obj).name ?? "", exception);
}
}
}
private static Dictionary<string, Type> GetPresetCollection(object attribute)
{
if (attribute == null || !(attribute is CustomObjectPresetAttribute))
{
return null;
}
if (attribute is HeroPresetAttribute)
{
return heroesPreset;
}
if (attribute is AbilityPresetAttribute)
{
return abilities;
}
if (attribute is GrenadePresetAttribute)
{
return grenades;
}
return customObjectsPreset;
}
private static void AddPresetToCollection(Dictionary<string, Type> collection, Type preset, string name, string collectionName = "")
{
if (collection == null)
{
throw new ArgumentNullException("collection");
}
if ((object)preset == null)
{
throw new ArgumentNullException("preset");
}
if (IEnumerableExtensions.IsNullOrEmpty<char>((IEnumerable<char>)name))
{
throw new ArgumentNullException("name", "is null or empty.");
}
if (collection.ContainsKey(name))
{
if (!disableWarnings)
{
BMLogger.Warning($"{collectionName} Preset of name {name} already exist. Type: {preset} ; Assembly: {preset.Assembly.FullName}");
}
}
else
{
collection.Add(name, preset);
}
}
private static string GetCollectionName(object attribute)
{
if (attribute is HeroPresetAttribute)
{
return "Hero";
}
if (attribute is AbilityPresetAttribute)
{
return "Ability";
}
if (attribute is GrenadePresetAttribute)
{
return "Grenade";
}
return string.Empty;
}
}
public class Settings
{
[JsonIgnore]
public static Settings instance;
[JsonIgnore]
public static string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
[JsonIgnore]
public bool overrideNextBroSpawn;
[JsonIgnore]
public string nextBroSpawn = "";
[JsonIgnore]
public bool disableSpawning;
public bool equalSpawnProbability = true;
public bool automaticSpawn = true;
public float automaticSpawnProbabilty = 25f;
public bool maxHealthAtOne = true;
public bool onlyCustomInHardcore;
public bool disableCustomAvatarFlash = true;
public bool developerMode;
public bool scaleUIWithWindowWidth;
public bool disableTooltips;
public bool scaleUIHeight;
public bool debugLogs;
public List<string> _enabledBros = new List<string>();
public List<List<string>> _notUnlockedBros;
public List<List<string>> _availableBros;
public bool showGeneralSettings = true;
public bool showSpawnSettings = true;
public bool showDeveloperSettings;
public static string FilePath => Path.Combine(directory, "Settings.json");
public static void Load()
{
if (File.Exists(FilePath))
{
instance = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(FilePath));
}
if (instance == null)
{
instance = new Settings();
}
if (instance._notUnlockedBros == null)
{
instance._notUnlockedBros = new List<List<string>>
{
new List<string>(),
new List<string>(),
new List<string>(),
new List<string>(),
new List<string>()
};
}
if (instance._availableBros == null)
{
instance._availableBros = new List<List<string>>
{
new List<string>(),
new List<string>(),
new List<string>(),
new List<string>(),
new List<string>()
};
}
instance.Save();
}
public void Save()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
JsonSerializerSettings val = new JsonSerializerSettings
{
ReferenceLoopHandling = (ReferenceLoopHandling)1
};
string contents = JsonConvert.SerializeObject((object)this, (Formatting)1, val);
File.WriteAllText(FilePath, contents);
}
}
public static class DirectoriesManager
{
public const string JSON_EXTENSION = ".json";
private static string _storageDirectory;
public static string StorageDirectory => _storageDirectory;
public static string BrosDirectory { get; private set; }
public static string WeaponsDirectory { get; private set; }
public static string AbilitiesDi