using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
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: AssemblyTitle("BerserkerEnemies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BerserkerEnemies")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ebbf84f-d225-4b22-b9af-ebd8768167b2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class ModPatch
{
public static bool enableBerserker = true;
public static int startingLevel = 9;
public static int berserkerHealth = 1000;
public static bool berserkerUnkillable = false;
public static float maxBerserkerValuable = 30000f;
public static bool canBeStunned = true;
public static bool enableAnimal = true;
public static bool enableApexPredator = true;
public static bool enableBowtie = true;
public static bool enableChef = true;
public static bool enableClown = true;
public static bool enableHeadman = true;
public static bool enableHidden = true;
public static bool enableHuntsman = true;
public static bool enableMentalist = true;
public static bool enableReaper = true;
public static bool enableRobe = true;
public static bool enableRugrat = true;
public static bool enableShadowChild = true;
public static bool enableSpewer = true;
public static bool enableTrudge = true;
public static bool enableUpscream = true;
public static bool containModded = true;
public static bool enableGusher = true;
public static bool enableRoaster = true;
public static bool enableDroid = true;
public static bool enableDestroyer = true;
public static bool enableFreddyFazbear = true;
public static float berserkerMaxSpawnChance = 10f;
private static bool hasSpawnedBerserker = false;
private static BerserkerManager berserkerScript;
public static EnemyParent _berserkerChosen;
public static bool showDebugLogs = false;
public static bool _masterUnkillable = false;
public static float _orbValue = 30000f;
public static bool _masterCanBeStunned = true;
private static GameObject _berserkerOrbPrefab;
[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
[HarmonyPostfix]
public static void GenerateDonePostfix(LevelGenerator __instance)
{
if (!SemiFunc.RunIsLevel())
{
return;
}
hasSpawnedBerserker = false;
_berserkerChosen = null;
berserkerScript = ((Component)LevelGenerator.Instance).gameObject.AddComponent<BerserkerManager>();
PhotonView component = ((Component)LevelGenerator.Instance).GetComponent<PhotonView>();
if (!enableBerserker || RunManager.instance.levelsCompleted + 1 < startingLevel || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
List<string> enemyTypes = GetEnemyTypes();
int num = 0;
List<EnemyParent> enemiesSpawned = EnemyDirector.instance.enemiesSpawned;
for (int i = 0; i < enemiesSpawned.Count; i++)
{
if (!hasSpawnedBerserker)
{
float num2 = Random.Range(0, 100);
if (showDebugLogs)
{
DebugRepo($"Enemy {enemiesSpawned[i].enemyName}, chance {num2}, berserker? {num2 <= berserkerMaxSpawnChance && enemyTypes.Contains(enemiesSpawned[i].enemyName)}, is is list? {enemyTypes.Contains(enemiesSpawned[i].enemyName)}");
}
if (num2 <= berserkerMaxSpawnChance && enemyTypes.Contains(enemiesSpawned[i].enemyName))
{
DebugRepo("Berserker Chosen!");
hasSpawnedBerserker = true;
_berserkerChosen = enemiesSpawned[i];
((Component)_berserkerChosen).GetComponent<BerserkerController>().isBerserkerFlag = true;
num = i;
berserkerScript.berserkerChosen = _berserkerChosen;
break;
}
}
}
if ((Object)(object)_berserkerChosen != (Object)null)
{
GameObject enemyValuableBig = AssetManager.instance.enemyValuableBig;
_berserkerOrbPrefab = Object.Instantiate<GameObject>(enemyValuableBig);
((Object)_berserkerOrbPrefab).name = "Berserker Orb";
_berserkerOrbPrefab.SetActive(false);
if (SemiFunc.IsMultiplayer())
{
if ((Object)(object)component != (Object)null)
{
component.RPC("SetChosenBerserker", (RpcTarget)1, new object[1] { num });
component.RPC("StartBerserker", (RpcTarget)0, new object[1] { berserkerHealth });
component.RPC("GetCanBeStunnedFromMaster", (RpcTarget)1, new object[1] { canBeStunned });
component.RPC("GetUnkillableVariableFromMaster", (RpcTarget)1, new object[1] { berserkerUnkillable });
component.RPC("GetOrbValuableFromMaster", (RpcTarget)1, new object[1] { maxBerserkerValuable });
if (showDebugLogs)
{
DebugRepo($"Berserker chosen: {enemiesSpawned[num].enemyName}, health: {berserkerHealth}, unkillable: {_masterUnkillable}, value: {_orbValue}, can be stunned: {_masterCanBeStunned}");
}
}
}
else
{
berserkerScript.StartBerserker(berserkerHealth);
}
}
else
{
DebugRepo("Berserker not spawned!");
}
}
[HarmonyPatch(typeof(HurtCollider), "EnemyHurtRigidbody")]
[HarmonyPrefix]
public static bool EnemyHurtRigidbody(HurtCollider __instance, ref EnemyRigidbody _enemyRigidbody, PhysGrabObject _physGrabObject)
{
if ((Object)(object)_enemyRigidbody != (Object)null && enableBerserker)
{
bool masterUnkillable = berserkerUnkillable;
if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
{
masterUnkillable = _masterUnkillable;
}
BerserkerController componentInMainParent = ModPatch.GetComponentInMainParent<BerserkerController>(((Component)_enemyRigidbody).transform);
if ((Object)(object)componentInMainParent != (Object)null)
{
if (componentInMainParent.isBerserkerFlag && masterUnkillable)
{
return false;
}
return true;
}
}
return true;
}
[HarmonyPatch(typeof(HurtCollider), "EnemyHurt")]
[HarmonyPrefix]
public static bool EnemyHurt(ref bool __result, HurtCollider __instance, ref Enemy _enemy)
{
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Expected O, but got Unknown
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Expected O, but got Unknown
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Expected O, but got Unknown
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0404: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_enemy != (Object)null && enableBerserker)
{
EnemyParent componentInParent = ((Component)_enemy).GetComponentInParent<EnemyParent>();
BerserkerController component = ((Component)componentInParent).GetComponent<BerserkerController>();
if ((Object)(object)component != (Object)null && component.isBerserkerFlag)
{
bool masterCanBeStunned = canBeStunned;
EnemyHealth component2 = ((Component)_enemy).GetComponent<EnemyHealth>();
FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
if ((Object)(object)component2 == (Object)null)
{
DebugRepo("EnemyHealth not found!");
}
FieldInfo fieldInfo2 = AccessTools.Field(typeof(Enemy), "HasHealth");
if ((Object)(object)_enemy == (Object)(object)__instance.enemyHost)
{
__result = false;
return false;
}
if (!__instance.enemyLogic)
{
__result = false;
return false;
}
bool flag = false;
if (__instance.enemyKill)
{
FieldInfo fieldInfo3 = AccessTools.Field(typeof(Enemy), "HasStateDespawn");
if ((bool)fieldInfo2.GetValue(_enemy))
{
component2.Hurt((int)fieldInfo.GetValue(component2), ((Component)__instance).transform.forward);
}
else if ((bool)fieldInfo3.GetValue(_enemy))
{
((Component)_enemy).GetComponentInParent<EnemyParent>().SpawnedTimerSet(0f);
_enemy.CurrentState = (EnemyState)11;
flag = true;
}
}
if (!flag)
{
if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
{
masterCanBeStunned = _masterCanBeStunned;
}
if (masterCanBeStunned)
{
FieldInfo fieldInfo4 = AccessTools.Field(typeof(Enemy), "HasStateStunned");
FieldInfo fieldInfo5 = AccessTools.Field(typeof(Enemy), "StateStunned");
if (__instance.enemyStun && (bool)fieldInfo4.GetValue(_enemy) && _enemy.Type <= __instance.enemyStunType)
{
EnemyStateStunned val = (EnemyStateStunned)fieldInfo5.GetValue(_enemy);
val.Set(__instance.enemyStunTime);
}
}
else if (showDebugLogs)
{
DebugRepo("Berserker cannot be stunned!");
}
if (__instance.enemyFreezeTime > 0f)
{
_enemy.Freeze(__instance.enemyFreezeTime);
}
FieldInfo fieldInfo6 = AccessTools.Field(typeof(Enemy), "HasRigidbody");
FieldInfo fieldInfo7 = AccessTools.Field(typeof(Enemy), "Rigidbody");
FieldInfo fieldInfo8 = AccessTools.Field(typeof(EnemyRigidbody), "physGrabObject");
if ((bool)fieldInfo6.GetValue(_enemy))
{
MethodInfo method = typeof(HurtCollider).GetMethod("PhysObjectHurt", BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null)
{
method.Invoke(__instance, new object[6]
{
(object)(PhysGrabObject)fieldInfo8.GetValue((object?)(EnemyRigidbody)fieldInfo7.GetValue(_enemy)),
__instance.enemyImpact,
__instance.enemyHitForce,
__instance.enemyHitTorque,
true,
false
});
}
if (__instance.enemyFreezeTime > 0f)
{
FieldInfo fieldInfo9 = AccessTools.Field(typeof(HurtCollider), "applyForce");
FieldInfo fieldInfo10 = AccessTools.Field(typeof(HurtCollider), "applyTorque");
EnemyRigidbody val2 = (EnemyRigidbody)fieldInfo7.GetValue(_enemy);
val2.FreezeForces((Vector3)fieldInfo9.GetValue(__instance), (Vector3)fieldInfo10.GetValue(__instance));
}
}
if (__instance.enemyDamage > 0 && (bool)fieldInfo2.GetValue(_enemy))
{
FieldInfo fieldInfo11 = AccessTools.Field(typeof(HurtCollider), "applyForce");
Vector3 val3 = (Vector3)fieldInfo11.GetValue(__instance);
component2.Hurt(__instance.enemyDamage, ((Vector3)(ref val3)).normalized);
}
}
if (showDebugLogs)
{
DebugRepo($"Berserker current health: {(int)fieldInfo.GetValue(component2)}");
}
__result = true;
return false;
}
if ((Object)(object)component != (Object)null && !component.isBerserkerFlag && showDebugLogs)
{
DebugRepo("Enemy is not Berserker!");
}
}
else
{
DebugRepo("Enemy is null!");
}
return true;
}
[HarmonyPatch(typeof(EnemyParent), "Despawn")]
[HarmonyPostfix]
private static void SpawnRPCPostfix(EnemyParent __instance)
{
DebugRepo(__instance.enemyName + " spawned!");
if ((Object)(object)((Component)__instance).gameObject.GetComponent<BerserkerController>() != (Object)null)
{
if (showDebugLogs)
{
DebugRepo("Enemy " + __instance.enemyName + " already had BerserkerController!");
}
return;
}
((Component)__instance).gameObject.AddComponent<BerserkerController>();
if (showDebugLogs)
{
DebugRepo("BerserkerController added to enemy " + __instance.enemyName + "!");
}
}
[HarmonyPatch(typeof(EnemyParent), "Despawn")]
[HarmonyPrefix]
public static bool DespawnPrefix(EnemyParent __instance)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
//IL_0321: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
if (enableBerserker)
{
BerserkerController component = ((Component)__instance).GetComponent<BerserkerController>();
if ((Object)(object)component != (Object)null)
{
if (component.isBerserkerFlag)
{
if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
{
return false;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyParent), "Enemy");
Enemy val = (Enemy)fieldInfo.GetValue(__instance);
if ((Object)(object)val != (Object)null)
{
FieldInfo fieldInfo2 = AccessTools.Field(typeof(EnemyDirector), "despawnedTimeMultiplier");
val.CurrentState = (EnemyState)11;
__instance.DespawnedTimer = Random.Range(__instance.DespawnedTimeMin, __instance.DespawnedTimeMax) * (float)fieldInfo2.GetValue(EnemyDirector.instance);
__instance.DespawnedTimer = Mathf.Max(__instance.DespawnedTimer, 1f);
FieldInfo fieldInfo3 = AccessTools.Field(typeof(Enemy), "HasRigidbody");
if ((bool)fieldInfo3.GetValue(val))
{
FieldInfo fieldInfo4 = AccessTools.Field(typeof(Enemy), "Rigidbody");
EnemyRigidbody val2 = (EnemyRigidbody)fieldInfo4.GetValue(val);
FieldInfo fieldInfo5 = AccessTools.Field(typeof(EnemyRigidbody), "grabbed");
FieldInfo fieldInfo6 = AccessTools.Field(typeof(EnemyRigidbody), "grabStrengthTimer");
fieldInfo5.SetValue(val2, false);
fieldInfo6.SetValue(val2, 0f);
val2.GrabRelease();
}
if (GameManager.Multiplayer())
{
((Component)__instance).GetComponent<PhotonView>().RPC("DespawnRPC", (RpcTarget)0, Array.Empty<object>());
}
else
{
MethodInfo method = typeof(EnemyParent).GetMethod("DespawnRPC", BindingFlags.Instance | BindingFlags.NonPublic);
if (method != null)
{
method.Invoke(__instance, new object[0]);
}
}
FieldInfo fieldInfo7 = AccessTools.Field(typeof(Enemy), "HasHealth");
EnemyHealth component2 = ((Component)val).GetComponent<EnemyHealth>();
FieldInfo fieldInfo8 = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
if (!(bool)fieldInfo7.GetValue(val) || (int)fieldInfo8.GetValue(component2) > 0)
{
return false;
}
GameObject berserkerOrbPrefab = _berserkerOrbPrefab;
Value val3 = ScriptableObject.CreateInstance<Value>();
((Object)val3).name = "Value Berserker";
float orbValue = maxBerserkerValuable;
if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
{
orbValue = _orbValue;
}
val3.valueMax = orbValue;
val3.valueMin = orbValue - 10000f;
berserkerOrbPrefab.GetComponent<ValuableObject>().valuePreset = val3;
Transform val4 = val.CustomValuableSpawnTransform;
if (!Object.op_Implicit((Object)(object)val4))
{
val4 = val.CenterTransform;
}
berserkerOrbPrefab = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)berserkerOrbPrefab).name, val4.position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(berserkerOrbPrefab, val4.position, Quaternion.identity));
int rootIndex = GetRootIndex(berserkerOrbPrefab);
if (!SemiFunc.IsMultiplayer())
{
berserkerScript.ChangeValuableVisual(rootIndex);
}
else
{
((Component)berserkerScript).GetComponent<PhotonView>().RPC("ChangeValuableVisual", (RpcTarget)0, new object[1] { rootIndex });
}
__instance.DespawnedTimer *= 3f;
return false;
}
DebugRepo("CurrentEnemy is null! Dropping default valuable!");
return true;
}
if (showDebugLogs)
{
DebugRepo("Enemy " + __instance.enemyName + " is not Berserker!");
}
return true;
}
DebugRepo("BerserkerController not found in enemy!");
}
if (showDebugLogs)
{
DebugRepo("BerserkerEnemies not enabled!");
}
return true;
}
public static int GetRootIndex(GameObject obj)
{
//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)
Scene activeScene = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
for (int i = 0; i < rootGameObjects.Length; i++)
{
if ((Object)(object)rootGameObjects[i] == (Object)(object)obj)
{
return i;
}
}
return -1;
}
public static T GetComponentInChildrenRecursive<T>(Transform obj) where T : Component
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in obj)
{
Transform val = item;
T component = ((Component)val).GetComponent<T>();
if ((Object)(object)component != (Object)null)
{
return component;
}
component = GetComponentInChildrenRecursive<T>(val);
if ((Object)(object)component != (Object)null)
{
return component;
}
}
return default(T);
}
public static T GetComponentInMainParent<T>(Transform obj) where T : Component
{
Transform parent = obj.parent;
T result = default(T);
while ((Object)(object)parent != (Object)null)
{
T component = ((Component)parent).GetComponent<T>();
if ((Object)(object)component != (Object)null)
{
result = component;
}
parent = parent.parent;
}
return result;
}
public static List<string> GetEnemyTypes()
{
List<string> list = new List<string>();
if (enableAnimal)
{
list.Add("Animal");
}
if (enableApexPredator)
{
list.Add("Apex Predator");
}
if (enableBowtie)
{
list.Add("Bowtie");
}
if (enableChef)
{
list.Add("Chef");
}
if (enableClown)
{
list.Add("Clown");
}
if (enableHeadman)
{
list.Add("Headman");
}
if (enableHuntsman)
{
list.Add("Huntsman");
}
if (enableMentalist)
{
list.Add("Mentalist");
}
if (enableReaper)
{
list.Add("Reaper");
}
if (enableRobe)
{
list.Add("Robe");
}
if (enableRugrat)
{
list.Add("Rugrat");
}
if (enableShadowChild)
{
list.Add("Shadow Child");
}
if (enableSpewer)
{
list.Add("Spewer");
}
if (enableTrudge)
{
list.Add("Trudge");
}
if (enableUpscream)
{
list.Add("Upscream");
}
if (containModded)
{
if (enableGusher)
{
list.Add("Gusher");
}
if (enableRoaster)
{
list.Add("Roaster");
}
if (enableDroid)
{
list.Add("Lost droid");
}
if (enableDestroyer)
{
list.Add("Lost Destroyer");
}
if (enableFreddyFazbear)
{
list.Add("Freddy Fazbear");
}
}
return list;
}
public static Texture2D LoadEmbeddedTexture(string resourceName)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using (Stream stream = executingAssembly.GetManifestResourceStream(resourceName))
{
if (stream == null)
{
DebugRepo("Resource " + resourceName + " not found!");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
if (ImageConversion.LoadImage(val, array))
{
((Texture)val).filterMode = (FilterMode)2;
((Texture)val).wrapMode = (TextureWrapMode)1;
return val;
}
}
return null;
}
public static void DebugRepo(string message)
{
Debug.Log((object)("[Berserker Enemies] " + message));
}
}
internal class BerserkerManager : MonoBehaviourPun
{
public static BerserkerManager instance;
public EnemyParent berserkerChosen;
private static Transform berserkerChosenTransform;
private static Enemy _berserkerEnemyScript;
private static EnemyHealth _berserkerEnemyHealthScript;
private static ParticleSystem berserkerParticlesObjPS;
public Enemy berserkerEnemyScript => _berserkerEnemyScript;
public EnemyHealth berserkerEnemyHealthScript => _berserkerEnemyHealthScript;
private void Awake()
{
instance = this;
}
private void Update()
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Invalid comparison between Unknown and I4
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Invalid comparison between Unknown and I4
if (!Object.op_Implicit((Object)(object)_berserkerEnemyScript))
{
return;
}
if (ModPatch.GetComponentInMainParent<EnemyParent>(((Component)_berserkerEnemyScript).transform).enemyName == "Freddy Fazbear" && ((Component)((Component)_berserkerEnemyScript).transform.parent).gameObject.activeInHierarchy)
{
GameObject gameObject = ((Component)((Component)_berserkerEnemyScript).transform.parent.GetChild(2).GetChild(3).GetChild(0)
.GetChild(3)).gameObject;
if ((Object)(object)berserkerParticlesObjPS != (Object)null && gameObject.transform.localPosition.z > 0f)
{
if (berserkerParticlesObjPS.isPlaying)
{
berserkerParticlesObjPS.Stop();
}
}
else if (berserkerParticlesObjPS.isStopped)
{
berserkerParticlesObjPS.Play();
}
}
if (!(ModPatch.GetComponentInMainParent<EnemyParent>(((Component)_berserkerEnemyScript).transform).enemyName == "Spewer") || !((Component)((Component)_berserkerEnemyScript).transform.parent).gameObject.activeInHierarchy)
{
return;
}
EnemySlowMouth component = ((Component)_berserkerEnemyScript).GetComponent<EnemySlowMouth>();
if ((Object)(object)berserkerParticlesObjPS != (Object)null && ((int)component.currentState == 9 || (int)component.currentState == 10))
{
if (berserkerParticlesObjPS.isPlaying)
{
berserkerParticlesObjPS.Stop();
}
}
else if (berserkerParticlesObjPS.isStopped)
{
berserkerParticlesObjPS.Play();
}
}
[PunRPC]
public void GetCanBeStunnedFromMaster(bool _canBeStunned)
{
ModPatch._masterCanBeStunned = _canBeStunned;
}
[PunRPC]
public void GetUnkillableVariableFromMaster(bool _umasterUnkillable)
{
ModPatch._masterUnkillable = _umasterUnkillable;
}
[PunRPC]
public void GetOrbValuableFromMaster(float _value)
{
ModPatch._orbValue = _value;
}
[PunRPC]
public void SetChosenBerserker(int _index)
{
List<EnemyParent> enemiesSpawned = EnemyDirector.instance.enemiesSpawned;
berserkerChosen = enemiesSpawned[_index];
ModPatch._berserkerChosen = berserkerChosen;
}
[PunRPC]
public void StartBerserker(int berserkerHealth)
{
if ((Object)(object)berserkerChosen != (Object)null)
{
berserkerChosenTransform = ((Component)berserkerChosen).transform;
ModPatch.DebugRepo("Setting Berserker properties...");
GetBerserkerScripts(berserkerChosenTransform);
SetBerserkerValues(berserkerChosenTransform, berserkerHealth);
SetBerserkerGrabForce(berserkerChosenTransform);
if (((Component)berserkerChosenTransform).GetComponent<EnemyParent>().enemyName != "Hidden")
{
SetBerserkerGlow(berserkerChosenTransform);
SetBerserkerSmoke(berserkerChosenTransform);
}
else if (((Component)berserkerChosenTransform).GetComponent<EnemyParent>().enemyName == "Hidden")
{
SetUpHidden(berserkerChosenTransform);
}
ModPatch.DebugRepo("Berserker configured. Good luck!");
}
else
{
ModPatch.DebugRepo("Berserker Chosen is null!");
}
}
private static void SetBerserkerValues(Transform enemy, int _masterHealth)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
int num = ModPatch.berserkerHealth;
if (SemiFunc.IsMultiplayer() && SemiFunc.IsNotMasterClient())
{
num = _masterHealth;
}
foreach (Transform item in enemy)
{
Transform val = item;
if (((Object)val).name == "Controller")
{
EnemyHealth component = ((Component)val).GetComponent<EnemyHealth>();
if ((Object)(object)component != (Object)null)
{
FieldInfo fieldInfo = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
fieldInfo.SetValue(component, num);
component.health = num;
component.impactHurt = false;
component.objectHurt = false;
component.objectHurtStun = false;
}
}
SetBerserkerValues(val, _masterHealth);
}
}
private static void SetBerserkerGlow(Transform enemy)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
foreach (Transform item in enemy)
{
Transform val = item;
Renderer component = ((Component)val).GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
Material material = component.material;
if ((Object)(object)material != (Object)null && (((Object)material.shader).name == "Hurtable/Hurtable" || ((Object)material.shader).name == "Hurtable/Hurtable Alpha Clip" || ((Object)material.shader).name == "Patcher/Hurtable/Hurtable" || ((Object)material.shader).name == "Patcher/Hurtable/Hurtable Alpha Clip" || ((Object)material.shader).name == "Ortong/Hurtable" || ((Object)material.shader).name == "Orton/Hurtable/Hurtable Freddy"))
{
material.SetFloat("_FresnelAmount", 1f);
material.SetFloat("_FresnelScale", 1f);
material.SetFloat("_FresnelPower", 5f);
material.SetFloat("_FresnelBias", 0f);
material.SetColor("_FresnelColor", Color.red);
material.SetFloat("_FresnelEmission", 1f);
}
}
SetBerserkerGlow(val);
}
}
private static void SetBerserkerGrabForce(Transform enemy)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
GrabForce val = ScriptableObject.CreateInstance<GrabForce>();
val.amount = 1E+10f;
((Object)val).name = "Grab Force - Berserker";
foreach (Transform item in enemy)
{
Transform berserkerGrabForce = item;
EnemyRigidbody component = ((Component)enemy).gameObject.GetComponent<EnemyRigidbody>();
if ((Object)(object)component != (Object)null && (Object)(object)component.grabForceNeeded != (Object)(object)val)
{
component.grabForceNeeded = val;
}
SetBerserkerGrabForce(berserkerGrabForce);
}
}
private static Transform GetBerserkerParticleParent(Transform enemy)
{
Transform result = null;
Animator componentInChildrenRecursive = ModPatch.GetComponentInChildrenRecursive<Animator>(enemy);
if ((Object)(object)componentInChildrenRecursive != (Object)null)
{
result = ((Component)componentInChildrenRecursive).transform;
}
return result;
}
private static void SetBerserkerSmoke(Transform enemy)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Expected O, but got Unknown
//IL_0403: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
Transform berserkerParticleParent = GetBerserkerParticleParent(enemy);
GameObject val = new GameObject();
((Object)val).name = "Berserker Particle System";
berserkerParticlesObjPS = val.AddComponent<ParticleSystem>();
((Object)berserkerParticlesObjPS).name = "ParticleSystem - Berserker";
if ((Object)(object)berserkerParticleParent != (Object)null)
{
val.transform.SetParent(berserkerParticleParent, false);
}
Vector3 val2 = Vector3.zero;
if (((Component)enemy).GetComponent<EnemyParent>().enemyName == "Robe" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Reaper" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Clown" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Hunter" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Lost droid" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Lost Destroyer")
{
val2 += new Vector3(0f, 1f, 0f);
}
else if (((Component)enemy).GetComponent<EnemyParent>().enemyName == "Trudge" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Gusher" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Roaster" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Freddy Fazbear" || ((Component)enemy).GetComponent<EnemyParent>().enemyName == "Shadow Child")
{
val2 += new Vector3(0f, 1.5f, 0f);
}
val.transform.localPosition = val2;
val.transform.localRotation = Quaternion.identity;
MainModule main = berserkerParticlesObjPS.main;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(2f);
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1f);
ColorOverLifetimeModule colorOverLifetime = berserkerParticlesObjPS.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val3 = new Gradient();
val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(Color.white, 0f),
new GradientColorKey(Color.white, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
{
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(1f, 0.1f),
new GradientAlphaKey(1f, 0.5f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
RotationOverLifetimeModule rotationOverLifetime = berserkerParticlesObjPS.rotationOverLifetime;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
ShapeModule shape = berserkerParticlesObjPS.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.5f;
Material val4 = new Material(Shader.Find("Particles/Standard Unlit"));
Texture2D val5 = ModPatch.LoadEmbeddedTexture("BerserkerEnemies.Resources.Particle.png");
val4.SetFloat("_Mode", 2f);
val4.SetOverrideTag("RenderType", "Transparent");
val4.EnableKeyword("_ALPHABLEND_ON");
val4.DisableKeyword("_ALPHATEST_ON");
val4.DisableKeyword("_ALPHAPREMULTIPLY_ON");
val4.SetFloat("_ColorMode", 3f);
val4.EnableKeyword("VERTEXSTREAMCOLOR");
val4.SetInt("_SrcBlend", 5);
val4.SetInt("_DstBlend", 10);
val4.SetInt("_ZWrite", 0);
val4.renderQueue = 3000;
ParticleSystemRenderer component = ((Component)berserkerParticlesObjPS).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component != (Object)null)
{
((Renderer)component).material = val4;
val4.SetColor("_Color", new Color(1f, 0f, 0f, 0.1f));
val4.SetTexture("_MainTex", (Texture)(object)val5);
}
}
private static void GetBerserkerScripts(Transform enemy)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
foreach (Transform item in enemy)
{
Transform val = item;
if ((Object)(object)_berserkerEnemyHealthScript != (Object)null && (Object)(object)_berserkerEnemyScript != (Object)null)
{
break;
}
if (((Object)val).name == "Controller")
{
_berserkerEnemyHealthScript = ((Component)val).GetComponent<EnemyHealth>();
if ((Object)(object)_berserkerEnemyHealthScript == (Object)null)
{
ModPatch.DebugRepo("Berserker EnemyHealth script is null!");
}
_berserkerEnemyScript = ((Component)val).GetComponentInChildren<Enemy>();
if ((Object)(object)_berserkerEnemyScript == (Object)null)
{
ModPatch.DebugRepo("Berserker Enemy script is null!");
}
}
GetBerserkerScripts(val);
}
}
[PunRPC]
public void ChangeValuableVisual(int orbIndex)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00b0: 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_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
if (ModPatch.showDebugLogs)
{
ModPatch.DebugRepo("Changing orb visual...");
}
GameObject rootObjectByIndex = GetRootObjectByIndex(orbIndex);
if (!rootObjectByIndex.activeInHierarchy)
{
rootObjectByIndex.SetActive(true);
}
if ((Object)(object)rootObjectByIndex == (Object)null)
{
ModPatch.DebugRepo("Orb null");
return;
}
Material val = new Material(Shader.Find("Particles/Standard Unlit"));
Material val2 = new Material(Shader.Find("Particles/Standard Unlit"));
Material val3 = new Material(Shader.Find("Enemy Valuable Shader"));
Material val4 = new Material(Shader.Find("Particles/Standard Unlit"));
val3.SetColor("_BaseColor", new Color(1f, 0f, 0f, 0.6f));
val3.SetColor("_EmissionColor", new Color(0.3f, 0f, 0f, 0f));
val3.SetFloat("_Smoothness", 0.8f);
val3.SetFloat("_FresnelBias", 0f);
val3.SetFloat("_FresnelEmission", 1f);
val3.SetFloat("_FresnelScale", 5f);
val3.SetFloat("_FresnelPower", 4f);
val3.SetColor("_FresnelColor", Color.red);
((Component)rootObjectByIndex.transform.GetChild(1).GetChild(0)).GetComponent<Renderer>().material = val3;
Texture2D val5 = ModPatch.LoadEmbeddedTexture("BerserkerEnemies.Resources.InnerTex.png");
val4.SetTexture("_MainTex", (Texture)(object)val5);
val4.SetColor("_Color", new Color(0.4f, 0f, 0f));
((Component)rootObjectByIndex.transform.GetChild(1).GetChild(1)).GetComponent<Renderer>().material = val4;
val.SetColor("_Color", Color.red);
((Component)rootObjectByIndex.transform.GetChild(1).GetChild(2)).GetComponent<Renderer>().material = val;
val2.SetColor("_Color", new Color(0.8f, 0f, 0f));
((Component)rootObjectByIndex.transform.GetChild(1).GetChild(3)).GetComponent<Renderer>().material = val2;
((Component)rootObjectByIndex.transform.GetChild(1).GetChild(4)).GetComponent<Light>().color = Color.red;
}
private static void SetUpHidden(Transform enemy)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Expected O, but got Unknown
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = ModPatch.LoadEmbeddedTexture("BerserkerEnemies.Resources.Particle.png");
Material val2 = new Material(Shader.Find("Particles/Standard Unlit"));
val2.SetFloat("_Mode", 2f);
val2.SetOverrideTag("RenderType", "Transparent");
val2.EnableKeyword("_ALPHABLEND_ON");
val2.DisableKeyword("_ALPHATEST_ON");
val2.DisableKeyword("_ALPHAPREMULTIPLY_ON");
val2.SetFloat("_ColorMode", 3f);
val2.EnableKeyword("VERTEXSTREAMCOLOR");
val2.SetInt("_SrcBlend", 5);
val2.SetInt("_DstBlend", 10);
val2.SetInt("_ZWrite", 0);
val2.renderQueue = 3000;
ModPatch.DebugRepo("Breath " + ((Object)((Component)enemy.GetChild(0).GetChild(0)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component = ((Component)enemy.GetChild(0).GetChild(0)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component != (Object)null)
{
((Renderer)component).material = val2;
val2.SetTexture("_MainTex", (Texture)(object)val);
val2.SetColor("_Color", new Color(1f, 0f, 0f));
}
ModPatch.DebugRepo("Breath Fast " + ((Object)((Component)enemy.GetChild(0).GetChild(1)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component2 = ((Component)enemy.GetChild(0).GetChild(1)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component2 != (Object)null)
{
((Renderer)component2).material = val2;
val2.SetTexture("_MainTex", (Texture)(object)val);
val2.SetColor("_Color", new Color(1f, 0f, 0f));
}
ModPatch.DebugRepo("Breath Constant " + ((Object)((Component)enemy.GetChild(0).GetChild(2)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component3 = ((Component)enemy.GetChild(0).GetChild(2)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component3 != (Object)null)
{
((Renderer)component3).material = val2;
val2.SetTexture("_MainTex", (Texture)(object)val);
val2.SetColor("_Color", new Color(1f, 0f, 0f));
}
ModPatch.DebugRepo("Foot Smoke " + ((Object)((Component)enemy.GetChild(0).GetChild(5)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component4 = ((Component)enemy.GetChild(0).GetChild(5)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component4 != (Object)null)
{
((Renderer)component4).material = val2;
val2.SetTexture("_MainTex", (Texture)(object)val);
val2.SetColor("_Color", new Color(1f, 0f, 0f));
}
Texture2D val3 = ModPatch.LoadEmbeddedTexture("BerserkerEnemies.Resources.HiddenFoot.png");
Material val4 = new Material(Shader.Find("Particles/Standard Unlit"));
val4.SetFloat("_Mode", 2f);
val4.SetOverrideTag("RenderType", "Transparent");
val4.EnableKeyword("_ALPHABLEND_ON");
val4.DisableKeyword("_ALPHATEST_ON");
val4.DisableKeyword("_ALPHAPREMULTIPLY_ON");
val4.EnableKeyword("_EMISSION");
val4.SetColor("_EmissionColor", new Color(255f, 0f, 0f));
val4.SetFloat("_ColorMode", 3f);
val4.EnableKeyword("VERTEXSTREAMCOLOR");
val4.SetInt("_SrcBlend", 5);
val4.SetInt("_DstBlend", 10);
val4.SetInt("_ZWrite", 0);
val4.SetInt("_Cull", 0);
val4.renderQueue = 3000;
ModPatch.DebugRepo("Foot Shape Right " + ((Object)((Component)enemy.GetChild(0).GetChild(3)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component5 = ((Component)enemy.GetChild(0).GetChild(3)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component5 != (Object)null)
{
((Renderer)component5).material = val4;
val4.SetTexture("_MainTex", (Texture)(object)val);
val4.SetColor("_Color", new Color(1f, 0f, 0f));
}
ModPatch.DebugRepo("Foot Shape Left " + ((Object)((Component)enemy.GetChild(0).GetChild(4)).GetComponent<Renderer>().material.shader).name);
ParticleSystemRenderer component6 = ((Component)enemy.GetChild(0).GetChild(3)).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component6 != (Object)null)
{
((Renderer)component6).material = val4;
val4.SetTexture("_MainTex", (Texture)(object)val);
val4.SetColor("_Color", new Color(1f, 0f, 0f));
}
}
public static GameObject GetRootObjectByIndex(int index)
{
//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)
Scene activeScene = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects();
if (index >= 0 && index < rootGameObjects.Length)
{
return rootGameObjects[index];
}
return null;
}
}
public class BerserkerController : MonoBehaviourPun
{
public bool isBerserkerFlag = false;
}
namespace BerserkerEnemies;
[BepInPlugin("FNKTLabs.BerserkerEnemies", "Berserker Enemies", "1.2.0")]
public class ModBase : BaseUnityPlugin
{
private const string modGUID = "FNKTLabs.BerserkerEnemies";
public const string modName = "Berserker Enemies";
private const string modVersion = "1.2.0";
private Harmony _harmony = new Harmony("FNKTLabs.BerserkerEnemies");
internal ManualLogSource _logSource;
public static ConfigEntry<bool> config_EnableBerserker;
public static ConfigEntry<int> config_StartingLevel;
public static ConfigEntry<int> config_BerserkerHealth;
public static ConfigEntry<bool> config_BerserkerUnkillable;
public static ConfigEntry<float> config_MaxBerserkerValuable;
public static ConfigEntry<bool> config_CanBeStunned;
public static ConfigEntry<float> config_berserkerMaxSpawnChance;
public static ConfigEntry<bool> config_enableAnimal;
public static ConfigEntry<bool> config_enableApexPredator;
public static ConfigEntry<bool> config_enableChef;
public static ConfigEntry<bool> config_enableClown;
public static ConfigEntry<bool> config_enableBowtie;
public static ConfigEntry<bool> config_enableMentalist;
public static ConfigEntry<bool> config_enableHeadman;
public static ConfigEntry<bool> config_enableHuntsman;
public static ConfigEntry<bool> config_enableReaper;
public static ConfigEntry<bool> config_enableRobe;
public static ConfigEntry<bool> config_enableRugrat;
public static ConfigEntry<bool> config_enableShadowChild;
public static ConfigEntry<bool> config_enableSpewer;
public static ConfigEntry<bool> config_enableTrudge;
public static ConfigEntry<bool> config_enableUpscream;
public static ConfigEntry<bool> config_enableDestroyer;
public static ConfigEntry<bool> config_enableDroid;
public static ConfigEntry<bool> config_enableGusher;
public static ConfigEntry<bool> config_enableRoaster;
public static ConfigEntry<bool> config_enableFreddyFazbear;
public static ConfigEntry<bool> config_showDebugLogs;
public void Awake()
{
_logSource = Logger.CreateLogSource("FNKTLabs.BerserkerEnemies");
_logSource.LogInfo((object)"BerserkerEnemies loaded!");
ConfigFile();
_harmony.PatchAll(typeof(ModBase));
_harmony.PatchAll(typeof(ModPatch));
}
public void ConfigFile()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Expected O, but got Unknown
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
config_EnableBerserker = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Toggle Berserker enemy", (AcceptableValueBase)null, Array.Empty<object>()));
ModPatch.enableBerserker = config_EnableBerserker.Value;
config_showDebugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Debug", false, new ConfigDescription("Toggle debug log visibility", (AcceptableValueBase)null, Array.Empty<object>()));
ModPatch.showDebugLogs = config_showDebugLogs.Value;
config_StartingLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Berserker", "Starting Level", 9, new ConfigDescription("Min level for the Berserker to spawn", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
ModPatch.startingLevel = config_StartingLevel.Value;
config_BerserkerUnkillable = ((BaseUnityPlugin)this).Config.Bind<bool>("Berserker", "Unkillable", false, new ConfigDescription("Toggle whether the Berserker is unkillable", (AcceptableValueBase)null, Array.Empty<object>()));
ModPatch.berserkerUnkillable = config_BerserkerUnkillable.Value;
config_BerserkerHealth = ((BaseUnityPlugin)this).Config.Bind<int>("Berserker", "Health", 2000, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2000, 5000), Array.Empty<object>()));
ModPatch.berserkerHealth = config_BerserkerHealth.Value;
config_CanBeStunned = ((BaseUnityPlugin)this).Config.Bind<bool>("Berserker", "Can Be Stunned", true, new ConfigDescription("Toggle whether the Berserker can be stunned", (AcceptableValueBase)null, Array.Empty<object>()));
ModPatch.canBeStunned = config_CanBeStunned.Value;
config_MaxBerserkerValuable = ((BaseUnityPlugin)this).Config.Bind<float>("Berserker", "Max Orb Value", 40000f, new ConfigDescription("Max value for the orb dropped by Berserkers", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20000f, 60000f), Array.Empty<object>()));
ModPatch.maxBerserkerValuable = config_MaxBerserkerValuable.Value;
config_berserkerMaxSpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn Chance", "Percentage", 10f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
ModPatch.berserkerMaxSpawnChance = config_berserkerMaxSpawnChance.Value;
config_enableAnimal = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Animal", true, (ConfigDescription)null);
ModPatch.enableAnimal = config_enableAnimal.Value;
config_enableApexPredator = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Apex Predator", true, (ConfigDescription)null);
ModPatch.enableApexPredator = config_enableApexPredator.Value;
config_enableBowtie = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Bowtie", true, (ConfigDescription)null);
ModPatch.enableBowtie = config_enableBowtie.Value;
config_enableChef = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Chef", true, (ConfigDescription)null);
ModPatch.enableChef = config_enableChef.Value;
config_enableClown = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Clown", true, (ConfigDescription)null);
ModPatch.enableClown = config_enableClown.Value;
config_enableHeadman = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Headman", true, (ConfigDescription)null);
ModPatch.enableHeadman = config_enableHeadman.Value;
config_enableHuntsman = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Huntsman", true, (ConfigDescription)null);
ModPatch.enableHuntsman = config_enableHuntsman.Value;
config_enableMentalist = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Mentalist", true, (ConfigDescription)null);
ModPatch.enableMentalist = config_enableMentalist.Value;
config_enableReaper = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Reaper", true, (ConfigDescription)null);
ModPatch.enableReaper = config_enableReaper.Value;
config_enableRobe = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Robe", true, (ConfigDescription)null);
ModPatch.enableRobe = config_enableRobe.Value;
config_enableRugrat = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Rugrat", true, (ConfigDescription)null);
ModPatch.enableRugrat = config_enableRugrat.Value;
config_enableShadowChild = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Shadow Child", true, (ConfigDescription)null);
ModPatch.enableShadowChild = config_enableShadowChild.Value;
config_enableSpewer = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Spewer", true, (ConfigDescription)null);
ModPatch.enableSpewer = config_enableSpewer.Value;
config_enableTrudge = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Trudge", true, (ConfigDescription)null);
ModPatch.enableTrudge = config_enableTrudge.Value;
config_enableUpscream = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Upscream", true, (ConfigDescription)null);
ModPatch.enableUpscream = config_enableUpscream.Value;
List<string> list = ListPluginFiles();
if (list.Contains("WesleysEnemies.dll"))
{
ModPatch.containModded = true;
config_enableDestroyer = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Destroyer", true, (ConfigDescription)null);
ModPatch.enableDestroyer = config_enableDestroyer.Value;
config_enableDroid = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Droid", true, (ConfigDescription)null);
ModPatch.enableDroid = config_enableDroid.Value;
config_enableGusher = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Gusher", true, (ConfigDescription)null);
ModPatch.enableGusher = config_enableGusher.Value;
config_enableRoaster = ((BaseUnityPlugin)this).Config.Bind<bool>("Wesleys Enemies", "Roaster", true, (ConfigDescription)null);
ModPatch.enableRoaster = config_enableRoaster.Value;
}
if (list.Contains("FreddyEnemy.dll"))
{
ModPatch.containModded = true;
config_enableFreddyFazbear = ((BaseUnityPlugin)this).Config.Bind<bool>("Freddy Enemy", "Freddy Fazbear", true, (ConfigDescription)null);
ModPatch.enableFreddyFazbear = config_enableFreddyFazbear.Value;
}
}
public static List<string> ListPluginFiles()
{
if (config_showDebugLogs.Value)
{
ModPatch.DebugRepo("Checking for modded enemies...");
}
List<string> list = new List<string>();
string pluginPath = Paths.PluginPath;
if (!Directory.Exists(pluginPath))
{
ModPatch.DebugRepo("Folder " + pluginPath + " not found!");
return null;
}
string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories);
string[] array = files;
foreach (string path in array)
{
ModPatch.DebugRepo(("Mod found: " + Path.GetFileName(path)).Replace(".dll", ""));
list.Add(Path.GetFileName(path));
}
return list;
}
}