using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.FalseSonBoss;
using EntityStates.Missions.BrotherEncounter;
using On.EntityStates.FalseSonBoss;
using On.EntityStates.Missions.BrotherEncounter;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Respawn_For_Mithrix;
public class Respawn_For_MithrixContent : IContentPackProvider
{
internal ManualLogSource lPluginLogger;
internal GameObject oRezEffect;
internal Dictionary<string, bool> dicConfig;
public string identifier => "com.Shasocais.Respawn_For_Mithrix";
public static ReadOnlyContentPack readOnlyContentPack => new ReadOnlyContentPack(Respawn_For_MithrixContentPack);
internal static ContentPack Respawn_For_MithrixContentPack { get; } = new ContentPack();
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
oRezEffect = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/HippoRezEffect");
yield break;
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
lPluginLogger.LogInfo((object)"Adding Hook");
if (dicConfig.TryGetValue("Mithrix", out var value) && value)
{
PreEncounter.OnEnter += new hook_OnEnter(RespawnPlayers_Mithrix);
}
if (dicConfig.TryGetValue("FalseSon", out value) && value)
{
HeartSpawnState.OnEnter += new hook_OnEnter(RespawnPlayers_FalseSon);
}
lPluginLogger.LogInfo((object)"Respawn For Mithrix -- loaded");
args.ReportProgress(1f);
yield break;
}
private void AddSelf(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)this);
}
internal Respawn_For_MithrixContent(ManualLogSource pluginLogger, bool enableMithrixHook, bool enableFalseSonHook)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
lPluginLogger = pluginLogger;
dicConfig = new Dictionary<string, bool>();
dicConfig.Add("Mithrix", enableMithrixHook);
dicConfig.Add("FalseSon", enableFalseSonHook);
ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddSelf);
}
private void RespawnPlayers_Mithrix(orig_OnEnter orig, PreEncounter self)
{
RespawnPlayers();
orig.Invoke(self);
}
private void RespawnPlayers_FalseSon(orig_OnEnter orig, HeartSpawnState self)
{
RespawnPlayers();
orig.Invoke(self);
}
private void RespawnPlayers()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Expected O, but got Unknown
if (!NetworkServer.active)
{
return;
}
foreach (CharacterMaster item in CharacterMaster.readOnlyInstancesList.Where((CharacterMaster x) => x.IsDeadAndOutOfLivesServer() && (int)x.teamIndex == 1))
{
try
{
Vector3 deathFootPosition = item.deathFootPosition;
deathFootPosition = (Vector3)(((??)TeleportHelper.FindSafeTeleportDestination(item.deathFootPosition, item.bodyPrefab.GetComponent<CharacterBody>(), RoR2Application.rng)) ?? item.deathFootPosition);
item.Respawn(deathFootPosition, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), false);
item.GetBody().AddTimedBuff(Buffs.Immune, 3f);
if (Object.op_Implicit((Object)(object)item.bodyInstanceObject))
{
EntityStateMachine[] components = item.bodyInstanceObject.GetComponents<EntityStateMachine>();
foreach (EntityStateMachine obj in components)
{
obj.initialStateType = obj.mainStateType;
}
if (Object.op_Implicit((Object)(object)oRezEffect))
{
EffectManager.SpawnEffect(oRezEffect, new EffectData
{
origin = deathFootPosition,
rotation = item.bodyInstanceObject.transform.rotation
}, true);
}
}
}
catch (Exception ex)
{
lPluginLogger.LogWarning((object)"Failed to rez");
lPluginLogger.LogWarning((object)ex.Message);
}
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Shasocais.Respawn_For_Mithrix", "Respawn For Mithrix", "1.1.1")]
public class Respawn_For_MithrixMain : BaseUnityPlugin
{
public const string GUID = "com.Shasocais.Respawn_For_Mithrix";
public const string MODNAME = "Respawn For Mithrix";
public const string VERSION = "1.1.1";
public static ConfigEntry<bool> EnableMithrixRespawn { get; set; }
public static ConfigEntry<bool> EnableFalseSonRespawn { get; set; }
public static PluginInfo pluginInfo { get; private set; }
public static Respawn_For_MithrixMain instance { get; private set; }
internal static AssetBundle assetBundle { get; private set; }
internal static string assetBundleDir => Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "Respawn_For_MithrixAssets");
private void Awake()
{
instance = this;
pluginInfo = ((BaseUnityPlugin)this).Info;
EnableMithrixRespawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Enable Respawn Procs", "Pre-Mithrix Respawn", true, "Enable team respawn on Mithrix arena entry");
EnableFalseSonRespawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Enable Respawn Procs", "Pre-False Son Respawn", true, "Enable team respawn on False Son arena entry");
new Respawn_For_MithrixContent(((BaseUnityPlugin)this).Logger, EnableMithrixRespawn.Value, EnableFalseSonRespawn.Value);
}
internal static void LogFatal(object data)
{
((BaseUnityPlugin)instance).Logger.LogFatal(data);
}
internal static void LogError(object data)
{
((BaseUnityPlugin)instance).Logger.LogError(data);
}
internal static void LogWarning(object data)
{
((BaseUnityPlugin)instance).Logger.LogWarning(data);
}
internal static void LogMessage(object data)
{
((BaseUnityPlugin)instance).Logger.LogMessage(data);
}
internal static void LogInfo(object data)
{
((BaseUnityPlugin)instance).Logger.LogInfo(data);
}
internal static void LogDebug(object data)
{
((BaseUnityPlugin)instance).Logger.LogDebug(data);
}
}