using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Mirror;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
using maploader;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MapLoader")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d1fcc331cc605a5dc6e41c09eda007e1e8922c31")]
[assembly: AssemblyProduct("MapLoader")]
[assembly: AssemblyTitle("MapLoader")]
[assembly: AssemblyVersion("1.0.0.0")]
public class CapPacket : PacketBase
{
public override string PacketSourceGUID => "firenoobsta.maploader";
[JsonProperty]
public string payload { get; set; }
public CapPacket(string payload)
{
this.payload = payload;
}
}
public class PortalSync
{
[HarmonyPatch(typeof(Player), "Awake")]
public static class HostCaptionSender
{
public static void Postfix(Player __instance)
{
MapLoader.Logger.LogInfo((object)"Postfix Player Awake called!");
if (NetworkServer.active)
{
MapLoader.Logger.LogInfo((object)"Sending captions");
if (Instance != null)
{
Instance.SendLocalCaptions();
}
}
}
}
public Dictionary<int, string> localPortalCaptions;
public Dictionary<int, string> receivedPortalCaptions;
public static PortalSync Instance { get; private set; }
public PortalSync()
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
localPortalCaptions = new Dictionary<int, string>();
receivedPortalCaptions = new Dictionary<int, string>();
Instance = this;
MapLoader.MapBundles.Sort((AssetBundle x, AssetBundle y) => ((Object)x).name.CompareTo(((Object)y).name));
int num = 0;
foreach (AssetBundle mapBundle in MapLoader.MapBundles)
{
localPortalCaptions.Add(num, Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0]));
num++;
}
CodeTalkerNetwork.RegisterListener<CapPacket>(new PacketListener(ReceiveCapPacket));
MapLoader.Logger.LogInfo((object)"Caption syncer created!");
}
internal static void ReceiveCapPacket(PacketHeader header, PacketBase packet)
{
if (!(packet is CapPacket capPacket))
{
return;
}
MapLoader.Logger.LogDebug((object)$"Packet\n From: {((PacketBase)capPacket).PacketSourceGUID} (isHost: {header.SenderIsLobbyOwner})\n PayLoad: {capPacket.payload}");
string[] array = capPacket.payload.Split('\n', StringSplitOptions.RemoveEmptyEntries);
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split('#', StringSplitOptions.RemoveEmptyEntries);
if (array3.Length == 2 && int.TryParse(array3[0], out var result))
{
string value = array3[1];
if (Instance != null)
{
Instance.receivedPortalCaptions[result] = value;
}
}
}
}
public void SendLocalCaptions()
{
string text = "";
foreach (KeyValuePair<int, string> localPortalCaption in localPortalCaptions)
{
string text2 = $"{localPortalCaption.Key}#{localPortalCaption.Value}\n";
text += text2;
}
if (text.Length > 4000)
{
MapLoader.Logger.LogWarning((object)"You have so many captions to send that it might not fit in one packet!");
}
try
{
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new CapPacket(text));
}
catch
{
MapLoader.Logger.LogError((object)"Failed to send caption!");
}
}
public void SetReceivedCaptions()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_00c0: Expected O, but got Unknown
Portal[] array = Object.FindObjectsOfType<Portal>();
Portal[] array2 = array;
foreach (Portal val in array2)
{
if (!MapLoader.portalLocations.Contains(((Component)val).gameObject.transform.position))
{
continue;
}
MapLoader.Logger.LogInfo((object)"Found modded portal to sync");
if (receivedPortalCaptions.TryGetValue(MapLoader.portalLocations.IndexOf(((Component)val).gameObject.transform.position), out var value))
{
MapLoader.Logger.LogInfo((object)("Successfully synced portal with caption " + value));
if (MapLoader.modSceneNames.Contains(value))
{
val._scenePortal._portalCaptionTitle = value;
GameObject val2 = new GameObject();
val2.SetActive(false);
SpriteRenderer val3 = val2.AddComponent<SpriteRenderer>();
Billboard target = val2.AddComponent<Billboard>();
try
{
typeof(Billboard).InvokeMember("findMainCamera", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField, null, target, new object[1] { true });
}
catch
{
MapLoader.Logger.LogWarning((object)"Couldn't change billboard camera for icon");
}
if (MapLoader.mapIcons.TryGetValue(value, out var value2))
{
val3.sprite = value2;
GameObject val4 = Object.Instantiate<GameObject>(val2, ((Component)val).gameObject.transform);
val4.transform.SetLocalPositionAndRotation(new Vector3(0f, 23f, 0f), Quaternion.identity);
val4.SetActive(true);
}
}
else
{
MapLoader.Logger.LogInfo((object)("We don't have " + value + "! Attempting to delete portal on client's side!"));
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
else
{
MapLoader.Logger.LogWarning((object)"No caption data received for portal, its destination is unknown!");
}
}
}
}
public class SceneCleanup
{
public AudioMixer mainMixer;
public Dictionary<string, ScriptableProfession> baseProfessions;
public SceneCleanup()
{
mainMixer = Resources.Load<AudioMixer>("_sound/_mixer/_mixerMain");
if ((Object)(object)mainMixer == (Object)null)
{
MapLoader.Logger.LogWarning((object)"Couldn't load main mixer from resources!");
return;
}
baseProfessions = new Dictionary<string, ScriptableProfession>();
MapLoader.Logger.LogDebug((object)"Trying to get professions ...");
ScriptableProfession[] scriptableProfessions = GameManager._current._statLogics._scriptableProfessions;
foreach (ScriptableProfession val in scriptableProfessions)
{
if ((Object)(object)val != (Object)null)
{
MapLoader.Logger.LogDebug((object)("Profession Name: " + val._professionName));
baseProfessions.TryAdd(val._professionName, val);
}
}
}
public void FixAudioSources(GameObject obj)
{
if ((Object)(object)mainMixer == (Object)null)
{
return;
}
AudioSource[] componentsInChildren = obj.GetComponentsInChildren<AudioSource>(true);
foreach (AudioSource val in componentsInChildren)
{
if ((Object)(object)val.outputAudioMixerGroup != (Object)null)
{
val.outputAudioMixerGroup = mainMixer.FindMatchingGroups(((Object)val.outputAudioMixerGroup).name)[0];
}
}
}
public void FixResourceProfessionReferences(GameObject obj)
{
if (baseProfessions.Count == 0)
{
return;
}
ResourceEntity[] componentsInChildren = obj.GetComponentsInChildren<ResourceEntity>(true);
foreach (ResourceEntity val in componentsInChildren)
{
if (Object.op_Implicit((Object)(object)val._scriptableProfession) && baseProfessions.TryGetValue(val._scriptableProfession._professionName, out var value))
{
val._scriptableProfession = value;
MapLoader.Logger.LogDebug((object)("Sucessfully updated profession of resource " + ((Object)val).name));
}
}
}
public void CleanScene(Scene scene)
{
if (!((Scene)(ref scene)).IsValid())
{
MapLoader.Logger.LogWarning((object)"Invalid scene sent to cleanup. Couldn't fix references!");
return;
}
GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
foreach (GameObject obj in rootGameObjects)
{
FixAudioSources(obj);
FixResourceProfessionReferences(obj);
}
}
}
namespace maploader;
[BepInPlugin("firenoobsta.maploader", "Map Loader", "1.1.3")]
public class MapLoader : BaseUnityPlugin
{
[HarmonyPatch(typeof(MainMenuManager), "Start")]
public class RegisterPortalPrefab
{
[HarmonyPostfix]
private static void Postfix(MainMenuManager __instance)
{
Logger.LogInfo((object)"Registering portal prefab");
Portal component = PortalPrefab.GetComponent<Portal>();
component._isPortalOpen = true;
component._disableIfSoloMode = false;
component._openPortalIfOnQuest = false;
component._openPortalIfQuestComplete = false;
component._netDisablePortal = false;
component.Toggle_NetDisabler(false);
NetworkClient.RegisterPrefab(PortalPrefab);
Logger.LogInfo((object)"Portal Prefab Registered");
captionSyncer.receivedPortalCaptions.Clear();
if (sceneCleaner == null)
{
sceneCleaner = new SceneCleanup();
}
}
}
[HarmonyPatch(typeof(MapInstance), "Start")]
public class CreatePortalEntity
{
private static void RemoveModdedAttunements()
{
Player._mainPlayer._waypointAttunements.RemoveAll((string id) => !originalAttunementIDs.Contains(id));
}
private static void AddPlayerWaypointAttunements()
{
if (!Object.op_Implicit((Object)(object)Player._mainPlayer))
{
Logger.LogError((object)"Couldn't get _mainPlayer!");
return;
}
RemoveModdedAttunements();
if (NetworkServer.active)
{
foreach (AssetBundle mapBundle in MapBundles)
{
if (!Player._mainPlayer._waypointAttunements.Contains(Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0])))
{
Player._mainPlayer._waypointAttunements.Add(Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0]));
}
}
return;
}
foreach (string value in captionSyncer.receivedPortalCaptions.Values)
{
Player._mainPlayer._waypointAttunements.Add(value);
}
}
[HarmonyPostfix]
private static void Postfix(MapInstance __instance)
{
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Expected O, but got Unknown
Logger.LogInfo((object)"Postfix MapInstance Start Called!");
if (__instance._mapName == "Sanctum")
{
AddPlayerWaypointAttunements();
if (!NetworkServer.active)
{
Logger.LogInfo((object)"Not server host, attempting to set my portal captions. (Should have already received them by now)");
captionSyncer.SetReceivedCaptions();
return;
}
MapBundles.Sort((AssetBundle x, AssetBundle y) => ((Object)x).name.CompareTo(((Object)y).name));
int num = 0;
foreach (AssetBundle mapBundle in MapBundles)
{
if (num >= portalLocations.Count)
{
Logger.LogWarning((object)"I ran out of locations to put portals!");
Logger.LogWarning((object)"Aborting placement of other portals");
break;
}
if (mapBundle.GetAllScenePaths().Length == 0)
{
Logger.LogError((object)("Bundle " + ((Object)mapBundle).name + " had no scenes to load!"));
continue;
}
ScenePortalData val = new ScenePortalData
{
_portalType = (PortalType)0,
_subScene = mapBundle.GetAllScenePaths()[0],
_portalCaptionTitle = Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0]),
_spawnPointTag = "spawnPoint"
};
GameObject val2 = Object.Instantiate<GameObject>(PortalPrefab);
val2.GetComponent<Portal>()._scenePortal = val;
val2.transform.SetPositionAndRotation(portalLocations[num], Quaternion.identity);
SceneManager.MoveGameObjectToScene(val2, __instance._loadedScene);
val2.SetActive(true);
GameObject val3 = new GameObject();
val3.SetActive(false);
SpriteRenderer val4 = val3.AddComponent<SpriteRenderer>();
Billboard target = val3.AddComponent<Billboard>();
try
{
typeof(Billboard).InvokeMember("findMainCamera", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField, null, target, new object[1] { true });
}
catch
{
Logger.LogWarning((object)"Couldn't change billboard camera for icon");
}
if (mapIcons.TryGetValue(val._portalCaptionTitle, out var value))
{
val4.sprite = value;
GameObject val5 = Object.Instantiate<GameObject>(val3, val2.transform);
val5.transform.SetLocalPositionAndRotation(new Vector3(0f, 23f, 0f), Quaternion.identity);
val5.SetActive(true);
}
NetworkServer.Spawn(val2, (NetworkConnection)null);
Logger.LogInfo((object)("Portal to " + val2.GetComponent<Portal>()._scenePortal._portalCaptionTitle + " created!"));
num++;
}
}
List<string> modSceneNames = MapLoader.modSceneNames;
Scene scene = ((Component)__instance).gameObject.scene;
if (modSceneNames.Contains(((Scene)(ref scene)).name))
{
sceneCleaner.CleanScene(((Component)__instance).gameObject.scene);
}
}
}
[HarmonyPatch(typeof(GameManager), "Cache_ScriptableAssets")]
public class AddExtraScriptables
{
[HarmonyPostfix]
private static void Postfix(GameManager __instance)
{
//IL_065c: Unknown result type (might be due to invalid IL or missing references)
//IL_065e: Unknown result type (might be due to invalid IL or missing references)
//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
//IL_073d: Unknown result type (might be due to invalid IL or missing references)
Logger.LogInfo((object)"Postfix cache scriptables called!");
if (typeof(GameManager).GetField("_cachedScriptableCreeps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptableCreep> dictionary)
{
Logger.LogInfo((object)"Successfully got creep cache");
foreach (ScriptableCreep modCreep in modCreeps)
{
if (dictionary.TryAdd(modCreep._creepName, modCreep))
{
Logger.LogInfo((object)("Added " + modCreep._creepName + " to creep cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableItems", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptableItem> dictionary2)
{
Logger.LogInfo((object)"Successfully got item cache");
foreach (ScriptableItem modItem in modItems)
{
if (dictionary2.TryAdd(modItem._itemName, modItem))
{
Logger.LogInfo((object)("Added " + modItem._itemName + " to item cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableQuests", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptableQuest> dictionary3)
{
Logger.LogInfo((object)"Successfully got quest cache");
foreach (ScriptableQuest modQuest in modQuests)
{
if (dictionary3.TryAdd(modQuest._questName, modQuest))
{
Logger.LogInfo((object)("Added " + modQuest._questName + " to quest cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableConditions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<int, ScriptableCondition> dictionary4)
{
Logger.LogInfo((object)"Successfully got condition cache");
foreach (ScriptableCondition modCondition in modConditions)
{
if (dictionary4.TryAdd(modCondition._ID, modCondition))
{
Logger.LogInfo((object)("Added " + modCondition._conditionName + " to condition cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableStatModifiers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<int, ScriptableStatModifier> dictionary5)
{
Logger.LogInfo((object)"Successfully got stat modifier cache");
foreach (ScriptableStatModifier modStatModifier in modStatModifiers)
{
if (dictionary5.TryAdd(modStatModifier._modifierID, modStatModifier))
{
Logger.LogInfo((object)("Added " + modStatModifier._modifierTag + " to stat modifier cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableRaces", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptablePlayerRace> dictionary6)
{
Logger.LogInfo((object)"Successfully got race cache");
foreach (ScriptablePlayerRace modPlayerRace in modPlayerRaces)
{
if (dictionary6.TryAdd(modPlayerRace._raceName, modPlayerRace))
{
Logger.LogInfo((object)("Added " + modPlayerRace._raceName + " to race cache"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptablePlayerClasses", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptablePlayerBaseClass> dictionary7)
{
Logger.LogInfo((object)"Successfully got class cache");
foreach (ScriptablePlayerBaseClass modPlayerClass in modPlayerClasses)
{
if (dictionary7.TryAdd(modPlayerClass._className, modPlayerClass))
{
Logger.LogInfo((object)("Added " + modPlayerClass._className + " to class cache"));
}
}
}
Dictionary<string, ScriptableSkill> dictionary8 = typeof(GameManager).GetField("_cachedScriptableSkills", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) as Dictionary<string, ScriptableSkill>;
int num = (int)typeof(GameManager).GetField("_bonusSkillCount", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
Logger.LogDebug((object)$"BonusSkillCount: {num}");
List<ScriptableSkill> list = typeof(GameManager).GetField("_foundBonusSkills", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) as List<ScriptableSkill>;
if (dictionary8 != null && list != null)
{
Logger.LogInfo((object)"Successfully got skill cache");
foreach (ScriptableSkill modSkill in modSkills)
{
if (modSkill._allowAsBonusSkill)
{
num++;
list.Add(modSkill);
}
if (dictionary8.TryAdd(modSkill._skillName, modSkill))
{
Logger.LogInfo((object)("Added " + modSkill._skillName + " to skill cache"));
}
}
}
if (!(typeof(GameManager).GetField("_cachedScriptableMapDatas", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptableMapData> dictionary9))
{
return;
}
Logger.LogInfo((object)"Successfully got mapData cache");
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(250f, -150f);
float num2 = -30f;
float num3 = -30f;
int num4 = 0;
Vector2 mapIconPosition = val;
foreach (AssetBundle mapBundle in MapBundles)
{
ScriptableMapData val2 = ScriptableObject.CreateInstance<ScriptableMapData>();
val2._subScene = mapBundle.GetAllScenePaths()[0];
val2._mapCaptionTitle = Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0]);
val2._spawnPointTag = "spawnPoint";
val2._mapLockID = "sanctum";
val2._mapIconPosition = mapIconPosition;
if (mapIcons.TryGetValue(val2._mapCaptionTitle, out var value))
{
val2._mapSelectionIcon = value;
}
if (dictionary9.TryAdd(val2._mapCaptionTitle, val2))
{
Logger.LogInfo((object)("Added " + val2._mapCaptionTitle + " to map data cache"));
num4++;
if (num4 >= 17)
{
mapIconPosition.x = val.x;
mapIconPosition.y += num3;
num4 = 0;
}
else
{
mapIconPosition.x += num2;
}
}
else
{
Logger.LogWarning((object)("Couldn't add " + val2._mapCaptionTitle + " to map data cache!"));
}
}
}
}
internal static ManualLogSource Logger;
public static string PluginFolderPath;
public static List<string> modSceneNames;
public static Dictionary<string, Sprite> mapIcons;
public static List<ScriptableCreep> modCreeps;
public static List<ScriptableItem> modItems;
public static List<ScriptableQuest> modQuests;
public static List<ScriptableCondition> modConditions;
public static List<ScriptableStatModifier> modStatModifiers;
public static List<ScriptablePlayerRace> modPlayerRaces;
public static List<ScriptablePlayerBaseClass> modPlayerClasses;
public static List<ScriptableSkill> modSkills;
public static List<GameObject> PortalPrefabs;
public static GameObject PortalPrefab;
public static List<Vector3> portalLocations;
public static List<string> originalAttunementIDs;
public static PortalSync captionSyncer;
public static SceneCleanup sceneCleaner;
public static MapLoader Instance { get; private set; }
public static AssetBundle MyAssetBundle { get; private set; }
public static List<AssetBundle> MapBundles { get; private set; }
public static List<AssetBundle> ScriptableBundles { get; private set; }
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_006d: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("firenoobsta.maploader");
val.PatchAll();
Instance = this;
PluginFolderPath = Paths.PluginPath;
MapBundles = new List<AssetBundle>();
ScriptableBundles = new List<AssetBundle>();
PortalPrefabs = new List<GameObject>();
portalLocations = new List<Vector3>();
portalLocations.Add(new Vector3(-74f, 5f, 162f));
portalLocations.Add(new Vector3(-82f, 5f, 173f));
portalLocations.Add(new Vector3(-79f, 5f, 192f));
portalLocations.Add(new Vector3(-89f, 5f, 217f));
portalLocations.Add(new Vector3(58f, 5f, 162f));
portalLocations.Add(new Vector3(68f, 5f, 173f));
portalLocations.Add(new Vector3(69f, 5f, 200f));
portalLocations.Add(new Vector3(69f, 5f, 217f));
portalLocations.Add(new Vector3(59f, 5f, 243f));
portalLocations.Add(new Vector3(42f, 5f, 244f));
portalLocations.Add(new Vector3(37f, 5f, 261f));
portalLocations.Add(new Vector3(23f, 5f, 268f));
modSceneNames = new List<string>();
originalAttunementIDs = new List<string>();
modCreeps = new List<ScriptableCreep>();
modItems = new List<ScriptableItem>();
modQuests = new List<ScriptableQuest>();
modConditions = new List<ScriptableCondition>();
modStatModifiers = new List<ScriptableStatModifier>();
modPlayerRaces = new List<ScriptablePlayerRace>();
modPlayerClasses = new List<ScriptablePlayerBaseClass>();
modSkills = new List<ScriptableSkill>();
mapIcons = new Dictionary<string, Sprite>();
Logger.LogInfo((object)("Plugin Folder Path: " + PluginFolderPath));
if (Directory.Exists(PluginFolderPath))
{
CheckDirectory(PluginFolderPath);
}
PortalPrefab = Resources.Load<GameObject>("_prefab/_entity/_portal/_entity_portal");
if ((Object)(object)PortalPrefab == (Object)null)
{
Logger.LogError((object)"Couldn't load portal prefab from resources!");
return;
}
ScriptableMapData[] array = Resources.LoadAll<ScriptableMapData>("_MAPDATA/");
if (!array.Any())
{
Logger.LogError((object)"Couldn't load original map data!");
return;
}
ScriptableMapData[] array2 = array;
foreach (ScriptableMapData val2 in array2)
{
originalAttunementIDs.Add(val2._mapLockID);
}
foreach (AssetBundle mapBundle in MapBundles)
{
string[] allScenePaths = mapBundle.GetAllScenePaths();
foreach (string path in allScenePaths)
{
modSceneNames.Add(Path.GetFileNameWithoutExtension(path));
}
}
captionSyncer = new PortalSync();
}
private void Start()
{
Logger.LogInfo((object)"Map Loader Loaded!");
Logger.LogInfo((object)"Version 1.1.3");
Logger.LogInfo((object)"Current loaded bundles: ");
foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
{
Logger.LogInfo((object)((Object)allLoadedAssetBundle).name);
}
}
public static void CheckDirectory(string dirPath)
{
string[] files = Directory.GetFiles(dirPath);
string[] array = files;
foreach (string filePath in array)
{
CheckFile(filePath);
}
string[] directories = Directory.GetDirectories(dirPath);
string[] array2 = directories;
foreach (string dirPath2 in array2)
{
CheckDirectory(dirPath2);
}
}
public static void CheckFile(string filePath)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
if (filePath.EndsWith(".mapbundle"))
{
Logger.LogInfo((object)("Loading map asset bundle: " + Path.GetFileName(filePath)));
AssetBundle val = AssetBundle.LoadFromFile(filePath);
if ((Object)(object)val == (Object)null)
{
Logger.LogError((object)("Failed to load asset bundle: " + Path.GetFileName(filePath)));
return;
}
Logger.LogInfo((object)"Adding to map bundle list");
string path = Path.Combine(Path.GetDirectoryName(filePath), "icon.png");
Logger.LogInfo((object)"Checking for icon ...");
try
{
byte[] array = File.ReadAllBytes(path);
Texture2D val2 = new Texture2D(2, 2);
ImageConversion.LoadImage(val2, array);
Sprite value = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 50f);
mapIcons.Add(Path.GetFileNameWithoutExtension(val.GetAllScenePaths()[0]), value);
}
catch
{
Logger.LogWarning((object)("Couldn't get icon for " + Path.GetFileName(filePath) + "!"));
}
MapBundles.Add(val);
Logger.LogInfo((object)"Successfully loaded bundle!");
}
else
{
if (!filePath.EndsWith(".scriptable"))
{
return;
}
Logger.LogInfo((object)("Loading scriptables asset bundle: " + Path.GetFileName(filePath)));
AssetBundle val3 = AssetBundle.LoadFromFile(filePath);
if ((Object)(object)val3 == (Object)null)
{
Logger.LogError((object)("Failed to load asset bundle: " + Path.GetFileName(filePath)));
return;
}
Logger.LogInfo((object)"Adding to scriptable bundle list");
ScriptableBundles.Add(val3);
ScriptableCreep[] array2 = val3.LoadAllAssets<ScriptableCreep>();
foreach (ScriptableCreep val4 in array2)
{
Logger.LogInfo((object)(val4._creepName + " creep found in bundle! Logging it"));
modCreeps.Add(val4);
}
ScriptableItem[] array3 = val3.LoadAllAssets<ScriptableItem>();
foreach (ScriptableItem val5 in array3)
{
Logger.LogInfo((object)(val5._itemName + " item found in bundle! Logging it"));
modItems.Add(val5);
}
ScriptableQuest[] array4 = val3.LoadAllAssets<ScriptableQuest>();
foreach (ScriptableQuest val6 in array4)
{
Logger.LogInfo((object)(val6._questName + " quest found in bundle! Logging it"));
modQuests.Add(val6);
}
ScriptableCondition[] array5 = val3.LoadAllAssets<ScriptableCondition>();
foreach (ScriptableCondition val7 in array5)
{
Logger.LogInfo((object)(val7._conditionName + " condition found in bundle! Logging it"));
modConditions.Add(val7);
}
ScriptableStatModifier[] array6 = val3.LoadAllAssets<ScriptableStatModifier>();
foreach (ScriptableStatModifier val8 in array6)
{
Logger.LogInfo((object)(val8._modifierTag + " stat modifier found in bundle! Logging it"));
modStatModifiers.Add(val8);
}
ScriptablePlayerRace[] array7 = val3.LoadAllAssets<ScriptablePlayerRace>();
foreach (ScriptablePlayerRace val9 in array7)
{
Logger.LogInfo((object)(val9._raceName + " race found in bundle! Logging it"));
modPlayerRaces.Add(val9);
}
ScriptablePlayerBaseClass[] array8 = val3.LoadAllAssets<ScriptablePlayerBaseClass>();
foreach (ScriptablePlayerBaseClass val10 in array8)
{
Logger.LogInfo((object)(val10._className + " class found in bundle! Logging it"));
modPlayerClasses.Add(val10);
}
ScriptableSkill[] array9 = val3.LoadAllAssets<ScriptableSkill>();
foreach (ScriptableSkill val11 in array9)
{
Logger.LogInfo((object)(val11._skillName + " skill found in bundle! Logging it"));
modSkills.Add(val11);
}
Logger.LogInfo((object)"Successfully loaded bundle!");
}
}
}