using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
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+fc84be1584a0c50395cf87763b20533abd548e5a")]
[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.LogInfo((object)$"Packet\n From: {((PacketBase)capPacket).PacketSourceGUID} (isHost: {header.SenderIsLobbyOwner})\n PayLoad: {capPacket.payload}");
string text = Regex.Replace(capPacket.payload, "<.*?>", string.Empty);
string[] array = text.Split('#', StringSplitOptions.RemoveEmptyEntries);
if (array.Length < 3)
{
MapLoader.Logger.LogWarning((object)"Message had too few arguments!");
return;
}
if (!int.TryParse(array[1], out var result))
{
MapLoader.Logger.LogWarning((object)("Couldn't parse index from: " + array[1]));
return;
}
string value = array[2];
if (Instance != null)
{
Instance.receivedPortalCaptions[result] = value;
}
}
public void SendLocalCaptions()
{
foreach (KeyValuePair<int, string> localPortalCaption in localPortalCaptions)
{
string payload = $"<>#CAPTION#{localPortalCaption.Key}#{localPortalCaption.Value}";
try
{
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new CapPacket(payload));
}
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!");
}
}
}
}
namespace maploader;
[BepInPlugin("firenoobsta.maploader", "Map Loader", "1.1.1")]
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();
}
}
[HarmonyPatch(typeof(MapInstance), "Start")]
public class CreatePortalEntity
{
private static void AddPlayerWaypointAttunements()
{
if (!Object.op_Implicit((Object)(object)Player._mainPlayer))
{
Logger.LogError((object)"Couldn't get _mainPlayer!");
return;
}
foreach (string modSceneName in modSceneNames)
{
if (Player._mainPlayer._waypointAttunements.Contains(modSceneName))
{
Player._mainPlayer._waypointAttunements.Remove(modSceneName);
}
}
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_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: 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_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: 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++;
}
}
AudioMixer val6 = Resources.Load<AudioMixer>("_sound/_mixer/_mixerMain");
if ((Object)(object)val6 == (Object)null)
{
Logger.LogWarning((object)"Couldn't load main mixer from resources!");
return;
}
AudioSource[] array = Object.FindObjectsOfType<AudioSource>();
foreach (AudioSource val7 in array)
{
List<string> modSceneNames = MapLoader.modSceneNames;
Scene scene = ((Component)val7).gameObject.scene;
if (modSceneNames.Contains(((Scene)(ref scene)).name) && (Object)(object)val7.outputAudioMixerGroup != (Object)null)
{
val7.outputAudioMixerGroup = val6.FindMatchingGroups(((Object)val7.outputAudioMixerGroup).name)[0];
}
}
}
}
[HarmonyPatch(typeof(GameManager), "Cache_ScriptableAssets")]
public class AddExtraScriptables
{
[HarmonyPostfix]
private static void Postfix(GameManager __instance)
{
//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
//IL_062d: Unknown result type (might be due to invalid IL or missing references)
//IL_062f: 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"));
}
}
}
if (typeof(GameManager).GetField("_cachedScriptableSkills", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is Dictionary<string, ScriptableSkill> dictionary8)
{
Logger.LogInfo((object)"Successfully got skill cache");
foreach (ScriptableSkill modSkill in modSkills)
{
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(500f, -400f);
float num = -40f;
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"));
mapIconPosition.x += num;
}
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 PortalSync captionSyncer;
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(-89f, 5f, 200f));
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(56f, 5f, 244f));
portalLocations.Add(new Vector3(47f, 5f, 253f));
portalLocations.Add(new Vector3(37f, 5f, 261f));
portalLocations.Add(new Vector3(23f, 5f, 268f));
modSceneNames = 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;
}
foreach (AssetBundle mapBundle in MapBundles)
{
string[] allScenePaths = mapBundle.GetAllScenePaths();
foreach (string path in allScenePaths)
{
modSceneNames.Add(Path.GetFileNameWithoutExtension(path));
}
}
Logger.LogInfo((object)"Scene Names: ");
foreach (string modSceneName in modSceneNames)
{
Logger.LogInfo((object)modSceneName);
}
captionSyncer = new PortalSync();
}
private void Start()
{
Logger.LogInfo((object)"Map Loader Loaded!");
Logger.LogInfo((object)"Version 1.1.1");
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!");
}
}
}