Decompiled source of Weapons from the Past v1.0.2
BeyondThePast.dll
Decompiled 2 years ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using Gungeon; using ItemAPI; using MonoMod.RuntimeDetour; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BeyondThePast")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BeyondThePast")] [assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3993E3D8-7D4D-41A0-B3DC-1594A8B18D31")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")] namespace ItemAPI { public static class CompanionBuilder { public enum AnimationType { Move, Idle, Fidget, Flight, Hit, Talk, Other } private static GameObject behaviorSpeculatorPrefab; public static Dictionary<string, GameObject> companionDictionary = new Dictionary<string, GameObject>(); public static void Init() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown string companionGuid = ((Component)Game.Items["dog"]).GetComponent<CompanionItem>().CompanionGuid; AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(companionGuid); behaviorSpeculatorPrefab = Object.Instantiate<GameObject>(((Component)orLoadByGuid).gameObject); foreach (Transform item in behaviorSpeculatorPrefab.transform) { Transform val = item; if ((Object)(object)val != (Object)(object)behaviorSpeculatorPrefab.transform) { Object.DestroyImmediate((Object)(object)val); } } Component[] components = behaviorSpeculatorPrefab.GetComponents<Component>(); foreach (Component val2 in components) { if ((object)((object)val2).GetType() != typeof(BehaviorSpeculator)) { Object.DestroyImmediate((Object)(object)val2); } } Object.DontDestroyOnLoad((Object)(object)behaviorSpeculatorPrefab); FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab); behaviorSpeculatorPrefab.SetActive(false); Hook val3 = new Hook((MethodBase)typeof(EnemyDatabase).GetMethod("GetOrLoadByGuid", BindingFlags.Static | BindingFlags.Public), typeof(CompanionBuilder).GetMethod("GetOrLoadByGuid")); } public static AIActor GetOrLoadByGuid(Func<string, AIActor> orig, string guid) { foreach (string key in companionDictionary.Keys) { if (key == guid) { return companionDictionary[key].GetComponent<AIActor>(); } } return orig(guid); } public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_011b: Expected O, but got Unknown if (companionDictionary.ContainsKey(guid)) { Tools.PrintError("CompanionBuilder: Tried to create two companion prefabs with the same GUID!"); return null; } GameObject val = Object.Instantiate<GameObject>(behaviorSpeculatorPrefab); ((Object)val).name = name; tk2dSprite component = SpriteBuilder.SpriteFromResource(defaultSpritePath, val).GetComponent<tk2dSprite>(); component.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = false; val.AddComponent<tk2dSpriteAnimator>(); val.AddComponent<AIAnimator>(); HealthHaver val2 = val.AddComponent<HealthHaver>(); val2.RegisterBodySprite((tk2dBaseSprite)(object)component, false, 0); val2.PreventAllDamage = true; val2.SetHealthMaximum(15000f, (float?)null, false); val2.FullHeal(); AIActor val3 = val.AddComponent<AIActor>(); val3.State = (ActorState)2; val3.EnemyGuid = guid; BehaviorSpeculator component2 = val.GetComponent<BehaviorSpeculator>(); component2.MovementBehaviors = new List<MovementBehaviorBase>(); component2.AttackBehaviors = new List<AttackBehaviorBase>(); component2.TargetBehaviors = new List<TargetBehaviorBase>(); component2.OverrideBehaviors = new List<OverrideBehaviorBase>(); component2.OtherBehaviors = new List<BehaviorBase>(); EnemyDatabaseEntry item = new EnemyDatabaseEntry { myGuid = guid, placeableWidth = 2, placeableHeight = 2, isNormalEnemy = false }; ((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries.Add(item); companionDictionary.Add(guid, val); Object.DontDestroyOnLoad((Object)(object)val); FakePrefab.MarkAsFakePrefab(val); val.SetActive(false); return val; } public static tk2dSpriteAnimationClip AddAnimation(this GameObject obj, string name, string spriteDirectory, int fps, AnimationType type, DirectionType directionType = 0, FlipType flipType = 0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected I4, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_003c: 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) AIAnimator orAddComponent = GameObjectExtensions.GetOrAddComponent<AIAnimator>(obj); DirectionalAnimation val = orAddComponent.GetDirectionalAnimation(name, directionType, type); if (val == null) { DirectionalAnimation val2 = new DirectionalAnimation(); val2.AnimNames = new string[0]; val2.Flipped = (FlipType[])(object)new FlipType[0]; val2.Type = directionType; val2.Prefix = string.Empty; val = val2; } val.AnimNames = val.AnimNames.Concat(new string[1] { name }).ToArray(); val.Flipped = val.Flipped.Concat((IEnumerable<FlipType>)(object)new FlipType[1] { (FlipType)(int)flipType }).ToArray(); orAddComponent.AssignDirectionalAnimation(name, val, type); return BuildAnimation(orAddComponent, name, spriteDirectory, fps); } public static tk2dSpriteAnimationClip BuildAnimation(AIAnimator aiAnimator, string name, string spriteDirectory, int fps) { tk2dSpriteCollectionData val = ((Component)aiAnimator).GetComponent<tk2dSpriteCollectionData>(); if (!Object.op_Implicit((Object)(object)val)) { val = SpriteBuilder.ConstructCollection(((Component)aiAnimator).gameObject, ((Object)aiAnimator).name + "_collection"); } string[] resourceNames = ResourceExtractor.GetResourceNames(); List<int> list = new List<int>(); for (int i = 0; i < resourceNames.Length; i++) { if (resourceNames[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase)) { list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], val)); } } tk2dSpriteAnimationClip val2 = SpriteBuilder.AddAnimation(((BraveBehaviour)aiAnimator).spriteAnimator, val, list, name, (WrapMode)0); val2.fps = fps; return val2; } public static DirectionalAnimation GetDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionType directionType, AnimationType type) { DirectionalAnimation val = null; switch (type) { case AnimationType.Idle: val = aiAnimator.IdleAnimation; break; case AnimationType.Move: val = aiAnimator.MoveAnimation; break; case AnimationType.Flight: val = aiAnimator.FlightAnimation; break; case AnimationType.Hit: val = aiAnimator.HitAnimation; break; case AnimationType.Talk: val = aiAnimator.TalkAnimation; break; } if (val != null) { return val; } return null; } public static void AssignDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionalAnimation animation, AnimationType type) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown switch (type) { case AnimationType.Idle: aiAnimator.IdleAnimation = animation; return; case AnimationType.Move: aiAnimator.MoveAnimation = animation; return; case AnimationType.Flight: aiAnimator.FlightAnimation = animation; return; case AnimationType.Hit: aiAnimator.HitAnimation = animation; return; case AnimationType.Talk: aiAnimator.TalkAnimation = animation; return; case AnimationType.Fidget: aiAnimator.IdleFidgetAnimations.Add(animation); return; } aiAnimator.OtherAnimations.Add(new NamedDirectionalAnimation { anim = animation, name = name }); } } public static class CustomSynergies { public static Hook synergyHook = new Hook((MethodBase)typeof(StringTableManager).GetMethod("GetSynergyString", BindingFlags.Static | BindingFlags.Public), typeof(CustomSynergies).GetMethod("SynergyStringHook")); public static AdvancedSynergyEntry Add(string name, List<string> mandatoryConsoleIDs, List<string> optionalConsoleIDs = null, bool ignoreLichEyeBullets = true) { //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown if (mandatoryConsoleIDs == null || mandatoryConsoleIDs.Count == 0) { Tools.PrintError("Synergy " + name + " has no mandatory items/guns."); return null; } List<int> list = new List<int>(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); List<int> list4 = new List<int>(); foreach (string mandatoryConsoleID in mandatoryConsoleIDs) { PickupObject val = Game.Items[mandatoryConsoleID]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Gun>())) { list2.Add(val.PickupObjectId); } else if (Object.op_Implicit((Object)(object)val) && (Object.op_Implicit((Object)(object)((Component)val).GetComponent<PlayerItem>()) || Object.op_Implicit((Object)(object)((Component)val).GetComponent<PassiveItem>()))) { list.Add(val.PickupObjectId); } } if (optionalConsoleIDs != null) { foreach (string optionalConsoleID in optionalConsoleIDs) { PickupObject val = Game.Items[optionalConsoleID]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Gun>())) { list4.Add(val.PickupObjectId); } else if (Object.op_Implicit((Object)(object)val) && (Object.op_Implicit((Object)(object)((Component)val).GetComponent<PlayerItem>()) || Object.op_Implicit((Object)(object)((Component)val).GetComponent<PassiveItem>()))) { list3.Add(val.PickupObjectId); } } } AdvancedSynergyEntry val2 = new AdvancedSynergyEntry { NameKey = name, MandatoryItemIDs = list, MandatoryGunIDs = list2, OptionalItemIDs = list3, OptionalGunIDs = list4, bonusSynergies = new List<CustomSynergyType>(), statModifiers = new List<StatModifier>() }; Add(val2); return val2; } public static void Add(AdvancedSynergyEntry synergyEntry) { AdvancedSynergyEntry[] second = (AdvancedSynergyEntry[])(object)new AdvancedSynergyEntry[1] { synergyEntry }; GameManager.Instance.SynergyManager.synergies = GameManager.Instance.SynergyManager.synergies.Concat(second).ToArray(); } public static string SynergyStringHook(Func<string, int, string> orig, string key, int index = -1) { string text = orig(key, index); if (string.IsNullOrEmpty(text)) { text = key; } return text; } public static bool HasMTGConsoleID(this PlayerController player, string consoleID) { if (!Game.Items.ContainsID(consoleID)) { return false; } return player.HasPickupID(Game.Items[consoleID].PickupObjectId); } } public class FakePrefab : Component { internal static HashSet<GameObject> ExistingFakePrefabs = new HashSet<GameObject>(); public static bool IsFakePrefab(Object o) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (o is GameObject) { return ExistingFakePrefabs.Contains((GameObject)o); } if (o is Component) { return ExistingFakePrefabs.Contains(((Component)o).gameObject); } return false; } public static void MarkAsFakePrefab(GameObject obj) { ExistingFakePrefabs.Add(obj); Object.DontDestroyOnLoad((Object)(object)obj); } public static GameObject Clone(GameObject obj) { bool flag = IsFakePrefab((Object)(object)obj); bool activeSelf = obj.activeSelf; if (activeSelf) { obj.SetActive(false); } GameObject val = Object.Instantiate<GameObject>(obj); if (activeSelf) { obj.SetActive(true); } ExistingFakePrefabs.Add(val); Object.DontDestroyOnLoad((Object)(object)val); return val; } public static Object Instantiate(Object o, Object new_o) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (o is GameObject && ExistingFakePrefabs.Contains((GameObject)o)) { ((GameObject)new_o).SetActive(true); } else if (o is Component && ExistingFakePrefabs.Contains(((Component)o).gameObject)) { ((Component)new_o).gameObject.SetActive(true); } return new_o; } } public static class FakePrefabHooks { public delegate TResult Func<T1, T2, T3, T4, T5, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5); public static void Init() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown Hook val = new Hook((MethodBase)typeof(PlayerController).GetMethod("AcquirePassiveItemPrefabDirectly"), typeof(FakePrefabHooks).GetMethod("AcquirePassiveItemPrefabDirectly")); Hook val2 = new Hook((MethodBase)typeof(PlayerItem).GetMethod("Pickup"), typeof(FakePrefabHooks).GetMethod("ActivePickup")); Hook val3 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3] { typeof(Object), typeof(Transform), typeof(bool) }), typeof(FakePrefabHooks).GetMethod("InstantiateOPI")); Hook val4 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[2] { typeof(Object), typeof(Transform) }), typeof(FakePrefabHooks).GetMethod("InstantiateOP")); Hook val5 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[1] { typeof(Object) }), typeof(FakePrefabHooks).GetMethod("InstantiateO")); Hook val6 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3] { typeof(Object), typeof(Vector3), typeof(Quaternion) }), typeof(FakePrefabHooks).GetMethod("InstantiateOPR")); Hook val7 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[4] { typeof(Object), typeof(Vector3), typeof(Quaternion), typeof(Transform) }), typeof(FakePrefabHooks).GetMethod("InstantiateOPRP")); } public static void AcquirePassiveItemPrefabDirectly(Action<PlayerController, PassiveItem> orig, PlayerController self, PassiveItem item) { bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)item).gameObject); if (flag) { ((Component)item).gameObject.SetActive(true); } orig(self, item); if (flag) { ((Component)item).gameObject.SetActive(false); } } public static void ActivePickup(Action<PlayerItem, PlayerController> orig, PlayerItem self, PlayerController player) { bool flag = FakePrefab.IsFakePrefab((Object)(object)((Component)self).gameObject); if (flag) { ((Component)self).gameObject.SetActive(true); } orig(self, player); if (flag) { ((Component)self).gameObject.SetActive(false); } } public static Object InstantiateOPI(Func<Object, Transform, bool, Object> orig, Object original, Transform parent, bool instantiateInWorldSpace) { return FakePrefab.Instantiate(original, orig(original, parent, instantiateInWorldSpace)); } public static Object InstantiateOP(Func<Object, Transform, Object> orig, Object original, Transform parent) { return FakePrefab.Instantiate(original, orig(original, parent)); } public static Object InstantiateO(Func<Object, Object> orig, Object original) { return FakePrefab.Instantiate(original, orig(original)); } public static Object InstantiateOPR(Func<Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation) { //IL_0004: 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) return FakePrefab.Instantiate(original, orig(original, position, rotation)); } public static Object InstantiateOPRP(Func<Object, Vector3, Quaternion, Transform, Object> orig, Object original, Vector3 position, Quaternion rotation, Transform parent) { //IL_0004: 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) return FakePrefab.Instantiate(original, orig(original, position, rotation, parent)); } } public static class ItemBuilder { public enum CooldownType { Timed, Damage, PerRoom, None } public enum ShopType { Goopton, Flynt, Cursula, Trorc, OldRed } public static Dictionary<ShopType, GenericLootTable> shopInventories; public static void Init() { FakePrefabHooks.Init(); CompanionBuilder.Init(); Tools.Init(); LoadShopTables(); } private static void LoadShopTables() { shopInventories = new Dictionary<ShopType, GenericLootTable>(); shopInventories.Add(ShopType.Flynt, LoadShopTable("Shop_Key_Items_01")); shopInventories.Add(ShopType.Trorc, LoadShopTable("Shop_Truck_Items_01")); shopInventories.Add(ShopType.Cursula, LoadShopTable("Shop_Curse_Items_01")); shopInventories.Add(ShopType.Goopton, LoadShopTable("Shop_Goop_Items_01")); shopInventories.Add(ShopType.OldRed, LoadShopTable("Shop_Blank_Items_01")); } public static GenericLootTable LoadShopTable(string assetName) { return Tools.sharedAuto1.LoadAsset<GenericLootTable>(assetName); } public static GameObject AddSpriteToObject(string name, string resourcePath, GameObject obj = null) { GameObject val = SpriteBuilder.SpriteFromResource(resourcePath, obj); ((Object)val).name = name; return val; } public static void SetupItem(this PickupObject item, string shortDesc, string longDesc, string idPool = "customItems") { try { ((BraveBehaviour)item).encounterTrackable = null; Databases.Items.SetupItem(item, ((Object)item).name); SpriteBuilder.AddToAmmonomicon(((BraveBehaviour)item).sprite.GetCurrentSpriteDef()); ((BraveBehaviour)item).encounterTrackable.journalData.AmmonomiconSprite = ((BraveBehaviour)item).sprite.GetCurrentSpriteDef().name; GunExt.SetName(item, ((Object)item).name); GunExt.SetShortDescription(item, shortDesc); GunExt.SetLongDescription(item, longDesc); if (item is PlayerItem) { ((PlayerItem)((item is PlayerItem) ? item : null)).consumable = false; } Game.Items.Add(idPool + ":" + ((Object)item).name.ToLower().Replace(" ", "_"), item); Databases.Items.Add(item, false, "ANY"); FakePrefab.MarkAsFakePrefab(((Component)item).gameObject); ((Component)item).gameObject.SetActive(false); } catch (Exception ex) { ETGModConsole.Log(ex.Message, false); ETGModConsole.Log(ex.StackTrace, false); } } public static void AddToSubShop(this PickupObject po, ShopType type, float weight) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown WeightedGameObjectCollection defaultItemDrops = shopInventories[type].defaultItemDrops; WeightedGameObject val = new WeightedGameObject(); val.pickupId = po.PickupObjectId; val.weight = weight; val.rawGameObject = ((Component)po).gameObject; val.forceDuplicatesPossible = false; val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0]; defaultItemDrops.Add(val); } public static void SetCooldownType(this PlayerItem item, CooldownType cooldownType, float value) { item.damageCooldown = -1f; item.roomCooldown = -1; item.timeCooldown = -1f; switch (cooldownType) { case CooldownType.Timed: item.timeCooldown = value; break; case CooldownType.Damage: item.damageCooldown = value; break; case CooldownType.PerRoom: item.roomCooldown = (int)value; break; } } public static StatModifier AddPassiveStatModifier(this PickupObject po, StatType statType, float amount, ModifyMethod method = 0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) StatModifier val = new StatModifier(); val.amount = amount; val.statToBoost = statType; val.modifyType = method; po.AddPassiveStatModifier(val); return val; } public static void AddPassiveStatModifier(this PickupObject po, StatModifier modifier) { if (po is PlayerItem) { PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null); if (val.passiveStatModifiers == null) { val.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier }; } else { val.passiveStatModifiers = val.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray(); } return; } if (po is PassiveItem) { PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null); if (val2.passiveStatModifiers == null) { val2.passiveStatModifiers = (StatModifier[])(object)new StatModifier[1] { modifier }; } else { val2.passiveStatModifiers = val2.passiveStatModifiers.Concat((IEnumerable<StatModifier>)(object)new StatModifier[1] { modifier }).ToArray(); } return; } throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem"); } public static bool RemovePassiveStatModifier(this PickupObject po, StatModifier modifier) { bool flag = false; if (po is PlayerItem) { PlayerItem val = (PlayerItem)(object)((po is PlayerItem) ? po : null); if (val.passiveStatModifiers == null) { return false; } List<StatModifier> list = val.passiveStatModifiers.ToList(); flag = list.Remove(modifier); val.passiveStatModifiers = list.ToArray(); } else { if (!(po is PassiveItem)) { throw new NotSupportedException("Object must be of type PlayerItem or PassiveItem"); } PassiveItem val2 = (PassiveItem)(object)((po is PassiveItem) ? po : null); if (val2.passiveStatModifiers == null) { return false; } List<StatModifier> list2 = val2.passiveStatModifiers.ToList(); flag = list2.Remove(modifier); val2.passiveStatModifiers = list2.ToArray(); } return flag; } public static IEnumerator HandleDuration(PlayerItem item, float duration, PlayerController user, Action<PlayerController> OnFinish) { if (!item.IsCurrentlyActive) { SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: true); SetPrivateType<PlayerItem>(item, "m_activeElapsed", 0f); SetPrivateType<PlayerItem>(item, "m_activeDuration", duration); item.OnActivationStatusChanged?.Invoke(item); GetPrivateType<PlayerItem, float>(item, "m_activeElapsed"); GetPrivateType<PlayerItem, float>(item, "m_activeDuration"); while (GetPrivateType<PlayerItem, float>(item, "m_activeElapsed") < GetPrivateType<PlayerItem, float>(item, "m_activeDuration") && item.IsCurrentlyActive) { yield return null; } SetPrivateType<PlayerItem>(item, "m_isCurrentlyActive", value: false); item.OnActivationStatusChanged?.Invoke(item); OnFinish?.Invoke(user); } } private static void SetPrivateType<T>(T obj, string field, bool value) { FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); field2.SetValue(obj, value); } private static void SetPrivateType<T>(T obj, string field, float value) { FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); field2.SetValue(obj, value); } private static T2 GetPrivateType<T, T2>(T obj, string field) { FieldInfo field2 = typeof(T).GetField(field, BindingFlags.Instance | BindingFlags.NonPublic); return (T2)field2.GetValue(obj); } } public static class Tools { public static bool verbose = false; private static string defaultLog = Path.Combine(ETGMod.ResourcesDirectory, "exampleMod.txt"); public static string modID = "EX"; public static AssetBundle sharedAuto1 = ResourceManager.LoadAssetBundle("shared_auto_001"); public static AssetBundle sharedAuto2 = ResourceManager.LoadAssetBundle("shared_auto_002"); public static void Init() { if (File.Exists(defaultLog)) { File.Delete(defaultLog); } } public static void Print<T>(T obj, string color = "FFFFFF", bool force = false) { if (verbose || force) { ETGModConsole.Log("<color=#" + color + ">" + modID + ": " + obj.ToString() + "</color>", false); } Log(obj.ToString()); } public static void PrintRaw<T>(T obj, bool force = false) { if (verbose || force) { ETGModConsole.Log(obj.ToString(), false); } Log(obj.ToString()); } public static void PrintError<T>(T obj, string color = "FF0000") { ETGModConsole.Log("<color=#" + color + ">" + modID + ": " + obj.ToString() + "</color>", false); Log(obj.ToString()); } public static void PrintException(Exception e, string color = "FF0000") { ETGModConsole.Log("<color=#" + color + ">" + modID + ": " + e.Message + "</color>", false); ETGModConsole.Log(e.StackTrace, false); Log(e.Message); Log("\t" + e.StackTrace); } public static void Log<T>(T obj) { using StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, defaultLog), append: true); streamWriter.WriteLine(obj.ToString()); } public static void Log<T>(T obj, string fileName) { if (!verbose) { return; } using StreamWriter streamWriter = new StreamWriter(Path.Combine(ETGMod.ResourcesDirectory, fileName), append: true); streamWriter.WriteLine(obj.ToString()); } public static void Dissect(this GameObject obj) { Print(((Object)obj).name + " Components:"); Component[] components = obj.GetComponents<Component>(); foreach (Component val in components) { Print(" " + ((object)val).GetType()); } } public static void ShowHitBox(this SpeculativeRigidbody body) { //IL_004e: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) PixelCollider hitboxPixelCollider = body.HitboxPixelCollider; GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = "HitboxDisplay"; val.transform.SetParent(((BraveBehaviour)body).transform); Print(((Object)body).name ?? ""); Print($" Offset: {hitboxPixelCollider.Offset}, Dimesions: {hitboxPixelCollider.Dimensions}"); val.transform.localScale = new Vector3((float)hitboxPixelCollider.Dimensions.x / 16f, (float)hitboxPixelCollider.Dimensions.y / 16f, 1f); Vector3 localPosition = new Vector3((float)hitboxPixelCollider.Offset.x + (float)hitboxPixelCollider.Dimensions.x * 0.5f, (float)hitboxPixelCollider.Offset.y + (float)hitboxPixelCollider.Dimensions.y * 0.5f, -16f) / 16f; val.transform.localPosition = localPosition; } public static void HideHitBox(this SpeculativeRigidbody body) { Transform val = ((BraveBehaviour)body).transform.Find("HitboxDisplay"); if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } public static void ExportTexture(Texture texture) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown File.WriteAllBytes(Path.Combine(ETGMod.ResourcesDirectory, ((Object)texture).name + ".png"), ImageConversion.EncodeToPNG((Texture2D)texture)); } public static void LogPropertiesAndFields<T>(this T obj, string header = "") { Log(header); Log("======================="); if (obj == null) { Log("LogPropertiesAndFields: Null object"); return; } Type type = obj.GetType(); Log($"Type: {type}"); PropertyInfo[] properties = type.GetProperties(); Log($"{typeof(T)} Properties: "); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { try { object value = propertyInfo.GetValue(obj, null); string text = value.ToString(); if ((object)obj?.GetType().GetGenericTypeDefinition() == typeof(List<>)) { List<object> list = value as List<object>; text = $"List[{list.Count}]"; foreach (object item in list) { text = text + "\n\t\t" + item.ToString(); } } Log("\t" + propertyInfo.Name + ": " + text); } catch { } } Log($"{typeof(T)} Fields: "); FieldInfo[] fields = type.GetFields(); FieldInfo[] array2 = fields; foreach (FieldInfo fieldInfo in array2) { Log($"\t{fieldInfo.Name}: {fieldInfo.GetValue(obj)}"); } } } public static class ResourceExtractor { private static string spritesDirectory = Path.Combine(ETGMod.ResourcesDirectory, "sprites"); public static List<Texture2D> GetTexturesFromEmbeddedDirectory(string directoryPath) { directoryPath = directoryPath.Replace('/', '.'); directoryPath = directoryPath.Replace('\\', '.'); List<Texture2D> list = new List<Texture2D>(); string[] resourceNames = GetResourceNames(); foreach (string text in resourceNames) { if (text.EndsWith(".png") && text.StartsWith(directoryPath)) { list.Add(GetTextureFromResource(text)); } } return list; } public static List<Texture2D> GetTexturesFromDirectory(string directoryPath) { if (!Directory.Exists(directoryPath)) { Tools.PrintError(directoryPath + " not found."); return null; } List<Texture2D> list = new List<Texture2D>(); string[] files = Directory.GetFiles(directoryPath); foreach (string text in files) { if (text.EndsWith(".png")) { Texture2D item = BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", "")); list.Add(item); } } return list; } public static Texture2D GetTextureFromFile(string fileName, string extension = ".png") { fileName = fileName.Replace(extension, ""); string text = Path.Combine(spritesDirectory, fileName + extension); if (!File.Exists(text)) { Tools.PrintError(text + " not found."); return null; } return BytesToTexture(File.ReadAllBytes(text), fileName); } public static List<string> GetCollectionFiles() { List<string> list = new List<string>(); string[] files = Directory.GetFiles(spritesDirectory); foreach (string text in files) { if (text.EndsWith(".png")) { list.Add(Path.GetFileName(text).Replace(".png", "")); } } return list; } public static Texture2D BytesToTexture(byte[] bytes, string resourceName) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); ImageConversion.LoadImage(val, bytes); ((Texture)val).filterMode = (FilterMode)0; ((Object)val).name = resourceName; return val; } public static string[] GetLinesFromEmbeddedResource(string filePath) { string text = BytesToString(ExtractEmbeddedResource(filePath)); return text.Split(new char[1] { '\n' }); } public static string[] GetLinesFromFile(string filePath) { string text = BytesToString(File.ReadAllBytes(filePath)); return text.Split(new char[1] { '\n' }); } public static string BytesToString(byte[] bytes) { return Encoding.UTF8.GetString(bytes, 0, bytes.Length); } public static List<string> GetResourceFolders() { List<string> list = new List<string>(); string path = Path.Combine(ETGMod.ResourcesDirectory, "sprites"); if (Directory.Exists(path)) { string[] directories = Directory.GetDirectories(path); foreach (string path2 in directories) { list.Add(Path.GetFileName(path2)); } } return list; } public static byte[] ExtractEmbeddedResource(string filePath) { filePath = filePath.Replace("/", "."); filePath = filePath.Replace("\\", "."); Assembly callingAssembly = Assembly.GetCallingAssembly(); using Stream stream = callingAssembly.GetManifestResourceStream(filePath); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } public static Texture2D GetTextureFromResource(string resourceName) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown byte[] array = ExtractEmbeddedResource(resourceName); if (array == null) { Tools.PrintError("No bytes found in " + resourceName); return null; } Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; string text = resourceName.Substring(0, resourceName.LastIndexOf('.')); if (text.LastIndexOf('.') >= 0) { text = text.Substring(text.LastIndexOf('.') + 1); } ((Object)val).name = text; return val; } public static string[] GetResourceNames() { Assembly callingAssembly = Assembly.GetCallingAssembly(); string[] manifestResourceNames = callingAssembly.GetManifestResourceNames(); if (manifestResourceNames == null) { ETGModConsole.Log("No manifest resources found.", false); return null; } return manifestResourceNames; } } public static class SpriteBuilder { private static tk2dSpriteCollectionData itemCollection = ((BraveBehaviour)PickupObjectDatabase.GetByEncounterName("singularity")).sprite.Collection; private static tk2dSpriteCollectionData ammonomiconCollection = AmmonomiconController.ForceInstance.EncounterIconCollection; private static tk2dSprite baseSprite = ((Component)PickupObjectDatabase.GetByEncounterName("singularity")).GetComponent<tk2dSprite>(); public static GameObject SpriteFromFile(string spriteName, GameObject obj = null) { string fileName = spriteName.Replace(".png", ""); Texture2D textureFromFile = ResourceExtractor.GetTextureFromFile(fileName); if ((Object)(object)textureFromFile == (Object)null) { return null; } return SpriteFromTexture(textureFromFile, spriteName, obj); } public static GameObject SpriteFromResource(string spriteName, GameObject obj = null) { string text = ((!spriteName.EndsWith(".png")) ? ".png" : ""); string text2 = spriteName + text; Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(text2); if ((Object)(object)textureFromResource == (Object)null) { return null; } return SpriteFromTexture(textureFromResource, text2, obj); } public static GameObject SpriteFromTexture(Texture2D texture, string spriteName, GameObject obj = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if ((Object)(object)obj == (Object)null) { obj = new GameObject(); } tk2dSprite val = obj.AddComponent<tk2dSprite>(); int num = AddSpriteToCollection(spriteName, itemCollection); ((tk2dBaseSprite)val).SetSprite(itemCollection, num); ((tk2dBaseSprite)val).SortingOrder = 0; ((tk2dBaseSprite)val).IsPerpendicular = true; obj.GetComponent<BraveBehaviour>().sprite = (tk2dBaseSprite)(object)val; return obj; } public static int AddSpriteToCollection(string resourcePath, tk2dSpriteCollectionData collection) { string text = ((!resourcePath.EndsWith(".png")) ? ".png" : ""); resourcePath += text; Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(resourcePath); tk2dSpriteDefinition val = ConstructDefinition(textureFromResource); val.name = ((Object)textureFromResource).name; return AddSpriteToCollection(val, collection); } public static int AddSpriteToCollection(tk2dSpriteDefinition spriteDefinition, tk2dSpriteCollectionData collection) { tk2dSpriteDefinition[] spriteDefinitions = collection.spriteDefinitions; tk2dSpriteDefinition[] array = (collection.spriteDefinitions = spriteDefinitions.Concat((IEnumerable<tk2dSpriteDefinition>)(object)new tk2dSpriteDefinition[1] { spriteDefinition }).ToArray()); FieldInfo field = typeof(tk2dSpriteCollectionData).GetField("spriteNameLookupDict", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(collection, null); collection.InitDictionary(); return array.Length - 1; } public static int AddToAmmonomicon(tk2dSpriteDefinition spriteDefinition) { return AddSpriteToCollection(spriteDefinition, ammonomiconCollection); } public static tk2dSpriteAnimationClip AddAnimation(tk2dSpriteAnimator animator, tk2dSpriteCollectionData collection, List<int> spriteIDs, string clipName, WrapMode wrapMode = 0) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if ((Object)(object)animator.Library == (Object)null) { animator.Library = ((Component)animator).gameObject.AddComponent<tk2dSpriteAnimation>(); animator.Library.clips = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[0]; ((Behaviour)animator.Library).enabled = true; } List<tk2dSpriteAnimationFrame> list = new List<tk2dSpriteAnimationFrame>(); for (int i = 0; i < spriteIDs.Count; i++) { tk2dSpriteDefinition val = collection.spriteDefinitions[spriteIDs[i]]; if (val.Valid) { list.Add(new tk2dSpriteAnimationFrame { spriteCollection = collection, spriteId = spriteIDs[i] }); } } tk2dSpriteAnimationClip val2 = new tk2dSpriteAnimationClip { name = clipName, fps = 15f, wrapMode = wrapMode }; Array.Resize(ref animator.Library.clips, animator.Library.clips.Length + 1); animator.Library.clips[animator.Library.clips.Length - 1] = val2; val2.frames = list.ToArray(); return val2; } public static SpeculativeRigidbody SetUpSpeculativeRigidbody(this tk2dSprite sprite, IntVector2 offset, IntVector2 dimensions) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0015: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) SpeculativeRigidbody orAddComponent = GameObjectExtensions.GetOrAddComponent<SpeculativeRigidbody>(((Component)sprite).gameObject); PixelCollider val = new PixelCollider(); val.ColliderGenerationMode = (PixelColliderGeneration)0; val.CollisionLayer = (CollisionLayer)3; val.ManualWidth = dimensions.x; val.ManualHeight = dimensions.y; val.ManualOffsetX = offset.x; val.ManualOffsetY = offset.y; orAddComponent.PixelColliders = new List<PixelCollider> { val }; return orAddComponent; } public static tk2dSpriteDefinition ConstructDefinition(Texture2D texture) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) RuntimeAtlasSegment val = Assets.Packer.Pack(texture, false); Material val2 = new Material(ShaderCache.Acquire(PlayerController.DefaultShaderName)); val2.mainTexture = (Texture)(object)val.texture; int width = ((Texture)texture).width; int height = ((Texture)texture).height; float num = 0f; float num2 = 0f; float num3 = (float)width / 16f; float num4 = (float)height / 16f; tk2dSpriteDefinition val3 = new tk2dSpriteDefinition(); val3.normals = (Vector3[])(object)new Vector3[4] { new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f), new Vector3(0f, 0f, -1f) }; val3.tangents = (Vector4[])(object)new Vector4[4] { new Vector4(1f, 0f, 0f, 1f), new Vector4(1f, 0f, 0f, 1f), new Vector4(1f, 0f, 0f, 1f), new Vector4(1f, 0f, 0f, 1f) }; val3.texelSize = new Vector2(0.0625f, 0.0625f); val3.extractRegion = false; val3.regionX = 0; val3.regionY = 0; val3.regionW = 0; val3.regionH = 0; val3.flipped = (FlipMode)0; val3.complexGeometry = false; val3.physicsEngine = (PhysicsEngine)0; val3.colliderType = (ColliderType)1; val3.collisionLayer = (CollisionLayer)6; val3.position0 = new Vector3(num, num2, 0f); val3.position1 = new Vector3(num + num3, num2, 0f); val3.position2 = new Vector3(num, num2 + num4, 0f); val3.position3 = new Vector3(num + num3, num2 + num4, 0f); val3.material = val2; val3.materialInst = val2; val3.materialId = 0; val3.uvs = val.uvs; val3.boundsDataCenter = new Vector3(num3 / 2f, num4 / 2f, 0f); val3.boundsDataExtents = new Vector3(num3, num4, 0f); val3.untrimmedBoundsDataCenter = new Vector3(num3 / 2f, num4 / 2f, 0f); val3.untrimmedBoundsDataExtents = new Vector3(num3, num4, 0f); tk2dSpriteDefinition val4 = val3; val4.name = ((Object)texture).name; return val4; } public static tk2dSpriteCollectionData ConstructCollection(GameObject obj, string name) { tk2dSpriteCollectionData val = obj.AddComponent<tk2dSpriteCollectionData>(); Object.DontDestroyOnLoad((Object)(object)val); val.assetName = name; val.spriteCollectionGUID = name; val.spriteCollectionName = name; val.spriteDefinitions = (tk2dSpriteDefinition[])(object)new tk2dSpriteDefinition[0]; return val; } public static T CopyFrom<T>(this Component comp, T other) where T : Component { Type type = ((object)comp).GetType(); if ((object)type != ((object)other).GetType()) { return default(T); } PropertyInfo[] properties = type.GetProperties(); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (propertyInfo.CanWrite) { try { propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null); } catch { } } } FieldInfo[] fields = type.GetFields(); FieldInfo[] array2 = fields; foreach (FieldInfo fieldInfo in array2) { fieldInfo.SetValue(comp, fieldInfo.GetValue(other)); } return (T)(object)((comp is T) ? comp : null); } public static void SetColor(this tk2dSprite sprite, Color color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) ((BraveBehaviour)sprite).renderer.material.SetColor("_OverrideColor", color); } public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component { return ((Component)(object)go.AddComponent<T>()).CopyFrom(toAdd); } } } namespace BeyondThePast { public class CompassItem : SenseOfDirectionItem { public static int CompassID; private static readonly string theItemName = "Pocket Compass"; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Compass"; GameObject val = new GameObject(theItemName); CompassItem compassItem = val.AddComponent<CompassItem>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "Surprisingly Common"; string longDesc = "Strangely, the needle in this compass always points toward the descending elevator on this specific floor. It's so small and light, that it doesn't really take up any space.\n\nThe words \"Cannon was here\" are engraved upon the back."; ((PickupObject)(object)compassItem).SetupItem(shortDesc, longDesc, "gr"); ((PickupObject)(object)compassItem).AddPassiveStatModifier((StatType)8, 1f, (ModifyMethod)0); CompassID = ((PickupObject)compassItem).PickupObjectId; ((PickupObject)compassItem).CanBeSold = false; PickupObject byId = PickupObjectDatabase.GetById(209); SenseOfDirectionItem val2 = (SenseOfDirectionItem)(object)((byId is SenseOfDirectionItem) ? byId : null); ((SenseOfDirectionItem)compassItem).arrowVFX = val2.arrowVFX; ((PlayerItem)compassItem).damageCooldown = ((PlayerItem)val2).damageCooldown; ((PlayerItem)compassItem).roomCooldown = ((PlayerItem)val2).roomCooldown; ((PlayerItem)compassItem).timeCooldown = ((PlayerItem)val2).timeCooldown; ((PickupObject)compassItem).quality = (ItemQuality)(-100); GameManager.Instance.OnNewLevelFullyLoaded += RemoveOnFloorChange; } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.NameKey == "#EXPLORER") { if (synergy.OptionalItemIDs == null) { synergy.OptionalItemIDs = new List<int>(); } if (!synergy.OptionalItemIDs.Contains(CompassID)) { synergy.OptionalItemIDs.Add(CompassID); if (!synergy.OptionalItemIDs.Contains(209)) { synergy.OptionalItemIDs.Add(209); } if (synergy.MandatoryItemIDs.Count != 1) { ETGModConsole.Log(SynergyHelper.GenerateModEditedSynergyProblem(synergy, "Sense of Direction", theItemName), false); } synergy.MandatoryItemIDs.RemoveAll((int x) => x == 209); } } else { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(209) && !synergy.OptionalItemIDs.Contains(CompassID)) { synergy.OptionalItemIDs.Add(CompassID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(209)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Sense of Direction", theItemName), false); } } } public static void RemoveOnFloorChange() { PlayerController[] allPlayers = GameManager.Instance.AllPlayers; foreach (PlayerController val in allPlayers) { if (!Object.op_Implicit((Object)(object)val)) { continue; } for (int num = val.activeItems.Count - 1; num >= 0; num--) { PlayerItem val2 = val.activeItems[num]; if (val2 is CompassItem) { DebrisObject val3 = val.DropActiveItem(val2, 4f, false); Object.Destroy((Object)(object)((Component)val3).gameObject); } } } } } public class LonelinessCookie : RationItem { public static int LonelinessCookieID; private static readonly string theItemName = "Loneliness Cookie"; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Loneliness_Cookie"; GameObject val = new GameObject(theItemName); LonelinessCookie lonelinessCookie = val.AddComponent<LonelinessCookie>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "It's Delicious!"; string longDesc = "Heals for one full heart. Automatically used if you run out of health.\n\nBaked fresh every morning by Mom! It's to die for! Or, just maybe, to live for... if only you could share them."; ((PickupObject)(object)lonelinessCookie).SetupItem(shortDesc, longDesc, "gr"); LonelinessCookieID = ((PickupObject)lonelinessCookie).PickupObjectId; PickupObject byId = PickupObjectDatabase.GetById(412); HealPlayerItem val2 = (HealPlayerItem)(object)((byId is HealPlayerItem) ? byId : null); ((RationItem)lonelinessCookie).healingAmount = 1f; ((RationItem)lonelinessCookie).healVFX = val2.healVFX; ((PlayerItem)lonelinessCookie).damageCooldown = ((PlayerItem)val2).damageCooldown; ((PlayerItem)lonelinessCookie).roomCooldown = ((PlayerItem)val2).roomCooldown; ((PlayerItem)lonelinessCookie).timeCooldown = ((PlayerItem)val2).timeCooldown; ((PlayerItem)lonelinessCookie).consumable = ((PlayerItem)val2).consumable; ((PlayerItem)lonelinessCookie).consumableOnActiveUse = ((PlayerItem)val2).consumableOnActiveUse; ((PlayerItem)lonelinessCookie).numberOfUses = ((PlayerItem)val2).numberOfUses; ((PickupObject)lonelinessCookie).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(412) && !synergy.OptionalItemIDs.Contains(LonelinessCookieID)) { synergy.OptionalItemIDs.Add(LonelinessCookieID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(412)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Friendship Cookie", theItemName), false); } } } public class FakeHeroBandana : PassiveItem { public static int FakeHeroBandanaID; private static readonly string theItemName = "Fake Hero Bandana"; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Fake_Hero_Bandana"; GameObject val = new GameObject(theItemName); FakeHeroBandana fakeHeroBandana = val.AddComponent<FakeHeroBandana>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "Limitless?"; string longDesc = "Ammo Capacity multiplied by 1.04.\n\nThis simple bandana, which once covered the brow of an ancient... wait a minute, this is just a cheap replica made by a child playing hero."; ((PickupObject)(object)fakeHeroBandana).SetupItem(shortDesc, longDesc, "gr"); FakeHeroBandanaID = ((PickupObject)fakeHeroBandana).PickupObjectId; ((PickupObject)(object)fakeHeroBandana).AddPassiveStatModifier((StatType)9, 1.04f, (ModifyMethod)1); ((PickupObject)fakeHeroBandana).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.NameKey == "#TRUEHERO") { if (synergy.OptionalItemIDs == null) { synergy.OptionalItemIDs = new List<int>(); } if (!synergy.OptionalItemIDs.Contains(FakeHeroBandanaID)) { synergy.OptionalItemIDs.Add(FakeHeroBandanaID); if (!synergy.OptionalItemIDs.Contains(255)) { synergy.OptionalItemIDs.Add(255); } if (synergy.MandatoryItemIDs.Count != 2) { ETGModConsole.Log(SynergyHelper.GenerateModEditedSynergyProblem(synergy, "Ancient Hero's Bandana", theItemName), false); } synergy.MandatoryItemIDs.RemoveAll((int x) => x == 255); } } else { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(255) && !synergy.OptionalItemIDs.Contains(FakeHeroBandanaID)) { synergy.OptionalItemIDs.Add(FakeHeroBandanaID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(255)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Ancient Hero's Bandana", theItemName), false); } } } } public class OldBulletsBlessing : PassiveItem { public static int OldBulletsBlessingID; private static readonly List<int> possibleItems = new List<int> { 108, 448, 447, 558, 250 }; [SerializeField] private bool givenMapThisFloor = false; [SerializeField] private bool givenCompassThisFloor = false; [SerializeField] private int itemIDGivenLastFloor = 109; [SerializeField] private int lastCheckedFloor = -1; public static void Register() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) string text = "Old Bullet's Blessing"; string resourcePath = "BeyondThePast/Resources/Old_Bullets_Blessing"; GameObject val = new GameObject(text); OldBulletsBlessing oldBulletsBlessing = val.AddComponent<OldBulletsBlessing>(); ItemBuilder.AddSpriteToObject(text, resourcePath, val); string shortDesc = "Aim True, My..."; string longDesc = "Every floor you gain a random item from a select range, that you can only use on this floor. The first two chests you open every floor will also contain the Map and the Pocket Compass (does not work on mimics).\n\nThe Bullet still remembers the words of his late mentor."; ((PickupObject)(object)oldBulletsBlessing).SetupItem(shortDesc, longDesc, "gr"); OldBulletsBlessingID = ((PickupObject)oldBulletsBlessing).PickupObjectId; ((PickupObject)oldBulletsBlessing).quality = (ItemQuality)(-100); } public override void Pickup(PlayerController player) { if (!base.m_pickedUp) { if (Chest.OnPostOpen == null) { Chest.OnPostOpen = delegate { }; } Chest.OnPostOpen = (Action<Chest, PlayerController>)Delegate.Combine(Chest.OnPostOpen, new Action<Chest, PlayerController>(OnOpenChest)); player.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Combine(player.OnNewFloorLoaded, new Action<PlayerController>(OnNewFloor)); ((PassiveItem)this).Pickup(player); } } public override DebrisObject Drop(PlayerController player) { DebrisObject result = ((PassiveItem)this).Drop(player); Cleanup(player); return result; } protected override void OnDestroy() { ((PassiveItem)this).OnDestroy(); Cleanup(((PassiveItem)this).Owner); } private void Cleanup(PlayerController player) { Chest.OnPostOpen = (Action<Chest, PlayerController>)Delegate.Remove(Chest.OnPostOpen, new Action<Chest, PlayerController>(OnOpenChest)); if (Object.op_Implicit((Object)(object)player)) { player.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Remove(player.OnNewFloorLoaded, new Action<PlayerController>(OnNewFloor)); } } private void OnNewFloor(PlayerController player) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)player) && lastCheckedFloor != GameManager.Instance.CurrentFloor && (int)GameManager.Instance.CurrentLevelOverrideState != 4) { lastCheckedFloor = GameManager.Instance.CurrentFloor; givenMapThisFloor = false; givenCompassThisFloor = false; DestroyAllZeldaItems(player); if (player.activeItems.Count < player.maxActiveItemsHeld) { GiveRandomZeldaItem(player); } } } private void GiveRandomZeldaItem(PlayerController player) { int num; for (num = itemIDGivenLastFloor; num == itemIDGivenLastFloor; num = possibleItems[Random.Range(0, possibleItems.Count)]) { } itemIDGivenLastFloor = num; GiveActiveZeldaItem(player, num); foreach (PlayerItem activeItem in player.activeItems) { if (Object.op_Implicit((Object)(object)activeItem) && Object.op_Implicit((Object)(object)((Component)activeItem).GetComponent<ZeldaItemTracker>())) { ((PickupObject)activeItem).CanBeSold = false; if (((PickupObject)activeItem).PickupObjectId == 558) { EmptyBottleItem val = (EmptyBottleItem)(object)((activeItem is EmptyBottleItem) ? activeItem : null); val.Contents = (EmptyBottleContents)1; } } } } private void GiveActiveZeldaItem(PlayerController player, int id) { PickupObject byId = PickupObjectDatabase.GetById(id); PlayerItem val = (PlayerItem)(object)((byId is PlayerItem) ? byId : null); ((Component)val).gameObject.AddComponent<ZeldaItemTracker>(); EncounterTrackable.SuppressNextNotification = true; ((PickupObject)val).Pickup(player); EncounterTrackable.SuppressNextNotification = false; Object.Destroy((Object)(object)((Component)val).gameObject.GetComponent<ZeldaItemTracker>()); } private void DestroyAllZeldaItems(PlayerController player) { for (int num = player.passiveItems.Count - 1; num >= 0; num--) { PassiveItem val = player.passiveItems[num]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<ZeldaItemTracker>())) { DebrisObject val2 = player.DropPassiveItem(val); Object.Destroy((Object)(object)((Component)val2).gameObject); } } for (int num2 = player.activeItems.Count - 1; num2 >= 0; num2--) { PlayerItem val3 = player.activeItems[num2]; if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)((Component)val3).GetComponent<ZeldaItemTracker>())) { DebrisObject val4 = player.DropActiveItem(val3, 4f, false); Object.Destroy((Object)(object)((Component)val4).gameObject); } } } private void OnOpenChest(Chest chest, PlayerController player) { if (!Object.op_Implicit((Object)(object)((PassiveItem)this).Owner) || !((Object)(object)player == (Object)(object)((PassiveItem)this).Owner) || !Object.op_Implicit((Object)(object)chest) || chest.IsMimic) { return; } if (!givenMapThisFloor && !givenCompassThisFloor) { if (Random.Range(0, 2) == 0) { GiveMap(player); } else { GiveCompass(player); } } else if (!givenMapThisFloor) { GiveMap(player); } else if (!givenCompassThisFloor) { GiveCompass(player); } } private void GiveCompass(PlayerController player) { givenCompassThisFloor = true; PickupObject byId = PickupObjectDatabase.GetById(CompassItem.CompassID); PlayerItem val = (PlayerItem)(object)((byId is PlayerItem) ? byId : null); EncounterTrackable.SuppressNextNotification = true; ((PickupObject)val).Pickup(player); EncounterTrackable.SuppressNextNotification = false; } private void GiveMap(PlayerController player) { givenMapThisFloor = true; player.EverHadMap = true; player.stats.RecalculateStats(player, false, false); if ((Object)(object)Minimap.Instance != (Object)null) { Minimap.Instance.RevealAllRooms(true); } } } public class ZeldaItemTracker : MonoBehaviour { } public class PackLeader : PassiveItem { public static int PackLeaderID; private int companionCountAtLastUpdate = 0; private StatModifier statBuff; private Coroutine checkForCompanionCoroutine; private Coroutine checkForColtCoroutine; public static void Register() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) string text = "Pack Leader"; string resourcePath = "BeyondThePast/Resources/Pack_Leader"; GameObject val = new GameObject(text); PackLeader packLeader = val.AddComponent<PackLeader>(); ItemBuilder.AddSpriteToObject(text, resourcePath, val); string shortDesc = "Strength Of The Pack"; string longDesc = "Increases movement speed by 0.25 for every companion you have."; ((PickupObject)(object)packLeader).SetupItem(shortDesc, longDesc, "gr"); PackLeaderID = ((PickupObject)packLeader).PickupObjectId; ((PickupObject)packLeader).quality = (ItemQuality)(-100); } public override void Pickup(PlayerController player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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_001d: 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_0032: Expected O, but got Unknown if (!base.m_pickedUp) { statBuff = new StatModifier { statToBoost = (StatType)0, modifyType = (ModifyMethod)0, amount = 0f }; player.ownerlessStatModifiers.Add(statBuff); player.stats.RecalculateStats(player, false, false); checkForCompanionCoroutine = ((MonoBehaviour)player).StartCoroutine(CheckForCompanion()); checkForColtCoroutine = ((MonoBehaviour)player).StartCoroutine(CheckForColt()); ((PassiveItem)this).Pickup(player); } } private IEnumerator CheckForColt() { while (true) { PlayerController owner = ((PassiveItem)this).Owner; object obj; if (owner == null) { obj = null; } else { GunInventory inventory = owner.inventory; obj = ((inventory != null) ? inventory.AllGuns : null); } if (obj != null) { foreach (Gun item in ((PassiveItem)this).Owner.inventory.AllGuns) { if (((PickupObject)item).PickupObjectId == 62 && (!item.InfiniteAmmo || !((PickupObject)item).PreventStartingOwnerFromDropping)) { item.InfiniteAmmo = true; ((PickupObject)item).PreventStartingOwnerFromDropping = true; } } } yield return (object)new WaitForSeconds(1f); } } private IEnumerator CheckForCompanion() { while (true) { if (Object.op_Implicit((Object)(object)((PassiveItem)this).Owner) && ((PassiveItem)this).Owner.companions != null && ((PassiveItem)this).Owner.companions.Count != companionCountAtLastUpdate) { companionCountAtLastUpdate = ((PassiveItem)this).Owner.companions.Count; OnChangeEvent(companionCountAtLastUpdate); } yield return (object)new WaitForSeconds(0.5f); } } public void OnChangeEvent(int newValue) { if (Object.op_Implicit((Object)(object)((PassiveItem)this).Owner)) { statBuff.amount = 0.25f * (float)newValue; ((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, false, false); } } public override DebrisObject Drop(PlayerController player) { DebrisObject result = ((PassiveItem)this).Drop(player); Cleanup(player); return result; } protected override void OnDestroy() { ((PassiveItem)this).OnDestroy(); Cleanup(((PassiveItem)this).Owner); } private void Cleanup(PlayerController player) { if (Object.op_Implicit((Object)(object)player)) { ((MonoBehaviour)player).StopCoroutine(checkForCompanionCoroutine); checkForCompanionCoroutine = null; ((MonoBehaviour)player).StopCoroutine(checkForColtCoroutine); checkForColtCoroutine = null; player.ownerlessStatModifiers.Remove(statBuff); statBuff = null; player.stats.RecalculateStats(player, false, false); } } } public class EmbarrassingPhoto : RagePassiveItem { public static int EmbarrassingPhotoID; private static readonly string theItemName = "Embarrassing Photo"; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Group_Photo"; GameObject val = new GameObject(theItemName); EmbarrassingPhoto embarrassingPhoto = val.AddComponent<EmbarrassingPhoto>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "Why Did I Do That..."; string longDesc = "A photo that the Convict brought with her to the Gungeon. Deal extra damage for a short time after getting hit.\n\nShe often looks at the photo, longing to once again change her past."; ((PickupObject)(object)embarrassingPhoto).SetupItem(shortDesc, longDesc, "gr"); EmbarrassingPhotoID = ((PickupObject)embarrassingPhoto).PickupObjectId; PickupObject byId = PickupObjectDatabase.GetById(353); RagePassiveItem obj = (RagePassiveItem)(object)((byId is RagePassiveItem) ? byId : null); FieldInfo[] fields = typeof(RagePassiveItem).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(embarrassingPhoto, fieldInfo.GetValue(obj)); } ((PickupObject)embarrassingPhoto).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(353) && !synergy.OptionalItemIDs.Contains(EmbarrassingPhotoID)) { synergy.OptionalItemIDs.Add(EmbarrassingPhotoID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(353)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Supply Drop", theItemName), false); } } } public class EmptyBriefcase : PassiveItem { public static int EmptyBriefcaseID; public static void Register() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) string text = "Empty Briefcase"; string resourcePath = "BeyondThePast/Resources/Empty_Briefcase"; GameObject val = new GameObject(text); EmptyBriefcase emptyBriefcase = val.AddComponent<EmptyBriefcase>(); ItemBuilder.AddSpriteToObject(text, resourcePath, val); string shortDesc = "Broke"; string longDesc = "Increases active item capacity, but also increases prices at shops.\n\nA briefcase that once held a fortune. While the money is long gone, people regularly assume otherwise. At least it can still be used to carry other things."; ((PickupObject)(object)emptyBriefcase).SetupItem(shortDesc, longDesc, "gr"); EmptyBriefcaseID = ((PickupObject)emptyBriefcase).PickupObjectId; ((PickupObject)(object)emptyBriefcase).AddPassiveStatModifier((StatType)8, 2f, (ModifyMethod)0); ((PickupObject)(object)emptyBriefcase).AddPassiveStatModifier((StatType)13, 1.1f, (ModifyMethod)1); ((PickupObject)emptyBriefcase).quality = (ItemQuality)(-100); } } public class BeyondThePast : ETGModule { public static readonly string MOD_NAME = "Beyond The Past - Stronger Starting Loadouts"; public static bool NonMedalMarine = false; public static bool ModEnabled; public override void Init() { ModEnabled = PlayerPrefs.GetInt("BeyondThePastEnabled", 1) == 1; } public override void Exit() { } public override void Start() { //IL_013c: Unknown result type (might be due to invalid IL or missing references) try { ETGModConsole.Commands.AddGroup("beyondThePast"); ETGModConsole.Commands.GetGroup("beyondThePast").AddUnit("enabled", (Action<string[]>)delegate { ModEnabled = !ModEnabled; ETGModConsole.Log("Beyond The Past is now " + (ModEnabled ? "enabled" : "disabled") + ".", false); PlayerPrefs.SetInt("BeyondThePastEnabled", ModEnabled ? 1 : 0); PlayerPrefs.Save(); }); ItemBuilder.Init(); if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)2, (CharacterSpecificGungeonFlags)1000)) { LoadRobotModule(); } if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)8, (CharacterSpecificGungeonFlags)1000)) { LoadBulletModule(); } if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)1, (CharacterSpecificGungeonFlags)1000)) { LoadConvictModule(); } if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)6, (CharacterSpecificGungeonFlags)1000)) { LoadHunterModule(); } if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)0, (CharacterSpecificGungeonFlags)1000)) { LoadPilotModule(); } if (GameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)5, (CharacterSpecificGungeonFlags)1000)) { LoadMarineModule(); } LoadCultistModule(); SynergyHelper.Help(); new Hook((MethodBase)typeof(PlayerController).GetMethod("InitializeInventory", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BeyondThePast).GetMethod("OverrideStartingInventory")); string text = $"{MOD_NAME} v{((ETGModule)this).Metadata.Version} initialized"; if (!ModEnabled) { text += ", currently disabled"; } ETGModConsole.Log(text, false); } catch (Exception arg) { ETGModConsole.Log($"<color=red>Exception in Start: {arg}</color>", false); } } public static void OverrideStartingInventory(Action<PlayerController> orig, PlayerController self) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected I4, but got Unknown //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Invalid comparison between Unknown and I4 List<string> list = new List<string> { "PlayerConvict(Clone)", "PlayerMarine(Clone)", "PlayerGuide(Clone)", "PlayerRogue(Clone)", "PlayerBullet(Clone)", "PlayerRobot(Clone)", "PlayerCoopCultist(Clone)" }; if (ModEnabled && (int)self.characterIdentity == 7 && (int)GameManager.Instance.CurrentGameType == 0) { self.startingPassiveItemIds = new List<int>(); self.startingActiveItemIds = new List<int> { WarningItem.WarningItemID }; self.startingGunIds = new List<int>(); self.startingAlternateGunIds = new List<int>(); orig(self); return; } if (!ModEnabled || !list.Contains(((Object)self).name) || (!GameStatsManager.Instance.GetCharacterSpecificFlag(self.characterIdentity, (CharacterSpecificGungeonFlags)1000) && ((Object)self).name != "PlayerCoopCultist(Clone)")) { orig(self); return; } PlayableCharacters characterIdentity = self.characterIdentity; PlayableCharacters val = characterIdentity; switch ((int)val) { case 0: self.startingPassiveItemIds = new List<int> { 187, 473, 491, MasterOfUnlocking.MasterOfUnlockingID }; self.startingActiveItemIds = new List<int> { 356 }; self.startingGunIds = new List<int> { 89 }; self.startingAlternateGunIds = new List<int> { 651 }; break; case 1: self.startingPassiveItemIds = new List<int> { EmbarrassingPhoto.EmbarrassingPhotoID, EmptyBriefcase.EmptyBriefcaseID }; self.startingActiveItemIds = new List<int> { PremiumCigarettes.PremiumCigarettesID, 460 }; self.startingGunIds = new List<int> { 80, 2 }; self.startingAlternateGunIds = new List<int> { 652, 2 }; break; case 2: self.startingPassiveItemIds = new List<int> { 410, RecycleItem.RecycleItemID }; self.startingActiveItemIds = new List<int> { 411 }; self.startingGunIds = new List<int> { 88, 576 }; self.startingAlternateGunIds = new List<int> { 812, 576 }; break; case 5: if (!NonMedalMarine) { self.startingPassiveItemIds = new List<int> { 494 }; self.startingActiveItemIds = new List<int> { SupplySupport.SupplySupportID }; self.startingGunIds = new List<int> { 86 }; self.startingAlternateGunIds = new List<int> { 809 }; } else { self.startingPassiveItemIds = new List<int> { 354 }; self.startingActiveItemIds = new List<int> { SupplySupport.SupplySupportID }; self.startingGunIds = new List<int> { 86, 229 }; self.startingAlternateGunIds = new List<int> { 809, 229 }; } break; case 6: self.startingPassiveItemIds = new List<int> { 300, 492, PackLeader.PackLeaderID }; self.startingActiveItemIds = new List<int>(); self.startingGunIds = new List<int> { 62, 4 }; self.startingAlternateGunIds = new List<int> { 62, 4 }; break; case 8: self.startingPassiveItemIds = new List<int> { 414, 572, OldBulletsBlessing.OldBulletsBlessingID }; self.startingActiveItemIds = new List<int>(); self.startingGunIds = new List<int> { 417 }; self.startingAlternateGunIds = new List<int> { 813 }; break; case 7: if ((int)GameManager.Instance.CurrentGameType == 1) { self.startingPassiveItemIds = new List<int> { 326, FakeHeroBandana.FakeHeroBandanaID, 375 }; self.startingActiveItemIds = new List<int> { 412 }; self.startingGunIds = new List<int> { 24, 10 }; self.startingAlternateGunIds = new List<int> { 811, 10 }; } break; } orig(self); } private void LoadPilotModule() { MasterOfUnlocking.SetupHook(); MasterOfUnlocking.Register(); } private void LoadConvictModule() { EmptyBriefcase.Register(); EmbarrassingPhoto.Register(); PremiumCigarettes.Register(); } private void LoadRobotModule() { RecycleItem.SetupHook(); RecycleItem.Register(); } private void LoadMarineModule() { SupplySupport.Register(); } private void LoadHunterModule() { PackLeader.Register(); } private void LoadBulletModule() { OldBulletsBlessing.Register(); CompassItem.Register(); } private void LoadCultistModule() { FakeHeroBandana.Register(); LonelinessCookie.Register(); WarningItem.Register(); } } public class MasterOfUnlocking : SpawnItemOnRoomClearItem { public static int MasterOfUnlockingID; private static readonly string theItemName = "Master of Unlocking"; public static Action<int> OnKeysChanged = delegate { }; private StatModifier statBuff; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Master_of_Unlocking"; GameObject val = new GameObject(theItemName); MasterOfUnlocking masterOfUnlocking = val.AddComponent<MasterOfUnlocking>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "Play Well, Get Keys"; string longDesc = "Increases the chance of gaining a key upon clearing a room. Increases projectile speed by 5% for every key you are holding."; ((PickupObject)(object)masterOfUnlocking).SetupItem(shortDesc, longDesc, "gr"); MasterOfUnlockingID = ((PickupObject)masterOfUnlocking).PickupObjectId; PickupObject byId = PickupObjectDatabase.GetById(140); SpawnItemOnRoomClearItem obj = (SpawnItemOnRoomClearItem)(object)((byId is SpawnItemOnRoomClearItem) ? byId : null); FieldInfo[] fields = typeof(SpawnItemOnRoomClearItem).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(masterOfUnlocking, fieldInfo.GetValue(obj)); } ((PickupObject)masterOfUnlocking).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.NameKey == "#KEYWITNESS" || synergy.NameKey == "#MASTEROFUNLOCKING") { synergy.RequiresAtLeastOneGunAndOneItem = false; if (synergy.OptionalItemIDs == null) { synergy.OptionalItemIDs = new List<int>(); } if (!synergy.OptionalItemIDs.Contains(MasterOfUnlockingID)) { synergy.OptionalItemIDs.Add(MasterOfUnlockingID); if (!synergy.OptionalItemIDs.Contains(140)) { synergy.OptionalItemIDs.Add(140); } if (synergy.MandatoryItemIDs.Count != 2) { ETGModConsole.Log(SynergyHelper.GenerateModEditedSynergyProblem(synergy, "Master of Unlocking", theItemName), false); } synergy.MandatoryItemIDs.RemoveAll((int x) => x == 140); } } else { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(140) && !synergy.OptionalItemIDs.Contains(MasterOfUnlockingID)) { synergy.OptionalItemIDs.Add(MasterOfUnlockingID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(140)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Master of Unlocking", theItemName), false); } } } public override void Pickup(PlayerController player) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //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_001d: 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_0032: Expected O, but got Unknown if (!((PassiveItem)this).m_pickedUp) { statBuff = new StatModifier { statToBoost = (StatType)6, modifyType = (ModifyMethod)1, amount = 1f }; player.ownerlessStatModifiers.Add(statBuff); player.stats.RecalculateStats(player, false, false); OnKeysChanged = (Action<int>)Delegate.Combine(OnKeysChanged, new Action<int>(OnChangeEvent)); ((SpawnItemOnRoomClearItem)this).Pickup(player); } } public static void SetupHook() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) new Hook((MethodBase)typeof(PlayerConsumables).GetProperty("KeyBullets").GetSetMethod(), typeof(MasterOfUnlocking).GetMethod("CheckForKeys")); } public static void CheckForKeys(Action<PlayerConsumables, int> orig, PlayerConsumables self, int value) { orig(self, value); OnKeysChanged(value); } private void OnChangeEvent(int newValue) { if (Object.op_Implicit((Object)(object)((PassiveItem)this).Owner)) { statBuff.amount = 1f + 0.05f * (float)newValue; ((PassiveItem)this).Owner.stats.RecalculateStats(((PassiveItem)this).Owner, false, false); } } public override DebrisObject Drop(PlayerController player) { DebrisObject result = ((SpawnItemOnRoomClearItem)this).Drop(player); Cleanup(player); return result; } protected override void OnDestroy() { ((SpawnItemOnRoomClearItem)this).OnDestroy(); Cleanup(((PassiveItem)this).Owner); } private void Cleanup(PlayerController player) { if (Object.op_Implicit((Object)(object)player)) { OnKeysChanged = (Action<int>)Delegate.Remove(OnKeysChanged, new Action<int>(OnChangeEvent)); player.ownerlessStatModifiers.Remove(statBuff); statBuff = null; player.stats.RecalculateStats(player, false, false); } } } public class PremiumCigarettes : SpawnObjectPlayerItem { public static int PremiumCigarettesID; private static readonly string theItemName = "Premium Cigarettes"; private static readonly bool damageIncreasesWithEveryUse = false; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Cigarettes"; GameObject val = new GameObject(theItemName); PremiumCigarettes premiumCigarettes = val.AddComponent<PremiumCigarettes>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); string shortDesc = "Hazardous To Health"; string longDesc = "Premium or not, can result in serious health problems and even death. They do have a certain appeal though."; ((PickupObject)(object)premiumCigarettes).SetupItem(shortDesc, longDesc, "gr"); PremiumCigarettesID = ((PickupObject)premiumCigarettes).PickupObjectId; PickupObject byId = PickupObjectDatabase.GetById(203); SpawnObjectPlayerItem val2 = (SpawnObjectPlayerItem)(object)((byId is SpawnObjectPlayerItem) ? byId : null); FieldInfo[] fields = typeof(SpawnObjectPlayerItem).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(premiumCigarettes, fieldInfo.GetValue(val2)); } ((PlayerItem)premiumCigarettes).damageCooldown = ((PlayerItem)val2).damageCooldown; ((PlayerItem)premiumCigarettes).roomCooldown = ((PlayerItem)val2).roomCooldown; ((PlayerItem)premiumCigarettes).timeCooldown = ((PlayerItem)val2).timeCooldown; ((PickupObject)premiumCigarettes).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.NameKey == "#COFFEEANDCIGS") { if (synergy.OptionalItemIDs == null) { synergy.OptionalItemIDs = new List<int>(); } if (!synergy.OptionalItemIDs.Contains(PremiumCigarettesID)) { synergy.OptionalItemIDs.Add(PremiumCigarettesID); if (!synergy.OptionalItemIDs.Contains(203)) { synergy.OptionalItemIDs.Add(203); } if (synergy.MandatoryItemIDs.Count != 2) { ETGModConsole.Log(SynergyHelper.GenerateModEditedSynergyProblem(synergy, "Cigarettes", theItemName), false); } synergy.MandatoryItemIDs.RemoveAll((int x) => x == 203); } } else { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(203) && !synergy.OptionalItemIDs.Contains(PremiumCigarettesID)) { synergy.OptionalItemIDs.Add(PremiumCigarettesID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(203)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Cigarettes", theItemName), false); } } } public override bool CanBeUsed(PlayerController user) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 return (int)user.characterIdentity != 2 && !user.ForceZeroHealthState && ((SpawnObjectPlayerItem)this).CanBeUsed(user); } protected override void DoEffect(PlayerController user) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown float num = 0.5f; if (damageIncreasesWithEveryUse) { CigarettesCounter component = ((Component)user).GetComponent<CigarettesCounter>(); float num2; if (Object.op_Implicit((Object)(object)component)) { component.CigarettesUsed++; num2 = component.CigarettesUsed; } else { ((Component)user).gameObject.AddComponent<CigarettesCounter>(); num2 = 1f; } num *= num2; } bool playerHasTakenDamageInThisRoom = false; bool hasTakenDamageThisRun = user.HasTakenDamageThisRun; bool hasTakenDamageThisFloor = user.HasTakenDamageThisFloor; if (user.CurrentRoom != null) { playerHasTakenDamageInThisRoom = user.CurrentRoom.PlayerHasTakenDamageInThisRoom; } ((BraveBehaviour)user).healthHaver.NextDamageIgnoresArmor = true; ((BraveBehaviour)user).healthHaver.ApplyDamage(num, Vector2.zero, StringTableManager.GetEnemiesString("#SMOKING", -1), (CoreDamageTypes)0, (DamageCategory)0, true, (PixelCollider)null, false); user.HasTakenDamageThisRun = hasTakenDamageThisRun; user.HasTakenDamageThisFloor = hasTakenDamageThisFloor; if (user.CurrentRoom != null) { user.CurrentRoom.PlayerHasTakenDamageInThisRoom = playerHasTakenDamageInThisRoom; } StatModifier item = new StatModifier { statToBoost = (StatType)4, modifyType = (ModifyMethod)0, amount = 1f }; user.ownerlessStatModifiers.Add(item); user.stats.RecalculateStats(user, false, false); base.IsCigarettes = false; ((SpawnObjectPlayerItem)this).DoEffect(user); base.IsCigarettes = true; } } public class CigarettesCounter : MonoBehaviour { public int CigarettesUsed = 1; } public class RecycleItem : PassiveItem { public static int RecycleItemID; private Coroutine checkForHandCoroutine; public static void Register() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) string text = "Recycle-inator"; string resourcePath = "BeyondThePast/Resources/Recycle_Item"; GameObject val = new GameObject(text); RecycleItem recycleItem = val.AddComponent<RecycleItem>(); ItemBuilder.AddSpriteToObject(text, resourcePath, val); string shortDesc = "For A Good Cause"; string longDesc = "Permanently increases damage by 5% for every junk you ever picked up. Destroyed chests are guaranteed to drop junk.\n\nEven the clueless scientist who made it agrees on the importance of the cause."; ((PickupObject)(object)recycleItem).SetupItem(shortDesc, longDesc, "gr"); RecycleItemID = ((PickupObject)recycleItem).PickupObjectId; ((PickupObject)recycleItem).quality = (ItemQuality)(-100); } public override void Pickup(PlayerController player) { if (!base.m_pickedUp) { checkForHandCoroutine = ((MonoBehaviour)player).StartCoroutine(CheckForHand()); ((PassiveItem)this).Pickup(player); } } public override DebrisObject Drop(PlayerController player) { DebrisObject result = ((PassiveItem)this).Drop(player); Cleanup(player); return result; } protected override void OnDestroy() { Cleanup(((PassiveItem)this).Owner); ((PassiveItem)this).OnDestroy(); } private void Cleanup(PlayerController player) { if (Object.op_Implicit((Object)(object)player)) { ((MonoBehaviour)player).StopCoroutine(checkForHandCoroutine); checkForHandCoroutine = null; } } private IEnumerator CheckForHand() { while (true) { PlayerController owner = ((PassiveItem)this).Owner; object obj; if (owner == null) { obj = null; } else { GunInventory inventory = owner.inventory; obj = ((inventory != null) ? inventory.AllGuns : null); } if (obj != null) { foreach (Gun item in ((PassiveItem)this).Owner.inventory.AllGuns) { if (((PickupObject)item).PickupObjectId == 576) { ((PickupObject)item).PreventStartingOwnerFromDropping = true; } } } yield return (object)new WaitForSeconds(1f); } } public static void SetupHook() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) new Hook((MethodBase)typeof(Chest).GetMethod("OnBroken", BindingFlags.Instance | BindingFlags.NonPublic), typeof(RecycleItem).GetMethod("OnBrokenHook")); } public static void OnBrokenHook(Action<Chest> orig, Chest self) { bool flag = false; PlayerController[] allPlayers = GameManager.Instance.AllPlayers; foreach (PlayerController val in allPlayers) { foreach (PassiveItem passiveItem in val.passiveItems) { if (passiveItem is RecycleItem) { flag = true; break; } } } if (flag) { float chestDowngradeChance = GameManager.Instance.RewardManager.ChestDowngradeChance; float chestHalfHeartChance = GameManager.Instance.RewardManager.ChestHalfHeartChance; float chestExplosionChance = GameManager.Instance.RewardManager.ChestExplosionChance; float chestJunkChance = GameManager.Instance.RewardManager.ChestJunkChance; float hasKeyJunkMultiplier = GameManager.Instance.RewardManager.HasKeyJunkMultiplier; float hasJunkanJunkMultiplier = GameManager.Instance.RewardManager.HasJunkanJunkMultiplier; GameManager.Instance.RewardManager.ChestDowngradeChance = 0f; GameManager.Instance.RewardManager.ChestHalfHeartChance = 0f; GameManager.Instance.RewardManager.ChestExplosionChance = 0f; GameManager.Instance.RewardManager.ChestJunkChance = 1f; GameManager.Instance.RewardManager.HasKeyJunkMultiplier = 1f; GameManager.Instance.RewardManager.HasJunkanJunkMultiplier = 1f; orig(self); GameManager.Instance.RewardManager.ChestDowngradeChance = chestDowngradeChance; GameManager.Instance.RewardManager.ChestHalfHeartChance = chestHalfHeartChance; GameManager.Instance.RewardManager.ChestExplosionChance = chestExplosionChance; GameManager.Instance.RewardManager.ChestJunkChance = chestJunkChance; GameManager.Instance.RewardManager.HasKeyJunkMultiplier = hasKeyJunkMultiplier; GameManager.Instance.RewardManager.HasJunkanJunkMultiplier = hasJunkanJunkMultiplier; } else { orig(self); } } } public class SupplySupport : SupplyDropItem { public static int SupplySupportID; private static readonly string theItemName = "Supply Support"; [SerializeField] private bool hasBeenUsedThisFloor = false; public static void Register() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) string resourcePath = "BeyondThePast/Resources/Supply_Drop"; GameObject val = new GameObject(theItemName); SupplySupport supplySupport = val.AddComponent<SupplySupport>(); ItemBuilder.AddSpriteToObject(theItemName, resourcePath, val); PickupObject byId = PickupObjectDatabase.GetById(77); SupplyDropItem obj = (SupplyDropItem)(object)((byId is SupplyDropItem) ? byId : null); string shortDesc = "I Need Supplies!"; string longDesc = "Calls in a supply drop. Can be used once per floor."; ((PickupObject)(object)supplySupport).SetupItem(shortDesc, longDesc, "gr"); SupplySupportID = ((PickupObject)supplySupport).PickupObjectId; FieldInfo[] fields = typeof(SupplyDropItem).GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { fieldInfo.SetValue(supplySupport, fieldInfo.GetValue(obj)); } ((PlayerItem)supplySupport).consumable = false; ((PlayerItem)supplySupport).consumableHandlesOwnDuration = false; ((PlayerItem)supplySupport).consumableOnActiveUse = false; ((PlayerItem)supplySupport).consumableOnCooldownUse = false; ((PickupObject)supplySupport).quality = (ItemQuality)(-100); } public static void HandleSynergy(AdvancedSynergyEntry synergy) { if (synergy.NameKey == "#SUPPLYDROP") { if (synergy.OptionalItemIDs == null) { synergy.OptionalItemIDs = new List<int>(); } if (!synergy.OptionalItemIDs.Contains(SupplySupportID)) { synergy.OptionalItemIDs.Add(SupplySupportID); if (!synergy.OptionalItemIDs.Contains(77)) { synergy.OptionalItemIDs.Add(77); } if (synergy.MandatoryItemIDs.Count != 2) { ETGModConsole.Log(SynergyHelper.GenerateModEditedSynergyProblem(synergy, "Supply Drop", theItemName), false); } synergy.MandatoryItemIDs.RemoveAll((int x) => x == 77); } } else { if (synergy.OptionalItemIDs != null && synergy.OptionalItemIDs.Contains(77) && !synergy.OptionalItemIDs.Contains(SupplySupportID)) { synergy.OptionalItemIDs.Add(SupplySupportID); } if (synergy.MandatoryItemIDs != null && synergy.MandatoryItemIDs.Contains(77)) { ETGModConsole.Log(SynergyHelper.GenerateModdedSynergyProblem(synergy, "Supply Drop", theItemName), false); } } } public override void Pickup(PlayerController player) { if (!((PlayerItem)this).m_pickedUp) { player.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Combine(player.OnNewFloorLoaded, new Action<PlayerController>(ResetCooldown)); ((PlayerItem)this).Pickup(player); } } public override bool CanBeUsed(PlayerController user) { return !hasBeenUsedThisFloor; } protected override void DoEffect(PlayerController user) { hasBeenUsedThisFloor = true; ((SupplyDropItem)this).DoEffect(user); } public void ResetCooldown(PlayerController player) { hasBeenUsedThisFloor = false; } protected override void OnDestroy() { if (Object.op_Implicit((Object)(object)((PlayerItem)this).LastOwner)) { PlayerController lastOwner = ((PlayerItem)this).LastOwner; lastOwner.OnNewFloorLoaded = (Action<PlayerController>)Delegate.Remove(lastOwner.OnNewFloorLoaded, new Action<PlayerController>(ResetCooldown)); } ((SupplyDropItem)this).OnDestroy(); } } internal class SynergyHelper { public static void Help() { AdvancedSynergyEntry[] synergies = GameManager.Instance.