using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
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: AssemblyCompany("SplitOffByMitosis")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SplitOffByMitosis")]
[assembly: AssemblyTitle("SplitOffByMitosis")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace EnemyMitosis
{
[BepInPlugin("com.mod.enemymitosis", "Enemy Mitosis", "1.5.2")]
public class MitosisPlugin : BaseUnityPlugin
{
public static ManualLogSource ModLogger = null;
private static Harmony? harmony;
public static List<GameObject> activeClones = new List<GameObject>();
public static FloatField? intervalField;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
ModLogger = ((BaseUnityPlugin)this).Logger;
SetupConfigUI();
harmony = new Harmony("com.mod.enemymitosis");
harmony.PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
ModLogger.LogInfo((object)"Enemy Mitosis 1.5.2 loaded successfully!");
}
private void SetupConfigUI()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
PluginConfigurator val = PluginConfigurator.Create("Enemy Mitosis", "com.mod.enemymitosis");
intervalField = new FloatField(val.rootPanel, "Clone Interval (Seconds)", "CloneInterval", 10f, 1f, 60f);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
ClearAllClones();
}
public static void ClearAllClones()
{
foreach (GameObject activeClone in activeClones)
{
if ((Object)(object)activeClone != (Object)null)
{
Object.Destroy((Object)(object)activeClone);
}
}
activeClones.Clear();
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "Start")]
public class EnemyStartPatch
{
public static void Postfix(EnemyIdentifier __instance)
{
if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).gameObject != (Object)null && (Object)(object)((Component)__instance).GetComponent<MitosisTracker>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<MitosisTracker>();
}
}
}
[HarmonyPatch(typeof(NewMovement), "Respawn")]
public class PlayerRespawnPatch
{
public static void Postfix()
{
MitosisPlugin.ClearAllClones();
}
}
public class MitosisTracker : MonoBehaviour
{
private EnemyIdentifier? enemyId;
private float maxHealth = 100f;
private float timer = 0f;
private void Start()
{
enemyId = ((Component)this).GetComponent<EnemyIdentifier>();
if ((Object)(object)enemyId != (Object)null)
{
maxHealth = enemyId.health;
}
timer = 0f;
}
private void Update()
{
if (!((Object)(object)enemyId == (Object)null) && !enemyId.dead)
{
timer += Time.deltaTime;
float num = 10f;
if (MitosisPlugin.intervalField != null)
{
num = MitosisPlugin.intervalField.value;
}
if (timer >= num)
{
timer = 0f;
PerformMitosis();
}
}
}
private void PerformMitosis()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = FindSafeSpawnPosition();
GameObject val2 = Object.Instantiate<GameObject>(((Component)this).gameObject, val, ((Component)this).transform.rotation);
MitosisPlugin.activeClones.Add(val2);
EnemyIdentifier component = val2.GetComponent<EnemyIdentifier>();
if ((Object)(object)component != (Object)null)
{
component.health = maxHealth;
}
MitosisTracker component2 = val2.GetComponent<MitosisTracker>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
val2.AddComponent<MitosisTracker>();
}
private Vector3 FindSafeSpawnPosition()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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_00b9: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
float num = 3f;
Vector3[] array = (Vector3[])(object)new Vector3[4]
{
((Component)this).transform.right * num,
-((Component)this).transform.right * num,
((Component)this).transform.forward * num,
-((Component)this).transform.forward * num
};
Vector3[] array2 = array;
foreach (Vector3 val in array2)
{
Vector3 val2 = ((Component)this).transform.position + val;
if (!Physics.Linecast(((Component)this).transform.position, val2))
{
return val2;
}
}
return ((Component)this).transform.position + Vector3.up * 1.5f;
}
}
}