using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Alexandria.DungeonAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using BepInEx;
using Dungeonator;
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("GungeonAPI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GungeonAPI")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("550ce75b-bdf5-4ddd-b063-5617f06b18fd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GungeonAPI;
public static class GungeonAPI
{
public static void Init()
{
string[] directories = Directory.GetDirectories(Paths.PluginPath, "CustomRoomData", SearchOption.AllDirectories);
string[] array = directories;
foreach (string text in array)
{
RoomFactory.LoadRoomsFromRoomDirectory("CustomRoomsMod", text);
}
}
}
public static class HitboxMonitor
{
public class HitBoxDisplay : BraveBehaviour
{
private GameObject hitboxDisplay = null;
private PixelCollider collider;
private void Start()
{
CreateDisplay();
}
public void CreateDisplay()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
collider = ((BraveBehaviour)this).specRigidbody.HitboxPixelCollider;
string name = "HitboxDisplay";
if ((Object)(object)hitboxDisplay == (Object)null)
{
hitboxDisplay = GameObject.CreatePrimitive((PrimitiveType)3);
}
hitboxDisplay.GetComponent<Renderer>().material.color = new Color(1f, 0f, 1f, 0.75f);
((Object)hitboxDisplay).name = name;
hitboxDisplay.transform.SetParent(((BraveBehaviour)((BraveBehaviour)this).specRigidbody).transform);
}
private void FixedUpdate()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
hitboxDisplay.transform.localScale = new Vector3((float)collider.Dimensions.x / pixelsPerUnit, (float)collider.Dimensions.y / pixelsPerUnit, 1f);
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor((float)collider.Offset.x + (float)collider.Dimensions.x * 0.5f, (float)collider.Offset.y + (float)collider.Dimensions.y * 0.5f, 0f - pixelsPerUnit);
val /= pixelsPerUnit;
hitboxDisplay.transform.localPosition = val;
}
public override void OnDestroy()
{
if (Object.op_Implicit((Object)(object)hitboxDisplay))
{
Object.DestroyImmediate((Object)(object)hitboxDisplay);
}
}
}
private static float pixelsPerUnit = 16f;
public static void DisplayHitbox(SpeculativeRigidbody speculativeRigidbody)
{
PixelCollider hitboxPixelCollider = speculativeRigidbody.HitboxPixelCollider;
DebugUtility.Log<string>("Collider Found...");
if (!Object.op_Implicit((Object)(object)((Component)speculativeRigidbody).gameObject.GetComponent<HitBoxDisplay>()))
{
((Component)speculativeRigidbody).gameObject.AddComponent<HitBoxDisplay>();
}
DebugUtility.Log<string>("Displaying...");
LogHitboxInfo(hitboxPixelCollider);
}
public static void DeleteHitboxDisplays()
{
HitBoxDisplay[] array = Object.FindObjectsOfType<HitBoxDisplay>();
foreach (HitBoxDisplay hitBoxDisplay in array)
{
Object.Destroy((Object)(object)hitBoxDisplay);
}
}
private static void LogHitboxInfo(PixelCollider collider)
{
//IL_0007: 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)
//IL_003d: 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)
DebugUtility.Print<string>($"Dimensions: ({collider.Dimensions.x},{collider.Dimensions.y})", "FFFFFF", false);
DebugUtility.Print<string>($"Offset: ({collider.Offset.x},{collider.Offset.y})", "FFFFFF", false);
}
}
public static class KeyShrine
{
public static void Add()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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)
ShrineFactory shrineFactory = new ShrineFactory();
shrineFactory.name = "Key Shrine";
shrineFactory.modID = "kts";
shrineFactory.text = "A shrine representing the key to happiness.";
shrineFactory.spritePath = "GungeonAPI/resource/shrine_heart_key.png";
shrineFactory.room = RoomFactory.BuildFromResource("GungeonAPI/resource/rooms/KeyShrine.room", (Assembly)null).room;
shrineFactory.acceptText = "Offer a heart to unlock your potential";
shrineFactory.declineText = "Walk away";
shrineFactory.OnAccept = Accept;
shrineFactory.OnDecline = null;
shrineFactory.CanUse = CanUse;
shrineFactory.offset = new Vector3(10f, 0f, 0f);
shrineFactory.talkPointOffset = new Vector3(0f, 3f, 0f);
shrineFactory.isToggle = false;
shrineFactory.isBreachShrine = false;
ShrineFactory shrineFactory2 = shrineFactory;
shrineFactory2.Build();
}
public static bool CanUse(PlayerController player, GameObject shrine)
{
return shrine.GetComponent<ShrineFactory.CustomShrineController>().numUses == 0;
}
public static void Accept(PlayerController player, GameObject shrine)
{
float maxHealth = ((BraveBehaviour)player).healthHaver.GetMaxHealth();
if (maxHealth > 1f)
{
((BraveBehaviour)player).healthHaver.SetHealthMaximum(maxHealth - 1f, (float?)null, false);
PlayerConsumables carriedConsumables = player.carriedConsumables;
carriedConsumables.KeyBullets += 2;
shrine.GetComponent<ShrineFactory.CustomShrineController>().numUses++;
shrine.GetComponent<ShrineFactory.CustomShrineController>().GetRidOfMinimapIcon();
AkSoundEngine.PostEvent("Play_OBJ_shrine_accept_01", shrine);
}
}
}
public class ShrineFactory
{
public class CustomShrineController : DungeonPlaceableBehaviour
{
public string ID;
public bool isBreachShrine;
public Vector3 offset;
public List<PixelCollider> pixelColliders;
public Dictionary<string, int> roomStyles;
public ShrineFactory factory;
public Action<PlayerController, GameObject> OnAccept;
public Action<PlayerController, GameObject> OnDecline;
public Func<PlayerController, GameObject, bool> CanUse;
private RoomHandler m_parentRoom;
private GameObject m_instanceMinimapIcon;
public int numUses = 0;
private void Start()
{
string text = ((Object)this).name.Replace("(Clone)", "");
if (builtShrines.ContainsKey(text))
{
Copy(builtShrines[text].GetComponent<CustomShrineController>());
}
else
{
DebugUtility.PrintError<string>("Was this shrine registered correctly?: " + text, "FF0000");
}
((Component)this).GetComponent<SimpleInteractable>().OnAccept = OnAccept;
((Component)this).GetComponent<SimpleInteractable>().OnDecline = OnDecline;
((Component)this).GetComponent<SimpleInteractable>().CanUse = CanUse;
}
public void Copy(CustomShrineController other)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
ID = other.ID;
roomStyles = other.roomStyles;
isBreachShrine = other.isBreachShrine;
offset = other.offset;
pixelColliders = other.pixelColliders;
factory = other.factory;
OnAccept = other.OnAccept;
OnDecline = other.OnDecline;
CanUse = other.CanUse;
}
public void ConfigureOnPlacement(RoomHandler room)
{
m_parentRoom = room;
RegisterMinimapIcon();
}
public void RegisterMinimapIcon()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
m_instanceMinimapIcon = Minimap.Instance.RegisterRoomIcon(m_parentRoom, (GameObject)BraveResources.Load("Global Prefabs/Minimap_Shrine_Icon", ".prefab"), false);
}
public void GetRidOfMinimapIcon()
{
if ((Object)(object)m_instanceMinimapIcon != (Object)null)
{
Minimap.Instance.DeregisterRoomIcon(m_parentRoom, m_instanceMinimapIcon);
m_instanceMinimapIcon = null;
}
}
}
public string name;
public string modID;
public string spritePath;
public string text;
public string acceptText;
public string declineText;
public Action<PlayerController, GameObject> OnAccept;
public Action<PlayerController, GameObject> OnDecline;
public Func<PlayerController, GameObject, bool> CanUse;
public Vector3 talkPointOffset;
public Vector3 offset = new Vector3(43.8f, 42.4f, 42.9f);
public IntVector2 colliderOffset;
public IntVector2 colliderSize;
public bool isToggle;
public bool usesCustomColliderOffsetAndSize;
public Type interactableComponent = null;
public bool isBreachShrine = false;
public PrototypeDungeonRoom room;
public Dictionary<string, int> roomStyles;
public static Dictionary<string, GameObject> builtShrines = new Dictionary<string, GameObject>();
private static bool m_initialized;
private static bool m_builtShrines;
public static void Init()
{
if (m_initialized)
{
return;
}
DungeonHooks.OnFoyerAwake += PlaceBreachShrines;
DungeonHooks.OnPreDungeonGeneration += delegate(LoopDungeonGenerator generator, Dungeon dungeon, DungeonFlow flow, int dungeonSeed)
{
if (((Object)flow).name != "Foyer Flow" && !GameManager.IsReturningToFoyerWithPlayer)
{
CustomShrineController[] array = Object.FindObjectsOfType<CustomShrineController>();
foreach (CustomShrineController customShrineController in array)
{
if (!FakePrefab.IsFakePrefab((Object)(object)customShrineController))
{
Object.Destroy((Object)(object)((Component)customShrineController).gameObject);
}
}
m_builtShrines = false;
}
};
m_initialized = true;
}
public GameObject Build()
{
//IL_0061: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
try
{
Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(spritePath, (Assembly)null);
GameObject val = SpriteBuilder.SpriteFromResource(spritePath, (GameObject)null, (Assembly)null);
string text2 = (((Object)val).name = (modID + ":" + name).ToLower().Replace(" ", "_"));
tk2dSprite component = val.GetComponent<tk2dSprite>();
((tk2dBaseSprite)component).IsPerpendicular = true;
((tk2dBaseSprite)component).PlaceAtPositionByAnchor(offset, (Anchor)1);
Transform transform = new GameObject("talkpoint").transform;
transform.position = val.transform.position + talkPointOffset;
transform.SetParent(val.transform);
if (!usesCustomColliderOffsetAndSize)
{
IntVector2 val2 = default(IntVector2);
((IntVector2)(ref val2))..ctor(((Texture)textureFromResource).width, ((Texture)textureFromResource).height);
colliderOffset = new IntVector2(0, 0);
colliderSize = new IntVector2(val2.x, val2.y / 2);
}
SpeculativeRigidbody val3 = SpriteBuilder.SetUpSpeculativeRigidbody(component, colliderOffset, colliderSize);
CustomShrineController customShrineController = val.AddComponent<CustomShrineController>();
customShrineController.ID = text2;
customShrineController.roomStyles = roomStyles;
customShrineController.isBreachShrine = true;
customShrineController.offset = offset;
customShrineController.pixelColliders = ((BraveBehaviour)val3).specRigidbody.PixelColliders;
customShrineController.factory = this;
customShrineController.OnAccept = OnAccept;
customShrineController.OnDecline = OnDecline;
customShrineController.CanUse = CanUse;
IPlayerInteractable item;
if ((object)interactableComponent != null)
{
Component obj = val.AddComponent(interactableComponent);
item = (IPlayerInteractable)(object)((obj is IPlayerInteractable) ? obj : null);
}
else
{
SimpleInteractable simpleInteractable = val.AddComponent<SimpleInteractable>();
simpleInteractable.isToggle = isToggle;
simpleInteractable.OnAccept = OnAccept;
simpleInteractable.OnDecline = OnDecline;
simpleInteractable.CanUse = CanUse;
simpleInteractable.text = this.text;
simpleInteractable.acceptText = acceptText;
simpleInteractable.declineText = declineText;
simpleInteractable.talkPoint = transform;
item = (IPlayerInteractable)(object)simpleInteractable;
}
GameObject val4 = FakePrefab.Clone(val);
val4.GetComponent<CustomShrineController>().Copy(customShrineController);
((Object)val4).name = text2;
if (isBreachShrine)
{
if (!RoomHandler.unassignedInteractableObjects.Contains(item))
{
RoomHandler.unassignedInteractableObjects.Add(item);
}
}
else
{
if (!Object.op_Implicit((Object)(object)room))
{
room = RoomFactory.CreateEmptyRoom(12, 12);
}
RegisterShrineRoom(val4, room, text2, Vector2.op_Implicit(offset));
}
builtShrines.Add(text2, val4);
DebugUtility.Print<string>("Added shrine: " + text2, "FFFFFF", false);
return val;
}
catch (Exception ex)
{
DebugUtility.PrintException(ex, "FF0000");
return null;
}
}
public static void RegisterShrineRoom(GameObject shrine, PrototypeDungeonRoom protoroom, string ID, Vector2 offset)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
protoroom.category = (RoomCategory)2;
DungeonPrerequisite[] array = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor((float)(protoroom.Width / 2) + offset.x, (float)(protoroom.Height / 2) + offset.y);
protoroom.placedObjectPositions.Add(val);
DungeonPlaceable val2 = ScriptableObject.CreateInstance<DungeonPlaceable>();
val2.width = 2;
val2.height = 2;
val2.respectsEncounterableDifferentiator = true;
List<DungeonPlaceableVariant> list = new List<DungeonPlaceableVariant>();
DungeonPlaceableVariant val3 = new DungeonPlaceableVariant();
val3.percentChance = 1f;
val3.nonDatabasePlaceable = shrine;
val3.prerequisites = array;
val3.materialRequirements = (DungeonPlaceableRoomMaterialRequirement[])(object)new DungeonPlaceableRoomMaterialRequirement[0];
list.Add(val3);
val2.variantTiers = list;
protoroom.placedObjects.Add(new PrototypePlacedObjectData
{
contentsBasePosition = val,
fieldData = new List<PrototypePlacedObjectFieldData>(),
instancePrerequisites = array,
linkedTriggerAreaIDs = new List<int>(),
placeableContents = val2
});
RoomData val4 = default(RoomData);
val4.room = protoroom;
val4.isSpecialRoom = true;
val4.category = "SPECIAL";
val4.specialSubCategory = "UNSPECIFIED_SPECIAL";
RoomData val5 = val4;
RoomFactory.rooms.Add(ID, val5);
DungeonHandler.Register(val5);
}
private static void PlaceBreachShrines()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
if (m_builtShrines)
{
return;
}
DebugUtility.Print<string>("Placing breach shrines: ", "FFFFFF", false);
foreach (GameObject value in builtShrines.Values)
{
try
{
CustomShrineController component = value.GetComponent<CustomShrineController>();
if (component.isBreachShrine)
{
DebugUtility.Print<string>(" " + ((Object)value).name, "FFFFFF", false);
CustomShrineController component2 = Object.Instantiate<GameObject>(value).GetComponent<CustomShrineController>();
component2.Copy(component);
((Component)component2).gameObject.SetActive(true);
((BraveBehaviour)component2).sprite.PlaceAtPositionByAnchor(component2.offset, (Anchor)1);
IPlayerInteractable component3 = ((Component)component2).GetComponent<IPlayerInteractable>();
if (component3 is SimpleInteractable)
{
((SimpleInteractable)(object)component3).OnAccept = component2.OnAccept;
((SimpleInteractable)(object)component3).OnDecline = component2.OnDecline;
((SimpleInteractable)(object)component3).CanUse = component2.CanUse;
}
if (!RoomHandler.unassignedInteractableObjects.Contains(component3))
{
RoomHandler.unassignedInteractableObjects.Add(component3);
}
}
}
catch (Exception ex)
{
DebugUtility.PrintException(ex, "FF0000");
}
}
m_builtShrines = true;
}
}
public class SimpleInteractable : BraveBehaviour, IPlayerInteractable
{
public Action<PlayerController, GameObject> OnAccept;
public Action<PlayerController, GameObject> OnDecline;
public Func<PlayerController, GameObject, bool> CanUse;
public Transform talkPoint;
public string text;
public string acceptText;
public string declineText;
public bool isToggle;
private bool m_isToggled;
private bool m_canUse = true;
private void Start()
{
talkPoint = ((BraveBehaviour)this).transform.Find("talkpoint");
m_isToggled = false;
}
public void Interact(PlayerController interactor)
{
if (!TextBoxManager.HasTextBox(talkPoint))
{
DebugUtility.Print<string>("Can use: " + (CanUse == null), "FFFFFF", false);
m_canUse = ((CanUse != null) ? CanUse(interactor, ((Component)this).gameObject) : m_canUse);
((MonoBehaviour)this).StartCoroutine(HandleConversation(interactor));
}
}
private IEnumerator HandleConversation(PlayerController interactor)
{
TextBoxManager.ShowStoneTablet(talkPoint.position, talkPoint, -1f, text, true, false);
int selectedResponse = -1;
interactor.SetInputOverride("shrineConversation");
yield return null;
if (!m_canUse)
{
GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, (TalkModule)null, declineText, string.Empty);
}
else if (isToggle)
{
if (m_isToggled)
{
GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, (TalkModule)null, declineText, string.Empty);
}
else
{
GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, (TalkModule)null, acceptText, string.Empty);
}
}
else
{
GameUIRoot.Instance.DisplayPlayerConversationOptions(interactor, (TalkModule)null, acceptText, declineText);
}
while (!GameUIRoot.Instance.GetPlayerConversationResponse(ref selectedResponse))
{
yield return null;
}
interactor.ClearInputOverride("shrineConversation");
TextBoxManager.ClearTextBox(talkPoint);
if (m_canUse)
{
if (selectedResponse == 0 && isToggle)
{
(m_isToggled ? OnDecline : OnAccept)?.Invoke(interactor, ((Component)this).gameObject);
m_isToggled = !m_isToggled;
}
else if (selectedResponse == 0)
{
OnAccept?.Invoke(interactor, ((Component)this).gameObject);
}
else
{
OnDecline?.Invoke(interactor, ((Component)this).gameObject);
}
}
}
public void OnEnteredRange(PlayerController interactor)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
SpriteOutlineManager.AddOutlineToSprite(((BraveBehaviour)this).sprite, Color.white, 1f, 0f, (OutlineType)0);
((BraveBehaviour)this).sprite.UpdateZDepth();
}
public void OnExitRange(PlayerController interactor)
{
SpriteOutlineManager.RemoveOutlineFromSprite(((BraveBehaviour)this).sprite, false);
}
public string GetAnimationState(PlayerController interactor, out bool shouldBeFlipped)
{
shouldBeFlipped = false;
return string.Empty;
}
public float GetDistanceToPoint(Vector2 point)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((BraveBehaviour)this).sprite == (Object)null)
{
return 100f;
}
Vector3 val = Vector2.op_Implicit(BraveMathCollege.ClosestPointOnRectangle(point, ((BraveBehaviour)this).specRigidbody.UnitBottomLeft, ((BraveBehaviour)this).specRigidbody.UnitDimensions));
return Vector2.Distance(point, Vector2.op_Implicit(val)) / 1.5f;
}
public float GetOverrideMaxDistance()
{
return -1f;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("kyle.etg.gapi", "Custom Rooms", "1.0.4")]
public class GAPIModule : BaseUnityPlugin
{
public const string GUID = "kyle.etg.gapi";
public const string NAME = "Custom Rooms";
public const string VERSION = "1.0.4";
public void Start()
{
ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
}
public void GMStart(GameManager g)
{
try
{
ShrineFactory.Init();
KeyShrine.Add();
ETGModConsole.Commands.AddUnit("dissectshrine", (Action<string[]>)delegate
{
GameObject closestCustomShrineObject = GetClosestCustomShrineObject();
DebugUtility.BreakdownComponents(closestCustomShrineObject);
DebugUtility.LogPropertiesAndFields<SimpleInteractable>(closestCustomShrineObject.GetComponent<SimpleInteractable>(), "");
});
DebugUtility.Print<string>("Custom Rooms 1.0.4 loaded.", "FF00FF", true);
((MonoBehaviour)this).StartCoroutine(FrameDelay());
}
catch (Exception ex)
{
DebugUtility.Print<string>("Failed to load Custom Rooms Mod", "FF0000", true);
DebugUtility.PrintException(ex, "FF0000");
}
}
public static IEnumerator FrameDelay()
{
yield return null;
GungeonAPI.Init();
}
public void DumpEnemyDatabase()
{
DebugUtility.Print<string>("Dumping enemy database.", "FFFFFF", false);
for (int i = 0; i < ((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries.Count; i++)
{
EnemyDatabaseEntry val = ((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries[i];
DebugUtility.Log<string>($"{((AssetBundleDatabaseEntry)val).myGuid}\t{((AssetBundleDatabaseEntry)val).name}\t{i}\t{val.isNormalEnemy}\t{val.isInBossTab}", "EnemyDump.txt");
}
}
public static GameObject GetClosestCustomShrineObject()
{
//IL_0034: 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)
PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
ShrineFactory.CustomShrineController[] array = Object.FindObjectsOfType<ShrineFactory.CustomShrineController>();
float num = float.MaxValue;
ShrineFactory.CustomShrineController customShrineController = null;
ShrineFactory.CustomShrineController[] array2 = array;
foreach (ShrineFactory.CustomShrineController customShrineController2 in array2)
{
try
{
float num2 = Vector2.Distance(((BraveBehaviour)customShrineController2).sprite.WorldCenter, ((BraveBehaviour)primaryPlayer).sprite.WorldCenter);
if (Object.op_Implicit((Object)(object)customShrineController2) && num2 < num)
{
customShrineController = customShrineController2;
num = num2;
}
}
catch
{
}
}
DebugUtility.Log<ShrineFactory.CustomShrineController>(customShrineController);
return ((Component)customShrineController).gameObject;
}
public static GameObject GetClosestShrineObject()
{
//IL_0034: 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)
PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
AdvancedShrineController[] array = Object.FindObjectsOfType<AdvancedShrineController>();
float num = float.MaxValue;
AdvancedShrineController val = null;
AdvancedShrineController[] array2 = array;
foreach (AdvancedShrineController val2 in array2)
{
try
{
float num2 = Vector2.Distance(((BraveBehaviour)val2).sprite.WorldCenter, ((BraveBehaviour)primaryPlayer).sprite.WorldCenter);
if (Object.op_Implicit((Object)(object)val2) && num2 < num)
{
val = val2;
num = num2;
}
}
catch
{
}
}
DebugUtility.Log<AdvancedShrineController>(val);
return ((Component)val).gameObject;
}
}