using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Coroner;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mimics;
[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("EliteMasterEric")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Provides integration between Coroner and Mimics.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Coroner - Mimics")]
[assembly: AssemblyTitle("Coroner - Mimics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CoronerMimics
{
public static class PluginInfo
{
public const string PLUGIN_ID = "coroner.mimics";
public const string PLUGIN_NAME = "Coroner - Mimics";
public const string PLUGIN_VERSION = "1.0.1";
public const string PLUGIN_GUID = "com.elitemastereric.coroner.mimics";
}
[BepInPlugin("com.elitemastereric.coroner.mimics", "Coroner - Mimics", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public ManualLogSource PluginLogger;
public AdvancedCauseOfDeath MIMIC;
public static Plugin Instance { get; private set; }
private void Awake()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
PluginLogger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.elitemastereric.coroner.mimics");
val.PatchAll();
PluginLogger.LogInfo((object)"Plugin Coroner - Mimics (com.elitemastereric.coroner.mimics) is loaded!");
MIMIC = AdvancedCauseOfDeath.Build("DeathEnemyMimic");
}
}
}
namespace CoronerMimics.Patch
{
[HarmonyPatch(typeof(MimicDoor))]
[HarmonyPatch("Attack")]
internal class MimicDoorAttackPatch
{
public static void Postfix(MimicDoor __instance, int playerId, ref IEnumerator __result)
{
try
{
Action prefixAction = delegate
{
Console.WriteLine("--> beginning");
};
Action postfixAction = delegate
{
HandleMimicKill(playerId);
};
Action<object> preItemAction = delegate(object item)
{
Console.WriteLine($"--> before {item}");
};
Action<object> postItemAction = delegate(object item)
{
Console.WriteLine($"--> after {item}");
};
Func<object, object> itemAction = delegate(object item)
{
string text = item?.ToString() + "+";
Console.WriteLine($"--> item {item} => {text}");
return text;
};
SimpleEnumerator simpleEnumerator = new SimpleEnumerator
{
enumerator = __result,
prefixAction = prefixAction,
postfixAction = postfixAction,
preItemAction = preItemAction,
postItemAction = postItemAction,
itemAction = itemAction
};
__result = simpleEnumerator.GetEnumerator();
}
catch (Exception ex)
{
Plugin.Instance.PluginLogger.LogError((object)("Error in MimicDoorAttackPatch.Postfix: " + ex));
Plugin.Instance.PluginLogger.LogError((object)ex.StackTrace);
}
}
private static void HandleMimicKill(int playerId)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Plugin.Instance.PluginLogger.LogDebug((object)"Player was killed by mimic! Processing...");
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerId];
Plugin.Instance.PluginLogger.LogDebug((object)$"Player {playerId} was killed by Mimic! Setting cause of death...");
API.SetCauseOfDeath(val, (AdvancedCauseOfDeath?)Plugin.Instance.MIMIC);
}
}
internal class SimpleEnumerator : IEnumerable
{
public IEnumerator enumerator;
public Action prefixAction;
public Action postfixAction;
public Action<object> preItemAction;
public Action<object> postItemAction;
public Func<object, object> itemAction;
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public IEnumerator GetEnumerator()
{
prefixAction();
while (enumerator.MoveNext())
{
object item = enumerator.Current;
preItemAction(item);
yield return itemAction(item);
postItemAction(item);
}
postfixAction();
}
}
}