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 BepInEx;
using Dungeonator;
using ETG_AllFloorsSafety.Hooks;
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("ETG_AllFloorsSafety")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ETG_AllFloorsSafety")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("991816b0-1d32-418e-abcd-43b89145726f")]
[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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_00f9: 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)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
if (companionDictionary.ContainsKey(guid))
{
ETGModConsole.Log((object)"CompanionBuilder: Tried to create two companion prefabs with the same GUID!", false);
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_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
if (mandatoryConsoleIDs == null || mandatoryConsoleIDs.Count == 0)
{
ETGModConsole.Log((object)("Synergy " + name + " has no mandatory items/guns."), false);
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);
}
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);
if (flag)
{
}
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();
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 ResourceManager.LoadAssetBundle("shared_auto_001").LoadAsset<GenericLootTable>(assetName);
}
public static GameObject AddSpriteToObject(string name, string resourcePath, GameObject obj = null)
{
GameObject val = SpriteBuilder.SpriteFromResource(resourcePath, obj);
FakePrefab.MarkAsFakePrefab(val);
obj.SetActive(false);
((Object)val).name = name;
return val;
}
public static void SetupItem(this PickupObject item, string shortDesc, string longDesc, string idPool = "ItemAPI")
{
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");
}
catch (Exception ex)
{
ETGModConsole.Log((object)ex.Message, false);
ETGModConsole.Log((object)ex.StackTrace, false);
}
}
public static void AddToSubShop(this PickupObject po, ShopType type, float weight = 1f)
{
//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 void RemovePickupFromLootTables(this PickupObject po)
{
WeightedGameObject val = GameManager.Instance.RewardManager.GunsLootTable.defaultItemDrops.FindWeightedGameObjectInCollection(po);
if (val != null)
{
GameManager.Instance.RewardManager.GunsLootTable.defaultItemDrops.elements.Remove(val);
}
WeightedGameObject val2 = GameManager.Instance.RewardManager.ItemsLootTable.defaultItemDrops.FindWeightedGameObjectInCollection(po);
if (val2 != null)
{
GameManager.Instance.RewardManager.ItemsLootTable.defaultItemDrops.elements.Remove(val2);
}
}
public static WeightedGameObject FindWeightedGameObjectInCollection(this WeightedGameObjectCollection collection, PickupObject po)
{
WeightedGameObject val = collection.FindWeightedGameObjectInCollection(po.PickupObjectId);
if (val == null)
{
val = collection.FindWeightedGameObjectInCollection(((Component)po).gameObject);
}
return val;
}
public static WeightedGameObject FindWeightedGameObjectInCollection(this WeightedGameObjectCollection collection, int id)
{
foreach (WeightedGameObject element in collection.elements)
{
if (element.pickupId == id)
{
return element;
}
}
return null;
}
public static WeightedGameObject FindWeightedGameObjectInCollection(this WeightedGameObjectCollection collection, GameObject obj)
{
foreach (WeightedGameObject element in collection.elements)
{
if ((Object)(object)element.gameObject == (Object)(object)obj)
{
return element;
}
}
return null;
}
}
public static class ResourceExtractor
{
private static string spritesDirectory = Path.Combine(ETGMod.ResourcesDirectory, "sprites");
public static List<Texture2D> GetTexturesFromDirectory(string directoryPath)
{
if (!Directory.Exists(directoryPath))
{
ETGModConsole.Log((object)(directoryPath + " not found."), false);
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))
{
ETGModConsole.Log((object)(text + " not found."), false);
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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
byte[] array = ExtractEmbeddedResource(resourceName);
if (array == null)
{
ETGModConsole.Log((object)("No bytes found in " + resourceName), false);
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((object)"No manifest resources found.", false);
return null;
}
return manifestResourceNames;
}
}
public static class SpriteBuilder
{
private static tk2dSpriteCollectionData itemCollection = ((BraveBehaviour)PickupObjectDatabase.GetById(155)).sprite.Collection;
private static tk2dSpriteCollectionData ammonomiconCollection = AmmonomiconController.ForceInstance.EncounterIconCollection;
private static tk2dSprite baseSprite = ((Component)PickupObjectDatabase.GetById(155)).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_00a7: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_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();
val2.name = clipName;
val2.fps = 15f;
val2.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 ETG_AllFloorsSafety
{
[BepInPlugin("the_rot_bot.etg.allfloorssafety", "All Floors Safety", "1.0.0")]
public class AllFloorsSafety : BaseUnityPlugin
{
public static bool IsFireExtinguished;
public void Awake()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
public void GMStart(GameManager manager)
{
Console.WriteLine("ETG_AllFloorsSafety Start()");
SetupHooks();
SetupItems();
IsFireExtinguished = false;
}
private void SetupItems()
{
Console.WriteLine("ETG_AllFloorsSafety SetupItems()");
FakePrefabHooks.Init();
ItemBuilder.Init();
SafetyRound.Init();
}
private void SetupHooks()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
Console.WriteLine("ETG_AllFloorsSafety SetupHooks()");
new Hook((MethodBase)typeof(PlayerConsumables).GetProperty("Currency", BindingFlags.Instance | BindingFlags.Public).GetSetMethod(), typeof(PlayerConsumablesHooks).GetMethod("Hook_PlayerConsumables_Currency_Set", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(MinorBreakable).GetMethod("Break", Type.EmptyTypes), typeof(MinorBreakableHooks).GetMethod("Hook_MinorBreakable_Break_NoParams", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(MinorBreakable).GetMethod("Break", new Type[1] { typeof(Vector2) }), typeof(MinorBreakableHooks).GetMethod("Hook_MinorBreakable_Break_WithParams", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(FireplaceController).GetMethod("OnFireExtinguished", BindingFlags.Instance | BindingFlags.NonPublic), typeof(FireplaceControllerHooks).GetMethod("Hook_FireplaceController_OnFireExtinguished", BindingFlags.Instance | BindingFlags.NonPublic), (object)this);
new Hook((MethodBase)typeof(LevelNameUIManager).GetMethod("ShowLevelName", BindingFlags.Instance | BindingFlags.Public), typeof(LevelNameUIManagerHooks).GetMethod("Hook_LevelNameUIManager_ShowLevelName", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(ShopItemController).GetMethod("Interact", BindingFlags.Instance | BindingFlags.Public), typeof(ShopItemControllerHooks).GetMethod("Hook_ShopItemController_Interact", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(PlayerController).GetMethod("InitializeInventory", BindingFlags.Instance | BindingFlags.NonPublic), typeof(PlayerControllerHooks).GetMethod("Hook_PlayerController_InitializeInventory", BindingFlags.Instance | BindingFlags.NonPublic), (object)this);
new Hook((MethodBase)typeof(ProceduralFlowModifierData).GetProperty("PrerequisitesMet", BindingFlags.Instance | BindingFlags.Public).GetGetMethod(), typeof(ProceduralFlowModifierDataHooks).GetMethod("Hook_ProceduralFlowModifierData_PrerequisitesMet", BindingFlags.Instance | BindingFlags.Public), (object)this);
new Hook((MethodBase)typeof(SellCellController).GetMethod("HandleSoldItem", BindingFlags.Instance | BindingFlags.NonPublic), typeof(SellCellControllerHooks).GetMethod("Hook_SellCellController_HandleSoldItem", BindingFlags.Instance | BindingFlags.NonPublic), (object)this);
new Hook((MethodBase)typeof(ShopSubsidiaryZone).GetMethod("HandleSetup", new Type[4]
{
typeof(BaseShopController),
typeof(RoomHandler),
typeof(List<GameObject>),
typeof(List<ShopItemController>)
}), typeof(ShopSubsidiaryZoneHooks).GetMethod("Hook_ShopSubsidiaryZone_HandleSetup", BindingFlags.Instance | BindingFlags.Public), (object)this);
}
}
public class SafetyRound : PassiveItem
{
public static void Init()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
string text = "Safety Round";
string resourcePath = "ETG_AllFloorsSafety/Resources/SafetyRound.png";
GameObject val = new GameObject(text);
PassiveItem val2 = val.AddComponent<PassiveItem>();
((PickupObject)(object)val2).RemovePickupFromLootTables();
ItemBuilder.AddSpriteToObject(text, resourcePath, val);
string shortDesc = "Safety First";
string longDesc = "Don't have a Master Round for the Sell Creep? Use the Safety Round!";
((PickupObject)(object)val2).SetupItem(shortDesc, longDesc, "ETG_AllFloorsSafety");
((PickupObject)val2).quality = (ItemQuality)(-50);
((PickupObject)(object)val2).RemovePickupFromLootTables();
}
}
}
namespace ETG_AllFloorsSafety.Hooks
{
internal class FireplaceControllerHooks
{
private void Hook_FireplaceController_OnFireExtinguished(Action<FireplaceController> orig, FireplaceController self)
{
orig(self);
AllFloorsSafety.IsFireExtinguished = true;
}
}
internal class LevelNameUIManagerHooks
{
public void Hook_LevelNameUIManager_ShowLevelName(Action<LevelNameUIManager, Dungeon> orig, LevelNameUIManager self, Dungeon d)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if ((int)GameManager.Instance.Dungeon.tileIndices.tilesetId == 2)
{
AllFloorsSafety.IsFireExtinguished = false;
}
orig(self, d);
}
}
internal class MinorBreakableHooks
{
public void Hook_MinorBreakable_Break_NoParams(Action<MinorBreakable> orig, MinorBreakable self)
{
if (!IsWaterDrum(self))
{
orig(self);
}
else if (AllFloorsSafety.IsFireExtinguished && IsWaterDrum(self))
{
AllFloorsSafety.IsFireExtinguished = false;
orig(self);
}
}
public void Hook_MinorBreakable_Break_WithParams(Action<MinorBreakable, Vector2> orig, MinorBreakable self, Vector2 direction)
{
//IL_0012: 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)
if (!IsWaterDrum(self))
{
orig(self, direction);
}
else if (AllFloorsSafety.IsFireExtinguished && IsWaterDrum(self))
{
AllFloorsSafety.IsFireExtinguished = false;
orig(self, direction);
}
}
private bool IsWaterDrum(MinorBreakable breakable)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
return (int)GameManager.Instance.Dungeon.tileIndices.tilesetId == 2 && (Object)(object)breakable.goopType != (Object)null && !breakable.goopType.CanBeIgnited;
}
}
internal class PlayerConsumablesHooks
{
public void Hook_PlayerConsumables_Currency_Set(Action<PlayerConsumables, int> orig, PlayerConsumables self, int value)
{
FieldInfo field = typeof(PlayerConsumables).GetField("m_currency", BindingFlags.Instance | BindingFlags.NonPublic);
int num = (int)field.GetValue(self);
num = (int)typeof(PlayerConsumables).GetField("m_currency", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if (value > num && GameStatsManager.HasInstance)
{
num = (int)typeof(PlayerConsumables).GetField("m_currency", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
GameStatsManager.Instance.RegisterStatChange((TrackedStats)14, (float)(value - num));
}
if (value >= 300 && GameManager.HasInstance && GameManager.Instance.platformInterface != null)
{
float realtimeSinceStartup = Time.realtimeSinceStartup;
if (realtimeSinceStartup > PlatformInterface.LastManyCoinsUnlockTime + 5f || realtimeSinceStartup < PlatformInterface.LastManyCoinsUnlockTime)
{
GameManager.Instance.platformInterface.AchievementUnlock((Achievement)45, 0);
PlatformInterface.LastManyCoinsUnlockTime = realtimeSinceStartup;
}
}
num = (int)typeof(PlayerConsumables).GetField("m_currency", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
num = value;
field.SetValue(self, num);
if (GameUIRoot.HasInstance)
{
GameUIRoot.Instance.UpdatePlayerConsumables(self);
}
}
}
internal class PlayerControllerHooks
{
private void Hook_PlayerController_InitializeInventory(Action<PlayerController> orig, PlayerController self)
{
orig(self);
? val = self;
PickupObject byName = PickupObjectDatabase.GetByName("Safety Round");
((PlayerController)val).AcquirePassiveItemPrefabDirectly((PassiveItem)(object)((byName is PassiveItem) ? byName : null));
}
}
internal class ProceduralFlowModifierDataHooks
{
public bool Hook_ProceduralFlowModifierData_PrerequisitesMet(Func<ProceduralFlowModifierData, bool> orig, ProceduralFlowModifierData self)
{
bool flag = orig(self);
if (self.annotation == "Sell Creep (Nakatomi)" && !flag)
{
for (int i = 0; i < self.prerequisites.Length; i++)
{
if (!self.prerequisites[i].CheckConditionsFulfilled())
{
return false;
}
}
return !self.RequiresMasteryToken || !GameManager.HasInstance || !Object.op_Implicit((Object)(object)GameManager.Instance.PrimaryPlayer) || GameManager.Instance.PrimaryPlayer.MasteryTokensCollectedThisRun > 0 || GameManager.Instance.PrimaryPlayer.passiveItems.Any((PassiveItem x) => ((PickupObject)x).PickupObjectId == PickupObjectDatabase.GetByName("Safety Round").PickupObjectId);
}
return flag;
}
}
internal class SellCellControllerHooks
{
private IEnumerator Hook_SellCellController_HandleSoldItem(Func<SellCellController, PickupObject, IEnumerator> orig, SellCellController self, PickupObject targetItem)
{
FieldInfo m_currentlySellingAnItem = typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic);
_ = (bool)m_currentlySellingAnItem.GetValue(self);
FieldInfo m_thingsSold = typeof(SellCellController).GetField("m_thingsSold", BindingFlags.Instance | BindingFlags.NonPublic);
_ = (int)m_thingsSold.GetValue(self);
FieldInfo m_masteryRoundsSold = typeof(SellCellController).GetField("m_masteryRoundsSold", BindingFlags.Instance | BindingFlags.NonPublic);
_ = (int)m_masteryRoundsSold.GetValue(self);
targetItem.IsBeingSold = true;
while ((bool)typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self))
{
yield return null;
}
if (!Object.op_Implicit((Object)(object)targetItem) || !Object.op_Implicit((Object)(object)((BraveBehaviour)targetItem).sprite) || !((BraveBehaviour)self).specRigidbody.ContainsPoint(((BraveBehaviour)targetItem).sprite.WorldCenter, int.MaxValue, true))
{
yield break;
}
_ = (bool)typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
bool _currentlySellingAnItem3 = true;
m_currentlySellingAnItem.SetValue(self, _currentlySellingAnItem3);
IPlayerInteractable ixable = null;
if (targetItem is PassiveItem)
{
PassiveItem passiveItem = (PassiveItem)(object)((targetItem is PassiveItem) ? targetItem : null);
passiveItem.GetRidOfMinimapIcon();
ixable = (IPlayerInteractable)(object)((targetItem is PassiveItem) ? targetItem : null);
}
else if (targetItem is Gun)
{
Gun gun = (Gun)(object)((targetItem is Gun) ? targetItem : null);
gun.GetRidOfMinimapIcon();
ixable = (IPlayerInteractable)(object)((targetItem is Gun) ? targetItem : null);
}
else if (targetItem is PlayerItem)
{
PlayerItem playerItem = (PlayerItem)(object)((targetItem is PlayerItem) ? targetItem : null);
playerItem.GetRidOfMinimapIcon();
ixable = (IPlayerInteractable)(object)((targetItem is PlayerItem) ? targetItem : null);
}
if (ixable != null)
{
RoomHandler.unassignedInteractableObjects.Remove(ixable);
GameManager.Instance.PrimaryPlayer.RemoveBrokenInteractable(ixable);
}
float elapsed = 0f;
float duration = 0.5f;
Vector3 startPos = ((BraveBehaviour)targetItem).transform.position;
Vector3 finalOffset = Vector3.zero;
tk2dBaseSprite targetSprite = ((Component)targetItem).GetComponentInChildren<tk2dBaseSprite>();
if (Object.op_Implicit((Object)(object)targetSprite))
{
Bounds bounds = targetSprite.GetBounds();
finalOffset = ((Bounds)(ref bounds)).extents;
}
while (elapsed < duration)
{
elapsed += BraveTime.DeltaTime;
if (!Object.op_Implicit((Object)(object)targetItem) || !Object.op_Implicit((Object)(object)((BraveBehaviour)targetItem).transform))
{
_ = (bool)typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_currentlySellingAnItem3 = false;
m_currentlySellingAnItem.SetValue(self, _currentlySellingAnItem3);
yield break;
}
((BraveBehaviour)targetItem).transform.localScale = Vector3.Lerp(Vector3.one, new Vector3(0.01f, 0.01f, 1f), elapsed / duration);
((BraveBehaviour)targetItem).transform.position = Vector3.Lerp(startPos, startPos + new Vector3(finalOffset.x, 0f, 0f), elapsed / duration);
yield return null;
}
if (!Object.op_Implicit((Object)(object)targetItem) || !Object.op_Implicit((Object)(object)((BraveBehaviour)targetItem).transform))
{
_ = (bool)typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_currentlySellingAnItem3 = false;
m_currentlySellingAnItem.SetValue(self, _currentlySellingAnItem3);
yield break;
}
((BraveBehaviour)self.SellPitDweller).SendPlaymakerEvent("playerSoldSomething");
int sellPrice = Mathf.Clamp(Mathf.CeilToInt((float)targetItem.PurchasePrice * self.SellValueModifier), 0, 200);
if ((int)targetItem.quality == -50 || (int)targetItem.quality == -100)
{
sellPrice = 3;
}
LootEngine.SpawnCurrency(((BraveBehaviour)targetItem).sprite.WorldCenter, sellPrice, false);
int _thingsSold3 = (int)typeof(SellCellController).GetField("m_thingsSold", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_thingsSold3++;
m_thingsSold.SetValue(self, _thingsSold3);
int _masteryRoundsSold3;
if (targetItem.PickupObjectId == GlobalItemIds.MasteryToken_Castle || targetItem.PickupObjectId == GlobalItemIds.MasteryToken_Catacombs || targetItem.PickupObjectId == GlobalItemIds.MasteryToken_Gungeon || targetItem.PickupObjectId == GlobalItemIds.MasteryToken_Forge || targetItem.PickupObjectId == GlobalItemIds.MasteryToken_Mines || targetItem.PickupObjectId == PickupObjectDatabase.GetByName("Safety Round").PickupObjectId)
{
_masteryRoundsSold3 = (int)typeof(SellCellController).GetField("m_masteryRoundsSold", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_masteryRoundsSold3++;
m_masteryRoundsSold.SetValue(self, _masteryRoundsSold3);
}
if (targetItem is Gun && Object.op_Implicit((Object)(object)((Component)targetItem).GetComponentInParent<DebrisObject>()))
{
Object.Destroy((Object)(object)((Component)((BraveBehaviour)targetItem).transform.parent).gameObject);
}
else
{
Object.Destroy((Object)(object)((Component)targetItem).gameObject);
}
_thingsSold3 = (int)typeof(SellCellController).GetField("m_thingsSold", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_masteryRoundsSold3 = (int)typeof(SellCellController).GetField("m_masteryRoundsSold", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if (_thingsSold3 >= 3 && _masteryRoundsSold3 > 0)
{
((MonoBehaviour)self).StartCoroutine(HandleSellPitOpening(self));
}
_ = (bool)typeof(SellCellController).GetField("m_currentlySellingAnItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
_currentlySellingAnItem3 = false;
m_currentlySellingAnItem.SetValue(self, _currentlySellingAnItem3);
}
private IEnumerator HandleSellPitOpening(SellCellController self)
{
FieldInfo m_isExploded = typeof(SellCellController).GetField("m_isExploded", BindingFlags.Instance | BindingFlags.NonPublic);
_ = (bool)m_isExploded.GetValue(self);
if ((int)GameManager.Instance.Dungeon.tileIndices.tilesetId != 32)
{
yield break;
}
_ = (bool)typeof(SellCellController).GetField("m_isExploded", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
bool _isExploded = true;
m_isExploded.SetValue(self, _isExploded);
self.SellPitDweller.PreventInteraction = true;
self.SellPitDweller.PreventCoopInteraction = true;
self.SellPitDweller.playerApproachRadius = -1f;
yield return (object)new WaitForSeconds(3f);
Object.Instantiate<GameObject>(self.SellExplosionVFX, ((BraveBehaviour)self).transform.position, Quaternion.identity);
float elapsed = 0f;
while (elapsed < 0.25f)
{
elapsed += BraveTime.DeltaTime;
yield return null;
}
((tk2dBaseSprite)self.CellTopSprite).SetSprite(self.ExplodedSellSpriteName);
for (int i = 1; i < ((DungeonPlaceableBehaviour)self).GetWidth(); i++)
{
for (int j = 0; j < ((DungeonPlaceableBehaviour)self).GetHeight(); j++)
{
IntVector2 intVector = Vector3Extensions.IntXY(((BraveBehaviour)self).transform.position, (VectorConversions)2) + new IntVector2(i, j);
if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(intVector))
{
CellData cellData = GameManager.Instance.Dungeon.data[intVector];
cellData.fallingPrevented = false;
}
}
}
}
}
internal class ShopItemControllerHooks
{
private bool IsCrestAndPlayerHasCrestInGungeon(ShopItemController self, PlayerController player)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
return (int)GameManager.Instance.Dungeon.tileIndices.tilesetId == 1 && self.item.PickupObjectId == GlobalItemIds.CathedralCrest && ((BraveBehaviour)player).healthHaver.HasCrest;
}
public void Hook_ShopItemController_Interact(Action<ShopItemController, PlayerController> orig, ShopItemController self, PlayerController player)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Invalid comparison between Unknown and I4
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Invalid comparison between Unknown and I4
//IL_0752: Unknown result type (might be due to invalid IL or missing references)
//IL_0758: Invalid comparison between Unknown and I4
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Invalid comparison between Unknown and I4
//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
//IL_07be: Expected O, but got Unknown
//IL_0944: Unknown result type (might be due to invalid IL or missing references)
//IL_094a: Expected O, but got Unknown
//IL_081c: Unknown result type (might be due to invalid IL or missing references)
//IL_0822: Expected O, but got Unknown
//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
//IL_07ee: Expected O, but got Unknown
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Expected O, but got Unknown
//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
//IL_09b0: Expected O, but got Unknown
//IL_0974: Unknown result type (might be due to invalid IL or missing references)
//IL_097a: Expected O, but got Unknown
//IL_084c: Unknown result type (might be due to invalid IL or missing references)
//IL_0852: Expected O, but got Unknown
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Expected O, but got Unknown
//IL_09da: Unknown result type (might be due to invalid IL or missing references)
//IL_09e0: Expected O, but got Unknown
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Invalid comparison between Unknown and I4
//IL_0568: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Expected O, but got Unknown
//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
//IL_05d8: Expected O, but got Unknown
//IL_0598: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Expected O, but got Unknown
//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
//IL_04f9: Invalid comparison between Unknown and I4
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Invalid comparison between Unknown and I4
//IL_0602: Unknown result type (might be due to invalid IL or missing references)
//IL_0608: Expected O, but got Unknown
//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
//IL_06ec: Invalid comparison between Unknown and I4
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_0633: Expected O, but got Unknown
//IL_0637: Unknown result type (might be due to invalid IL or missing references)
//IL_064b: Unknown result type (might be due to invalid IL or missing references)
//IL_0691: Unknown result type (might be due to invalid IL or missing references)
//IL_0697: Expected O, but got Unknown
//IL_0522: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Invalid comparison between Unknown and I4
//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ae: Expected O, but got Unknown
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Expected O, but got Unknown
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Expected O, but got Unknown
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0442: Expected O, but got Unknown
if (IsCrestAndPlayerHasCrestInGungeon(self, player))
{
return;
}
FieldInfo field = typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic);
BaseShopController val = (BaseShopController)field.GetValue(self);
FieldInfo field2 = typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic);
ShopController val2 = (ShopController)field2.GetValue(self);
FieldInfo field3 = typeof(ShopItemController).GetField("pickedUp", BindingFlags.Instance | BindingFlags.NonPublic);
bool flag = (bool)field3.GetValue(self);
if (Object.op_Implicit((Object)(object)self.item) && self.item is HealthPickup)
{
PickupObject item = self.item;
if (((HealthPickup)((item is HealthPickup) ? item : null)).healAmount > 0f && ((HealthPickup)/*isinst with value type is only supported in some contexts*/).armorAmount <= 0 && ((BraveBehaviour)player).healthHaver.GetCurrentHealthPercentage() >= 1f)
{
return;
}
}
else if (Object.op_Implicit((Object)(object)self.item) && self.item is AmmoPickup && ((Object)(object)((GameActor)player).CurrentGun == (Object)null || ((GameActor)player).CurrentGun.ammo == ((GameActor)player).CurrentGun.AdjustedMaxAmmo || !((GameActor)player).CurrentGun.CanGainAmmo || ((GameActor)player).CurrentGun.InfiniteAmmo))
{
GameUIRoot.Instance.InformNeedsReload(player, new Vector3(((BraveBehaviour)player).specRigidbody.UnitCenter.x - ((BraveBehaviour)player).transform.position.x, 1.25f, 0f), 1f, "#RELOAD_FULL");
return;
}
self.LastInteractingPlayer = player;
if ((int)self.CurrencyType == 0 || (int)self.CurrencyType == 3 || (int)self.CurrencyType == 2)
{
bool flag2 = false;
bool flag3 = true;
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((int)GameManager.Instance.CurrentLevelOverrideState != 1 && (val.IsCapableOfBeingStolenFrom || player.IsCapableOfStealing))
{
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
flag2 = val.AttemptToSteal();
field.SetValue(self, val);
flag3 = false;
if (!flag2)
{
player.DidUnstealthyAction();
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.NotifyStealFailed();
field.SetValue(self, val);
return;
}
}
if (flag3)
{
bool flag4 = false;
if ((int)self.CurrencyType == 0 || (int)self.CurrencyType == 3)
{
flag4 = player.carriedConsumables.Currency >= self.ModifiedPrice || self.ModifiedPrice == 0;
}
else if ((int)self.CurrencyType == 2)
{
flag4 = player.carriedConsumables.KeyBullets >= self.ModifiedPrice;
}
if (self.IsResourcefulRatKey)
{
PlayerConsumables carriedConsumables = player.carriedConsumables;
carriedConsumables.Currency -= self.ModifiedPrice;
GameStatsManager.Instance.RegisterStatChange((TrackedStats)84, (float)self.ModifiedPrice);
flag3 = false;
}
else if (!flag4)
{
AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", ((Component)self).gameObject);
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val2 != (Object)null)
{
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val2.NotifyFailedPurchase(self);
field2.SetValue(self, val2);
}
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val != (Object)null)
{
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.NotifyFailedPurchase(self);
field.SetValue(self, val);
}
return;
}
}
if ((bool)typeof(ShopItemController).GetField("pickedUp", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self))
{
return;
}
flag = (bool)typeof(ShopItemController).GetField("pickedUp", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
flag = !self.item.PersistsOnPurchase;
field3.SetValue(self, flag);
LootEngine.GivePrefabToPlayer(((Component)self.item).gameObject, player);
if (flag3)
{
if ((int)self.CurrencyType == 0 || (int)self.CurrencyType == 3)
{
PlayerConsumables carriedConsumables2 = player.carriedConsumables;
carriedConsumables2.Currency -= self.ModifiedPrice;
}
else if ((int)self.CurrencyType == 2)
{
PlayerConsumables carriedConsumables3 = player.carriedConsumables;
carriedConsumables3.KeyBullets -= self.ModifiedPrice;
}
}
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val2 != (Object)null)
{
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val2.PurchaseItem(self, !flag2, true);
field2.SetValue(self, val2);
}
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val != (Object)null)
{
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.PurchaseItem(self, !flag2, true);
field.SetValue(self, val);
}
if (flag2)
{
StatModifier val3 = new StatModifier();
val3.statToBoost = (StatType)14;
val3.amount = 1f;
val3.modifyType = (ModifyMethod)0;
player.ownerlessStatModifiers.Add(val3);
player.stats.RecalculateStats(player, false, false);
player.HandleItemStolen(self);
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.NotifyStealSucceeded();
field.SetValue(self, val);
player.IsThief = true;
GameStatsManager.Instance.RegisterStatChange((TrackedStats)60, 1f);
if (self.SetsFlagOnSteal)
{
GameStatsManager.Instance.SetFlag(self.FlagToSetOnSteal, true);
}
}
else
{
if ((int)self.CurrencyType == 3)
{
int blanks = player.Blanks;
player.Blanks = blanks + 1;
}
player.HandleItemPurchased(self);
}
if (!self.item.PersistsOnPurchase)
{
GameUIRoot.Instance.DeregisterDefaultLabel(((BraveBehaviour)self).transform);
}
AkSoundEngine.PostEvent("Play_OBJ_item_purchase_01", ((Component)self).gameObject);
}
else
{
if ((int)self.CurrencyType != 1)
{
return;
}
int num = Mathf.RoundToInt(GameStatsManager.Instance.GetPlayerStatValue((TrackedStats)25));
if (num < self.ModifiedPrice)
{
AkSoundEngine.PostEvent("Play_OBJ_purchase_unable_01", ((Component)self).gameObject);
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val2 != (Object)null)
{
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val2.NotifyFailedPurchase(self);
field2.SetValue(self, val2);
}
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val != (Object)null)
{
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.NotifyFailedPurchase(self);
field.SetValue(self, val);
}
}
else if (!(bool)typeof(ShopItemController).GetField("pickedUp", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self))
{
flag = (bool)typeof(ShopItemController).GetField("pickedUp", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
flag = !self.item.PersistsOnPurchase;
field3.SetValue(self, flag);
GameStatsManager.Instance.ClearStatValueGlobal((TrackedStats)25);
GameStatsManager.Instance.SetStat((TrackedStats)25, (float)(num - self.ModifiedPrice));
GameStatsManager.Instance.RegisterStatChange((TrackedStats)21, (float)self.ModifiedPrice);
LootEngine.GivePrefabToPlayer(((Component)self.item).gameObject, player);
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val2 != (Object)null)
{
val2 = (ShopController)typeof(ShopItemController).GetField("m_parentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val2.PurchaseItem(self, true, true);
field2.SetValue(self, val2);
}
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
if ((Object)(object)val != (Object)null)
{
val = (BaseShopController)typeof(ShopItemController).GetField("m_baseParentShop", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self);
val.PurchaseItem(self, true, true);
field.SetValue(self, val);
}
player.HandleItemPurchased(self);
if (!self.item.PersistsOnPurchase)
{
GameUIRoot.Instance.DeregisterDefaultLabel(((BraveBehaviour)self).transform);
}
AkSoundEngine.PostEvent("Play_OBJ_item_purchase_01", ((Component)self).gameObject);
}
}
}
}
internal class ShopSubsidiaryZoneHooks
{
public delegate void CustomAction<T1, T2, T3, T4, T5>(T1 p1, T2 p2, T3 p3, T4 p4, T5 p5);
public void Hook_ShopSubsidiaryZone_HandleSetup(CustomAction<ShopSubsidiaryZone, BaseShopController, RoomHandler, List<GameObject>, List<ShopItemController>> orig, ShopSubsidiaryZone self, BaseShopController controller, RoomHandler room, List<GameObject> shopItemObjects, List<ShopItemController> shopItemControllers)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Invalid comparison between Unknown and I4
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
int count = shopItemObjects.Count;
for (int i = 0; i < self.spawnPositions.Length; i++)
{
GameObject item = ((self.IsShopRoundTable && i == 0 && (int)GameManager.Instance.Dungeon.tileIndices.tilesetId == 1) ? ((Component)PickupObjectDatabase.GetById(GlobalItemIds.CathedralCrest)).gameObject : ((!self.IsShopRoundTable || (i != 0 && i != 1) || (int)GameManager.Instance.Dungeon.tileIndices.tilesetId != 16) ? self.shopItems.SelectByWeightWithoutDuplicatesFullPrereqs(shopItemObjects, true, false) : ((Component)PickupObjectDatabase.GetById(GlobalItemIds.Blank)).gameObject));
shopItemObjects.Add(item);
}
bool flag = false;
for (int j = 0; j < self.spawnPositions.Length; j++)
{
if ((Object)(object)shopItemObjects[count + j] == (Object)null)
{
continue;
}
flag = true;
Transform val = self.spawnPositions[j];
PickupObject component = shopItemObjects[count + j].GetComponent<PickupObject>();
if (!((Object)(object)component == (Object)null))
{
GameObject val2 = new GameObject("Shop item " + j);
Transform transform = val2.transform;
transform.parent = val;
transform.localPosition = Vector3.zero;
EncounterTrackable component2 = ((Component)component).GetComponent<EncounterTrackable>();
if ((Object)(object)component2 != (Object)null)
{
GameManager.Instance.ExtantShopTrackableGuids.Add(component2.EncounterGuid);
}
ShopItemController val3 = val2.AddComponent<ShopItemController>();
val3.PrecludeAllDiscounts = self.PrecludeAllDiscounts;
if (((Object)val).name.Contains("SIDE") || ((Object)val).name.Contains("EAST"))
{
val3.itemFacing = (Direction)2;
}
else if (((Object)val).name.Contains("WEST"))
{
val3.itemFacing = (Direction)6;
}
else if (((Object)val).name.Contains("NORTH"))
{
val3.itemFacing = (Direction)0;
}
if (!room.IsRegistered((IPlayerInteractable)(object)val3))
{
room.RegisterInteractable((IPlayerInteractable)(object)val3);
}
val3.Initialize(component, controller);
if (val3.item.PickupObjectId == GlobalItemIds.CathedralCrest)
{
val3.OverridePrice = 0;
val3.CurrentPrice = 0;
val3.item.PersistsOnPurchase = true;
}
shopItemControllers.Add(val3);
}
}
if (!flag)
{
SpeculativeRigidbody[] componentsInChildren = ((Component)self).GetComponentsInChildren<SpeculativeRigidbody>();
for (int k = 0; k < componentsInChildren.Length; k++)
{
((Behaviour)componentsInChildren[k]).enabled = false;
}
((Component)self).gameObject.SetActive(false);
}
}
}
}