using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("AubPiggybackAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Aubarino's API for useful and fun stuff, good for enemies, does stuff well and isn't easy to break much kinda smh")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AubPiggybackAPI")]
[assembly: AssemblyTitle("AubPiggybackAPI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[StructLayout(LayoutKind.Sequential, Size = 1)]
public struct AubPiggyback
{
public static string modName = "";
public static AssetBundle assetBundle;
public static RoundManager activeRoundManager;
public static QuickMenuManager quickMenuManager;
public static StartOfRound startOfRound;
public static Terminal terminal;
public static NetworkManager networkManager;
public static Harmony harmony;
public static int RegisterCustomsRepeats = 0;
public static GameObject piggybackObject;
public static APiggybackBehaviour piggybackBehaviour;
public static bool setup = false;
public static bool prepDone = false;
public static List<SpawnableEnemyWithRarity> EnemiesToAdd = new List<SpawnableEnemyWithRarity>();
public static List<int> EnemyTerminalEntries = new List<int>();
public static List<TerminalNode> TerminalEnemyNodesAdd = new List<TerminalNode>();
public static List<AudioClip> BoomboxAudioToAdd = new List<AudioClip>();
private static IDictionary<string, AudioClip> SFXRegist = new Dictionary<string, AudioClip>();
public static IDictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();
public static IDictionary<string, bool> PrefabsWithNet = new Dictionary<string, bool>();
public static List<string> PrefabEntries = new List<string>();
public static void prep()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
if (!prepDone)
{
EnemiesToAdd = new List<SpawnableEnemyWithRarity>();
BoomboxAudioToAdd = new List<AudioClip>();
EnemyTerminalEntries = new List<int>();
TerminalEnemyNodesAdd = new List<TerminalNode>();
SFXRegist = new Dictionary<string, AudioClip>();
harmony = new Harmony("AubPiggyBack");
PrefabEntries = new List<string>();
prepDone = true;
PrintLine();
Debug.Log((object)"Aub Piggy-back prep stage done.");
PrintLine();
}
}
public static void setSFXRegistry(string entry, AudioClip audio)
{
if (!prepDone)
{
Debug.Log((object)("Aub Piggy-back prep stage not complete, unable to add SFX Registry (" + entry + ") in (" + modName + ")"));
}
else
{
SFXRegist[entry] = audio;
}
}
public static AudioClip getSFXRegistry(string entry)
{
return SFXRegist[entry];
}
public static void setPrefabRegistry(string entry, GameObject prefab, bool hasNet = false)
{
if (!prepDone)
{
Debug.Log((object)("Aub Piggy-back prep stage not complete, unable to add Prefab Registry (" + entry + ") in (" + modName + ")"));
}
else
{
Prefabs[entry] = prefab;
PrefabsWithNet[entry] = hasNet;
PrefabEntries.Add(entry);
}
}
public static GameObject getPrefabRegistry(string entry)
{
return Prefabs[entry];
}
public static void addEnemy(SpawnableEnemyWithRarity enemy, int TerminalID = -1)
{
if ((Object)(object)enemy.enemyType == (Object)null)
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Enemy failed, EnemyType is null"));
}
else if (!prepDone)
{
Debug.Log((object)("Aub Piggy-back prep stage not complete, unable to add Enemy (" + enemy.enemyType.enemyName + ") in (" + modName + ")"));
}
else if (EnemiesToAdd.Contains(enemy))
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Enemy (" + enemy.enemyType.enemyName + ") failed, already contains this enemy"));
}
else
{
EnemiesToAdd.Add(enemy);
EnemyTerminalEntries.Add(TerminalID);
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Enemy (" + enemy.enemyType.enemyName + ") done."));
}
}
public static void addTerminalNode(TerminalNode node)
{
if ((Object)(object)node == (Object)null)
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add TerminalNode failed, tried with null"));
}
else if (!prepDone)
{
Debug.Log((object)("Aub Piggy-back prep stage not complete, unable to add Terminal Node (" + node.creatureName + ") in (" + modName + ")"));
}
else if (TerminalEnemyNodesAdd.Contains(node))
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add TerminalNode (" + node.creatureName + ") failed, already contains this TerminalNode"));
}
else
{
TerminalEnemyNodesAdd.Add(node);
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add TerminalNode (" + node.creatureName + ") done."));
}
}
public static void addBoomboxAudio(AudioClip audio)
{
if ((Object)(object)audio == (Object)null)
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Boombox Audio failed, AudioClip is null"));
}
else if (!prepDone)
{
Debug.Log((object)("Aub Piggy-back prep stage not complete, unable to add Boombox Audio (" + ((Object)audio).name + ") in (" + modName + ")"));
}
else if (BoomboxAudioToAdd.Contains(audio))
{
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Boombox Audio (" + ((Object)audio).name + ") failed, already contains this AudioClip"));
}
else
{
BoomboxAudioToAdd.Add(audio);
Debug.Log((object)("Aub Piggy-back (" + modName + ") Add Boombox Audio (" + ((Object)audio).name + ") done."));
}
}
public static void execute()
{
if (!setup)
{
setup = true;
SceneManager.activeSceneChanged += ChangedActiveScene;
harmony.PatchAll(typeof(ApiggybackNetworkMpatch));
Debug.Log((object)("Aub Piggy-back (" + modName + ") setup stage complete."));
PrintLine();
Debug.Log((object)"");
}
}
public static void ChangedActiveScene(Scene current, Scene next)
{
RoundManager val = Object.FindObjectOfType<RoundManager>();
PrintLine();
if ((Object)(object)val == (Object)null)
{
Debug.Log((object)("Aub Piggy-back ran on scene (" + ((Scene)(ref next)).name + "), RoundManager not found"));
}
else
{
Debug.Log((object)("Aub Piggy-back ran on scene (" + ((Scene)(ref next)).name + "), RoundManager found, executing Piggy-back"));
FindRoundManager();
RegisterCustoms();
}
PrintLine();
}
[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
private static void OnBeforeSceneLoad()
{
}
public static void RegisterCustoms(bool IsExtra = false)
{
if (!setup || (Object)(object)activeRoundManager == (Object)null)
{
if (!IsExtra)
{
Debug.Log((object)"Aub Piggy-back unable to execute fully, due to setup not finishing correctly");
}
return;
}
if (!IsExtra)
{
RegisterCustomsRepeats++;
CreatePiggybackObject();
}
for (int i = 0; i < EnemiesToAdd.Count; i++)
{
if (!activeRoundManager.currentLevel.Enemies.Contains(EnemiesToAdd[i]))
{
activeRoundManager.currentLevel.Enemies.Add(EnemiesToAdd[i]);
}
if (!quickMenuManager.testAllEnemiesLevel.Enemies.Contains(EnemiesToAdd[i]))
{
quickMenuManager.testAllEnemiesLevel.Enemies.Add(EnemiesToAdd[i]);
}
}
for (int j = 0; j < TerminalEnemyNodesAdd.Count; j++)
{
if (!terminal.enemyFiles.Contains(TerminalEnemyNodesAdd[j]))
{
terminal.enemyFiles.Add(TerminalEnemyNodesAdd[j]);
}
}
if (!IsExtra)
{
Debug.Log((object)"Aub Piggy-back added all enemies to testAllEnemiesLevel.");
Debug.Log((object)("Aub Piggy-back registered customs. EnemiesToAdd count (" + EnemiesToAdd.Count + "), TerminalEnemyNodesAdd count (" + TerminalEnemyNodesAdd.Count + ")"));
}
RegisterCustomsOTHER(IsExtra);
}
public static void RegisterCustomsOTHER(bool IsExtra = false)
{
if (!IsExtra)
{
Debug.Log((object)"Aub Piggy-back registering other customs.");
}
IEnumerable<GameObject> enumerable = from obj in Object.FindObjectsOfType<GameObject>()
where ((Object)obj).name.Contains("Boombox")
select obj;
foreach (GameObject item in enumerable)
{
if (!((Object)(object)item.GetComponent<BoomboxItem>() != (Object)null))
{
continue;
}
List<AudioClip> list = new List<AudioClip>();
foreach (AudioClip item2 in BoomboxAudioToAdd)
{
if (!item.GetComponent<BoomboxItem>().musicAudios.Contains(item2))
{
list.Add(item2);
}
}
if (list.Count > 0)
{
item.GetComponent<BoomboxItem>().musicAudios = item.GetComponent<BoomboxItem>().musicAudios.Concat(list.ToArray()).ToArray();
}
}
if (!IsExtra)
{
Debug.Log((object)("Aub Piggy-back registered other customs. BoomboxAudioToAdd count (" + BoomboxAudioToAdd.Count + ")"));
}
}
public static void PrintLine()
{
Debug.Log((object)"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
}
public static void ModLoadStage(string GUID)
{
PrintLine();
modName = GUID;
Debug.Log((object)("Mod (" + modName + ") AubPiggyback plugin loaded."));
}
public static void DebugSpawnEnemy(int index, int amount = 1)
{
SpawnableEnemyWithRarity val = EnemiesToAdd[index];
if (val == null)
{
Debug.Log((object)("Aub Piggy-back [DEBUG] failed to spawn enemy of index (" + index + "), SpawnableEnemyWithRarity is null."));
}
else if ((Object)(object)val.enemyType == (Object)null)
{
Debug.Log((object)("Aub Piggy-back [DEBUG] failed to spawn enemy of index (" + index + "), EnemyType is null."));
}
else if ((Object)(object)val.enemyType.enemyPrefab == (Object)null)
{
Debug.Log((object)("Aub Piggy-back [DEBUG] failed to spawn enemy of index (" + index + "), prefab is null."));
}
else
{
ForceSpawnEnemy(val.enemyType, amount);
}
}
public static void CreatePiggybackObject()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
if ((Object)(object)piggybackObject == (Object)null)
{
Debug.Log((object)"- Aub Piggy-back Behaviour Created -");
piggybackObject = new GameObject("AubPiggyback");
piggybackObject.AddComponent<APiggybackBehaviour>();
}
}
public static void FindRoundManager()
{
activeRoundManager = Object.FindObjectOfType<RoundManager>();
quickMenuManager = Object.FindObjectOfType<QuickMenuManager>();
startOfRound = Object.FindObjectOfType<StartOfRound>();
terminal = Object.FindObjectOfType<Terminal>();
networkManager = NetworkManager.Singleton;
}
public static void ForceSpawnEnemy(EnemyType enemyType, int Amount = 1)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
FindRoundManager();
if (!NetworkManager.Singleton.IsConnectedClient || !NetworkManager.Singleton.IsServer)
{
Debug.Log((object)"Aub Piggy-back [DEBUG] failed to spawn enemy, lacking server privilege");
return;
}
if ((Object)(object)enemyType == (Object)null)
{
Debug.Log((object)"Aub Piggy-back [DEBUG] failed to spawn enemy, as the EnemyType is null");
return;
}
Vector3 zero = Vector3.zero;
zero = ((!((Object)(object)startOfRound.testRoom != (Object)null)) ? activeRoundManager.insideAINodes[Random.Range(0, activeRoundManager.insideAINodes.Length)].transform.position : quickMenuManager.debugEnemySpawnPositions[0].position);
for (int i = 0; i < Amount && i <= 50; i++)
{
activeRoundManager.SpawnEnemyGameObject(zero, 0f, -1, enemyType);
}
Debug.Log((object)("Aub Piggy-back [DEBUG] spawned enemy (" + enemyType.enemyName + ") *" + Amount));
}
}
public class APiggybackBehaviour : MonoBehaviour
{
private float tickCycle = 0f;
private void FixedUpdate()
{
if (tickCycle < Time.fixedTime)
{
tickCycle = Time.fixedTime + 5f;
AubPiggyback.RegisterCustoms(IsExtra: true);
}
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class ApiggybackNetworkMpatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static bool Prefix()
{
Debug.Log((object)"Aub Piggy-back Patched GameNetworkManager");
for (int i = 0; i < AubPiggyback.EnemiesToAdd.Count; i++)
{
if ((Object)(object)AubPiggyback.EnemiesToAdd[i].enemyType.enemyPrefab != (Object)null)
{
NetworkManager.Singleton.AddNetworkPrefab(AubPiggyback.EnemiesToAdd[i].enemyType.enemyPrefab);
Debug.Log((object)("Aub Piggy-back added NetworkPrefab for enemy (" + AubPiggyback.EnemiesToAdd[i].enemyType.enemyName + ")"));
}
}
foreach (string prefabEntry in AubPiggyback.PrefabEntries)
{
if (AubPiggyback.PrefabsWithNet[prefabEntry])
{
if ((Object)(object)AubPiggyback.Prefabs[prefabEntry] == (Object)null)
{
Debug.Log((object)("Aub Piggy-back prefab registry (" + prefabEntry + ") is null"));
continue;
}
NetworkManager.Singleton.AddNetworkPrefab(AubPiggyback.Prefabs[prefabEntry]);
Debug.Log((object)("Aub Piggy-back added NetworkPrefab for prefab registry (" + prefabEntry + ")"));
}
else if ((Object)(object)AubPiggyback.Prefabs[prefabEntry] == (Object)null)
{
Debug.Log((object)("Aub Piggy-back prefab registry (" + prefabEntry + ") is null"));
}
else
{
Debug.Log((object)("Aub Piggy-back prefab registry (" + prefabEntry + ") client-side"));
}
}
return true;
}
}
namespace AubPiggybackAPI
{
[BepInPlugin("AubPiggybackAPI", "AubPiggybackAPI", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
AubPiggyback.ModLoadStage("AubPiggybackAPI");
AubPiggyback.prep();
AubPiggyback.execute();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "AubPiggybackAPI";
public const string PLUGIN_NAME = "AubPiggybackAPI";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}