using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Mirror;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
[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("MapMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e269e4598cfcf4f05004869d8e7b532e1abdd659")]
[assembly: AssemblyProduct("MapMod")]
[assembly: AssemblyTitle("MapMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("firenoobsta.webfishingmap", "Webfishing Custom Map", "1.0.3")]
public class MapMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(MainMenuManager), "Start")]
public class RegisterPortalPrefab
{
[HarmonyPostfix]
private static void Postfix(MainMenuManager __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
ScenePortalData scenePortal = new ScenePortalData
{
_portalType = (PortalType)0,
_subScene = "Assets/Mods/DuckMap/Scenes/MyMap.unity",
_portalCaptionTitle = "Pawprint Point",
_spawnPointTag = "spawnPoint"
};
Portal component = PortalPrefab.GetComponent<Portal>();
component._scenePortal = scenePortal;
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 ... hopefully");
}
}
[HarmonyPatch(typeof(MapInstance), "Start")]
public class CreatePortalEntity
{
[HarmonyPostfix]
private static void Postfix(MapInstance __instance)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
{
Logger.LogInfo((object)"Not server host, not gonna attempt to spawn portal");
return;
}
GameObject val = Object.Instantiate<GameObject>(PortalPrefab);
Debug.Log((object)("Setting " + ((Object)val).name + " position..."));
val.transform.SetPositionAndRotation(new Vector3(-78f, 5f, 169f), Quaternion.identity);
Debug.Log((object)("Assigning " + ((Object)val).name + " to " + ((Scene)(ref __instance._loadedScene)).name));
SceneManager.MoveGameObjectToScene(val, __instance._loadedScene);
val.SetActive(true);
Debug.Log((object)"Updating clients...");
NetworkServer.Spawn(val, (NetworkConnection)null);
Debug.Log((object)"Portal to Pawprint Point created!");
}
if (!(__instance._mapName == "Pawprint Point"))
{
return;
}
AudioMixer val2 = Resources.Load<AudioMixer>("_sound/_mixer/_mixerMain");
if ((Object)(object)val2 == (Object)null)
{
Logger.LogWarning((object)"Couldn't load main mixer from resources!");
return;
}
if (typeof(MapInstance).GetField("_dayAmbience", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is AudioSource[] array)
{
array[0].outputAudioMixerGroup = val2.FindMatchingGroups("Ambience")[0];
Logger.LogInfo((object)"Changed mixer for day time abience");
}
if (typeof(MapInstance).GetField("_nightAmbience", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance) is AudioSource[] array2)
{
array2[0].outputAudioMixerGroup = val2.FindMatchingGroups("Ambience")[0];
Logger.LogInfo((object)"Changed mixer for night time abience");
}
object? value = typeof(MapInstance).GetField("_daytimeMusic", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
AudioSource val3 = (AudioSource)((value is AudioSource) ? value : null);
if ((Object)(object)val3 != (Object)null)
{
val3.outputAudioMixerGroup = val2.FindMatchingGroups("Music")[0];
Logger.LogInfo((object)"Changed mixer for day time music");
}
object? value2 = typeof(MapInstance).GetField("_nightMusic", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
AudioSource val4 = (AudioSource)((value2 is AudioSource) ? value2 : null);
if ((Object)(object)val4 != (Object)null)
{
val4.outputAudioMixerGroup = val2.FindMatchingGroups("Music")[0];
Logger.LogInfo((object)"Changed mixer for night time music");
}
}
}
[HarmonyPatch(typeof(ChatBehaviour), "Rpc_RecieveChatMessage")]
public static class ChatBehaviour_Rpc_RecieveChatMessage
{
public static bool Prefix(ref ChatBehaviour __instance, ref string message)
{
//IL_00a4: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
if (message != null && message.StartsWith("."))
{
Player component = ((Component)__instance).GetComponent<Player>();
if ((Object)(object)component == (Object)null)
{
Logger.LogWarning((object)"Couldn't get player from chat message!");
return true;
}
string[] array = message.Split(' ');
string text = array[0].ToLower();
string[] array2 = ((array.Length > 1) ? array[1..] : new string[0]);
string text2 = text;
string text3 = text2;
if (!(text3 == ".tele"))
{
return true;
}
Debug.Log((object)"Creating new ScenePortalData instance...");
ScenePortalData scenePortal = new ScenePortalData
{
_portalType = (PortalType)0,
_subScene = "Assets/Mods/DuckMap/Scenes/MyMap.unity",
_portalCaptionTitle = "Pawprint Point",
_spawnPointTag = "spawnPoint"
};
Debug.Log((object)"New ScenePortalData instance created.");
Debug.Log((object)"Creating portal to the Abyss Entrance...");
Debug.Log((object)"loading game asset _entity_portal...");
GameObject val = Resources.Load<GameObject>("_prefab/_entity/_portal/_entity_portal");
Debug.Log((object)(((Object)val).name + " loaded."));
Debug.Log((object)("Instantiating prefab " + ((Object)val).name + "..."));
GameObject val2 = Object.Instantiate<GameObject>(val);
Debug.Log((object)(((Object)val2).name + " instantiated."));
Debug.Log((object)"Filling out PortalComponent...");
Portal component2 = val2.GetComponent<Portal>();
component2._scenePortal = scenePortal;
component2._isPortalOpen = true;
component2._disableIfSoloMode = false;
component2._openPortalIfOnQuest = false;
component2._openPortalIfQuestComplete = false;
component2._netDisablePortal = false;
component2.Toggle_NetDisabler(false);
Debug.Log((object)"PortalComponent updated.");
component2.Server_InteractPortal(((NetworkBehaviour)component).netIdentity, (ZoneDifficulty)1);
}
return true;
}
}
internal static ManualLogSource Logger;
public static string AssetFolderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static GameObject PortalPrefab;
public static MapMod Instance { get; private set; }
public static AssetBundle MyAssetBundle { 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
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("firenoobsta.webfishingmap");
val.PatchAll();
Instance = this;
MyAssetBundle = AssetBundle.LoadFromFile(Path.Combine(AssetFolderPath, "duckmap"));
if ((Object)(object)MyAssetBundle == (Object)null)
{
Logger.LogError((object)"Failed to load map asset bundle!");
}
string[] allScenePaths = MyAssetBundle.GetAllScenePaths();
Logger.LogInfo((object)"Listing found scene paths");
string[] array = allScenePaths;
foreach (string text in array)
{
Logger.LogInfo((object)text);
}
Logger.LogInfo((object)"All found paths listed");
}
private void Start()
{
Logger.LogInfo((object)"Webfishing Custom Map Loaded!");
Logger.LogInfo((object)"Version 1.0.3");
Logger.LogInfo((object)"Preparing portal prefab");
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!");
}
}
}