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 System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Mirror;
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+f31b8a3303521decccf8817a051a9ba3d903cabb")]
[assembly: AssemblyProduct("MapLoader")]
[assembly: AssemblyTitle("MapLoader")]
[assembly: AssemblyVersion("1.0.0.0")]
public class PortalSync
{
public List<string> captions;
public bool hasChecked;
public static PortalSync Instance { get; private set; }
public PortalSync()
{
captions = new List<string>();
hasChecked = false;
Instance = this;
MapLoader.Logger.LogInfo((object)"Caption syncer created!");
}
public void CheckPortalCaptions()
{
//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_00b3: 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)
if (hasChecked)
{
return;
}
captions.Clear();
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(0f, -100f, -100f);
Portal[] array = Object.FindObjectsByType<Portal>((FindObjectsInactive)1, (FindObjectsSortMode)0);
Portal[] array2 = array;
foreach (Portal val2 in array2)
{
if (!MapLoader.modSceneNames.Contains(val2._scenePortal._portalCaptionTitle))
{
continue;
}
Scene scene = ((Component)val2).gameObject.scene;
if (((Scene)(ref scene)).name != "DontDestroyOnLoad")
{
captions.Add(val2._scenePortal._portalCaptionTitle);
if (((Component)val2).gameObject.transform.position == val)
{
((Component)val2).gameObject.SetActive(false);
}
}
}
hasChecked = true;
}
}
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.5")]
public class MapLoader : BaseUnityPlugin
{
[HarmonyPatch(typeof(MainMenuManager), "Start")]
public class RegisterPortalPrefab
{
[HarmonyPostfix]
private static void Postfix(MainMenuManager __instance)
{
Logger.LogInfo((object)"Registering portals");
foreach (GameObject portalPrefab in PortalPrefabs)
{
if ((Object)(object)portalPrefab == (Object)null)
{
Logger.LogError((object)"Null portal in portal prefab list!");
continue;
}
NetworkIdentity component = portalPrefab.GetComponent<NetworkIdentity>();
if ((Object)(object)component == (Object)null)
{
Logger.LogError((object)"No netId found on portal object");
continue;
}
if (component.assetId != 0)
{
NetworkClient.RegisterPrefab(portalPrefab);
continue;
}
ScenePortalData scenePortal = portalPrefab.GetComponent<Portal>()._scenePortal;
MD5 mD = MD5.Create();
byte[] b = mD.ComputeHash(Encoding.UTF8.GetBytes(scenePortal._portalCaptionTitle));
Guid guid = new Guid(b);
uint num = NetworkIdentity.AssetGuidToUint(guid);
try
{
NetworkClient.RegisterPrefab(portalPrefab, num);
}
catch (Exception ex)
{
Logger.LogError((object)("Error trying to register " + scenePortal._portalCaptionTitle + " portal!"));
Logger.LogError((object)ex.Message);
}
}
Logger.LogInfo((object)"Portals Registered");
captionSyncer.hasChecked = false;
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();
foreach (string caption in captionSyncer.captions)
{
Player._mainPlayer._waypointAttunements.Add(caption);
}
}
[HarmonyPostfix]
private static void Postfix(MapInstance __instance)
{
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
Logger.LogInfo((object)"Postfix MapInstance Start Called!");
if (__instance._mapName == "Sanctum")
{
if (!NetworkServer.active)
{
captionSyncer.CheckPortalCaptions();
AddPlayerWaypointAttunements();
return;
}
int num = 0;
foreach (GameObject portalPrefab in PortalPrefabs)
{
GameObject val = Object.Instantiate<GameObject>(portalPrefab);
if (num >= portalLocations.Count)
{
val.transform.SetPositionAndRotation(new Vector3(0f, -100f, -100f), Quaternion.identity);
SceneManager.MoveGameObjectToScene(val, __instance._loadedScene);
val.SetActive(true);
NetworkServer.Spawn(val, (NetworkConnection)null);
val.SetActive(false);
Logger.LogInfo((object)("Portal to " + val.GetComponent<Portal>()._scenePortal._portalCaptionTitle + " created! (Is Hidden, check world portal)"));
}
else
{
val.transform.SetPositionAndRotation(portalLocations[num], Quaternion.identity);
SceneManager.MoveGameObjectToScene(val, __instance._loadedScene);
val.SetActive(true);
NetworkServer.Spawn(val, (NetworkConnection)null);
Logger.LogInfo((object)("Portal to " + val.GetComponent<Portal>()._scenePortal._portalCaptionTitle + " created!"));
}
num++;
}
captionSyncer.CheckPortalCaptions();
AddPlayerWaypointAttunements();
}
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_070e: Unknown result type (might be due to invalid IL or missing references)
//IL_0710: Unknown result type (might be due to invalid IL or missing references)
//IL_0774: Unknown result type (might be due to invalid IL or missing references)
//IL_0776: Unknown result type (might be due to invalid IL or missing references)
//IL_07ef: 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);
int num2 = 0;
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)
{
num2++;
list.Add(modSkill);
}
if (dictionary8.TryAdd(modSkill._skillName, modSkill))
{
Logger.LogInfo((object)("Added " + modSkill._skillName + " to skill cache"));
}
}
}
typeof(GameManager).InvokeMember("_bonusSkillCount", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField, null, __instance, new object[1] { num + num2 });
int num3 = (int)typeof(GameManager).GetField("_bonusSkillCount", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
Logger.LogDebug((object)$"BonusSkillCount: {num3}");
list = (from ch in list
orderby ch._skillUtilityType descending, ch._skillControlType
select ch).Reverse().ToList();
__instance.Refresh_StaticBonusSkills();
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 num4 = -30f;
float num5 = -30f;
int num6 = 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"));
num6++;
if (num6 >= 17)
{
mapIconPosition.x = val.x;
mapIconPosition.y += num5;
num6 = 0;
}
else
{
mapIconPosition.x += num4;
}
}
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)
//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Expected O, but got Unknown
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Expected O, but got Unknown
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);
}
MapBundles.Sort((AssetBundle x, AssetBundle y) => ((Object)x).name.CompareTo(((Object)y).name));
foreach (AssetBundle mapBundle in MapBundles)
{
string[] allScenePaths = mapBundle.GetAllScenePaths();
foreach (string path in allScenePaths)
{
modSceneNames.Add(Path.GetFileNameWithoutExtension(path));
}
GameObject val3 = Object.Instantiate<GameObject>(PortalPrefab);
if (mapBundle.GetAllScenePaths().Length == 0)
{
Logger.LogError((object)("Bundle " + ((Object)mapBundle).name + " had no scenes to load!"));
continue;
}
ScenePortalData val4 = new ScenePortalData
{
_portalType = (PortalType)0,
_subScene = mapBundle.GetAllScenePaths()[0],
_portalCaptionTitle = Path.GetFileNameWithoutExtension(mapBundle.GetAllScenePaths()[0]),
_spawnPointTag = "spawnPoint"
};
Portal component = val3.GetComponent<Portal>();
component._isPortalOpen = true;
component._disableIfSoloMode = false;
component._openPortalIfOnQuest = false;
component._openPortalIfQuestComplete = false;
component._netDisablePortal = false;
component.Toggle_NetDisabler(false);
component._scenePortal = val4;
GameObject val5 = new GameObject();
val5.SetActive(false);
SpriteRenderer val6 = val5.AddComponent<SpriteRenderer>();
Billboard target = val5.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(val4._portalCaptionTitle, out var value))
{
val6.sprite = value;
GameObject val7 = Object.Instantiate<GameObject>(val5, val3.transform);
val7.transform.SetLocalPositionAndRotation(new Vector3(0f, 23f, 0f), Quaternion.identity);
val7.SetActive(true);
}
val3.gameObject.SetActive(false);
NetworkIdentity component2 = val3.GetComponent<NetworkIdentity>();
Object.DestroyImmediate((Object)(object)component2);
val3.AddComponent<NetworkIdentity>();
Object.DontDestroyOnLoad((Object)(object)val3);
PortalPrefabs.Add(val3);
}
captionSyncer = new PortalSync();
}
private void Start()
{
Logger.LogInfo((object)"Map Loader Loaded!");
Logger.LogInfo((object)"Version 1.1.5");
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!");
}
}
}