using System;
using System.Collections;
using System.Collections.Generic;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MaskedEnemyRework.External_Classes;
using MaskedEnemyRework.Patches;
using Microsoft.CodeAnalysis;
using MoreCompany;
using MoreCompany.Cosmetics;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("MaskedEnemyRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("3.1.1.0")]
[assembly: AssemblyInformationalVersion("3.1.1")]
[assembly: AssemblyProduct("MaskedEnemyRework")]
[assembly: AssemblyTitle("MaskedEnemyRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.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 MaskedEnemyRework
{
[BepInPlugin("MaskedEnemyRework", "MaskedEnemyRework", "3.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("MaskedEnemyRework");
private static Plugin Instance;
internal ManualLogSource logger;
public static List<int> PlayerMimicList;
public static int PlayerMimicIndex;
private ConfigEntry<bool> RemoveMasksConfig;
private ConfigEntry<bool> RevealMasksConfig;
private ConfigEntry<bool> ShowMaskedNamesConfig;
private ConfigEntry<bool> RemoveZombieArmsConfig;
private ConfigEntry<bool> UseSpawnRarityConfig;
private ConfigEntry<int> SpawnRarityConfig;
private ConfigEntry<bool> CanSpawnOutsideConfig;
private ConfigEntry<int> MaxSpawnCountConfig;
private ConfigEntry<bool> ZombieApocalypeModeConfig;
private ConfigEntry<bool> UseVanillaSpawnsConfig;
private ConfigEntry<int> ZombieApocalypeRandomChanceConfig;
private ConfigEntry<int> MaxZombiesZombieConfig;
private ConfigEntry<float> InsideEnemySpawnCurveConfig;
private ConfigEntry<float> MiddayInsideEnemySpawnCurveConfig;
private ConfigEntry<float> StartOutsideEnemySpawnCurveConfig;
private ConfigEntry<float> MidOutsideEnemySpawnCurveConfig;
private ConfigEntry<float> EndOutsideEnemySpawnCurveConfig;
public static bool RemoveMasks;
public static bool RevealMasks;
public static bool ShowMaskedNames;
public static bool RemoveZombieArms;
public static bool UseSpawnRarity;
public static int SpawnRarity;
public static bool CanSpawnOutside;
public static int MaxSpawnCount;
public static int MaxZombies;
public static bool ZombieApocalypseMode;
public static bool UseVanillaSpawns;
public static int RandomChanceZombieApocalypse;
public static float InsideEnemySpawnCurve;
public static float MiddayInsideEnemySpawnCurve;
public static float StartOutsideEnemySpawnCurve;
public static float MidOutsideEnemySpawnCurve;
public static float EndOutsideEnemySpawnCurve;
public static int InitialPlayerCount;
public static SpawnableEnemyWithRarity maskedPrefab;
public static SpawnableEnemyWithRarity flowerPrefab;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
PlayerMimicList = new List<int>();
PlayerMimicIndex = 0;
InitialPlayerCount = 0;
ShowMaskedNamesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Masked Usernames", false, "Will show username of player being mimicked.");
RemoveMasksConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Mask From Masked Enemy", true, "Whether or not the Masked Enemy has a mask on.");
RevealMasksConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Reveal Mask When Attacking", false, "The enemy would reveal their mask permanently after trying to attack someone. Mask would be off until the attempt to attack is made");
RemoveZombieArmsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Remove Zombie Arms", true, "Remove the animation where the Masked raise arms like a zombie.");
UseVanillaSpawnsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Vanilla Spawns", false, "Ignores anything else in this mod. Only uses the above settings from this config. Will not spawn on all moons. will ignore EVERYTHING in the config below this point.");
UseSpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Use Spawn Rarity", false, "Use custom spawn rate from config. If this is false, the masked spawns at the same rate as the Bracken. If true, will spawn at whatever rarity is given in Spawn Rarity config option");
SpawnRarityConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Spawn Rarity", 15, "The rarity for the Masked Enemy to spawn. The higher the number, the more likely to spawn. Can go to 1000000000, any higher will break. Use Spawn Rarity must be set to True");
CanSpawnOutsideConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawns", "Allow Masked To Spawn Outside", false, "Whether the Masked Enemy can spawn outside the building");
MaxSpawnCountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Spawns", "Max Number of Masked", 2, "Max Number of possible masked to spawn in one level");
ZombieApocalypeModeConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Zombie Apocalypse Mode", "Zombie Apocalypse Mode", false, "Only spawns Masked! Make sure to crank up the Max Spawn Count in this config! Would also recommend bringing a gun (mod), a shovel works fine too though.... This mode does not play nice with other mods that affect spawn rates. Disable those before playing for best results");
MaxZombiesZombieConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Zombie Apocalypse Mode", "Max Number of Masked in Zombie Apocalypse", 2, "Max Number of possible masked to spawn in Zombie Apocalypse");
ZombieApocalypeRandomChanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Zombie Apocalypse Mode", "Random Zombie Apocalypse Mode", -1, "[Must Be Whole Number] The percent chance from 1 to 100 that a day could contain a zombie apocalypse. Put at -1 to never have the chance arise and don't have Only Spawn Masked turned on");
InsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Inside Masked Spawn Curve", 0.1f, "Spawn curve for masked inside, start of the day. Crank this way up for immediate action. More info in the readme");
MiddayInsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Inside Masked Spawn Curve", 500f, "Spawn curve for masked inside, midday.");
StartOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "StartOfDay Masked Outside Spawn Curve", -30f, "Spawn curve for outside masked, start of the day.");
MidOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "Midday Outside Masked Spawn Curve", -30f, "Spawn curve for outside masked, midday.");
EndOutsideEnemySpawnCurveConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Zombie Apocalypse Mode", "EOD Outside Masked Spawn Curve", 10f, "Spawn curve for outside masked, end of day");
RemoveMasks = RemoveMasksConfig.Value;
ShowMaskedNames = ShowMaskedNamesConfig.Value;
RevealMasks = RevealMasksConfig.Value;
UseVanillaSpawns = UseVanillaSpawnsConfig.Value;
RemoveZombieArms = RemoveZombieArmsConfig.Value;
UseSpawnRarity = UseSpawnRarityConfig.Value;
CanSpawnOutside = CanSpawnOutsideConfig.Value;
MaxSpawnCount = MaxSpawnCountConfig.Value;
SpawnRarity = SpawnRarityConfig.Value;
ZombieApocalypseMode = ZombieApocalypeModeConfig.Value;
MaxZombies = MaxZombiesZombieConfig.Value;
InsideEnemySpawnCurve = InsideEnemySpawnCurveConfig.Value;
MiddayInsideEnemySpawnCurve = MiddayInsideEnemySpawnCurveConfig.Value;
StartOutsideEnemySpawnCurve = StartOutsideEnemySpawnCurveConfig.Value;
MidOutsideEnemySpawnCurve = MidOutsideEnemySpawnCurveConfig.Value;
EndOutsideEnemySpawnCurve = EndOutsideEnemySpawnCurveConfig.Value;
RandomChanceZombieApocalypse = ZombieApocalypeRandomChanceConfig.Value;
logger = Logger.CreateLogSource("MaskedEnemyRework");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaskedEnemyRework is loaded! Woohoo!");
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(GetMaskedPrefabForLaterUse));
harmony.PatchAll(typeof(MaskedVisualRework));
harmony.PatchAll(typeof(MaskedSpawnSettings));
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MaskedEnemyRework";
public const string PLUGIN_NAME = "MaskedEnemyRework";
public const string PLUGIN_VERSION = "3.1.1";
}
}
namespace MaskedEnemyRework.Patches
{
[HarmonyPatch]
internal class GetMaskedPrefabForLaterUse
{
[HarmonyPatch(typeof(Terminal), "Start")]
[HarmonyPostfix]
private static void SavesPrefabForLaterUse(ref SelectableLevel[] ___moonsCatalogueList)
{
ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
SelectableLevel[] array = ___moonsCatalogueList;
foreach (SelectableLevel val2 in array)
{
foreach (SpawnableEnemyWithRarity enemy in val2.Enemies)
{
if (enemy.enemyType.enemyName == "Masked")
{
val.LogInfo((object)"Found Masked!");
Plugin.maskedPrefab = enemy;
}
else if (enemy.enemyType.enemyName == "Flowerman")
{
Plugin.flowerPrefab = enemy;
val.LogInfo((object)"Found Flowerman!");
}
}
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")]
[HarmonyPrefix]
private static void LookingAtMasked(ref PlayerControllerB __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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)
if (!Plugin.ShowMaskedNames)
{
return;
}
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
LayerMask val2 = LayerMask.op_Implicit(524288);
RaycastHit val3 = default(RaycastHit);
if (!__instance.isFreeCamera && Physics.Raycast(val, ref val3, 5f, LayerMask.op_Implicit(val2)))
{
EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val3)).collider).gameObject.GetComponent<EnemyAICollisionDetect>();
MaskedPlayerEnemy val4 = null;
if (Object.op_Implicit((Object)(object)component))
{
val4 = ((Component)component.mainScript).gameObject.GetComponent<MaskedPlayerEnemy>();
}
if ((Object)(object)val4 != (Object)null)
{
MaskedNamePatch.ToggleName(val4, TurnOn: true);
}
}
}
}
internal class MaskedNamePatch
{
public static void UpdateNameBillboard(MaskedPlayerEnemy masked)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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)
MaskedNameBillboard maskedNameBillboard = default(MaskedNameBillboard);
if (((Component)masked).gameObject.TryGetComponent<MaskedNameBillboard>(ref maskedNameBillboard))
{
Canvas usernameCanvas = maskedNameBillboard.usernameCanvas;
CanvasGroup canvasGroup = GetCanvasGroup(usernameCanvas);
Transform transform = ((Component)usernameCanvas).transform;
TextMeshProUGUI usernameText = maskedNameBillboard.usernameText;
if (Object.op_Implicit((Object)(object)usernameCanvas) && Object.op_Implicit((Object)(object)transform) && Object.op_Implicit((Object)(object)canvasGroup))
{
if (!((Component)usernameText).gameObject.activeInHierarchy || !Object.op_Implicit((Object)(object)((Graphic)usernameText).canvas))
{
((TMP_Text)usernameText).transform.SetParent(transform, false);
}
if (canvasGroup.alpha >= 0f && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
canvasGroup.alpha -= Time.deltaTime;
Vector3 val = default(Vector3);
((Vector3)(ref val)).Set(((Component)masked).transform.position.x, ((Component)masked).transform.position.y + 2.64f, ((Component)masked).transform.position.z);
transform.SetPositionAndRotation(val, transform.rotation);
transform.LookAt(GameNetworkManager.Instance.localPlayerController.localVisorTargetPoint);
}
else if (((Component)usernameCanvas).gameObject.activeSelf)
{
((Component)usernameCanvas).gameObject.SetActive(false);
}
}
}
else if ((Object)(object)masked.mimickingPlayer != (Object)null)
{
SetNameBillboard(masked);
}
}
public static void ToggleName(MaskedPlayerEnemy masked, bool TurnOn)
{
MaskedNameBillboard maskedNameBillboard = default(MaskedNameBillboard);
if (!((Object)(object)masked == (Object)null) && ((Component)masked).gameObject.TryGetComponent<MaskedNameBillboard>(ref maskedNameBillboard))
{
((Component)maskedNameBillboard.usernameCanvas).gameObject.SetActive(TurnOn);
if (TurnOn)
{
GetCanvasGroup(maskedNameBillboard.usernameCanvas).alpha = 1f;
}
}
}
public static CanvasGroup GetCanvasGroup(Canvas canvas)
{
CanvasGroup val = null;
if ((Object)(object)canvas != (Object)null)
{
val = ((Component)canvas).gameObject.GetComponent<CanvasGroup>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)canvas).gameObject.AddComponent<CanvasGroup>();
}
}
return val;
}
public static void SetNameBillboard(MaskedPlayerEnemy masked)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: 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_02e0: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)masked.mimickingPlayer == (Object)null))
{
PlayerControllerB mimickingPlayer = masked.mimickingPlayer;
MaskedNameBillboard maskedNameBillboard = default(MaskedNameBillboard);
if (!((Component)masked).gameObject.TryGetComponent<MaskedNameBillboard>(ref maskedNameBillboard))
{
maskedNameBillboard = ((Component)masked).gameObject.AddComponent<MaskedNameBillboard>();
}
maskedNameBillboard.usernameCanvas = mimickingPlayer.usernameCanvas;
GetCanvasGroup(maskedNameBillboard.usernameCanvas);
GameObject val = new GameObject("usernameText");
val.transform.SetParent(((Component)maskedNameBillboard.usernameCanvas).transform, false);
maskedNameBillboard.usernameText = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)maskedNameBillboard.usernameText).transform.SetParent(((Component)maskedNameBillboard.usernameCanvas).transform, false);
((TMP_Text)maskedNameBillboard.usernameText).text = ((TMP_Text)mimickingPlayer.usernameBillboardText).text;
((TMP_Text)maskedNameBillboard.usernameText).font = ((TMP_Text)mimickingPlayer.usernameBillboardText).font;
((Graphic)maskedNameBillboard.usernameText).color = ((Graphic)mimickingPlayer.usernameBillboardText).color;
((TMP_Text)maskedNameBillboard.usernameText).fontSize = ((TMP_Text)mimickingPlayer.usernameBillboardText).fontSize;
((TMP_Text)maskedNameBillboard.usernameText).enableAutoSizing = ((TMP_Text)mimickingPlayer.usernameBillboardText).enableAutoSizing;
((TMP_Text)maskedNameBillboard.usernameText).extraPadding = ((TMP_Text)mimickingPlayer.usernameBillboardText).extraPadding;
((TMP_Text)maskedNameBillboard.usernameText).alignment = ((TMP_Text)mimickingPlayer.usernameBillboardText).alignment;
((TMP_Text)maskedNameBillboard.usernameText).textStyle = ((TMP_Text)mimickingPlayer.usernameBillboardText).textStyle;
((TMP_Text)maskedNameBillboard.usernameText).textPreprocessor = ((TMP_Text)mimickingPlayer.usernameBillboardText).textPreprocessor;
((TMP_Text)maskedNameBillboard.usernameText).characterSpacing = ((TMP_Text)mimickingPlayer.usernameBillboardText).characterSpacing;
((TMP_Text)maskedNameBillboard.usernameText).wordSpacing = ((TMP_Text)mimickingPlayer.usernameBillboardText).wordSpacing;
((TMP_Text)maskedNameBillboard.usernameText).lineSpacing = ((TMP_Text)mimickingPlayer.usernameBillboardText).lineSpacing;
((TMP_Text)maskedNameBillboard.usernameText).margin = ((TMP_Text)mimickingPlayer.usernameBillboardText).margin;
((TMP_Text)maskedNameBillboard.usernameText).overflowMode = ((TMP_Text)mimickingPlayer.usernameBillboardText).overflowMode;
((TMP_Text)maskedNameBillboard.usernameText).fontSharedMaterial = ((TMP_Text)mimickingPlayer.usernameBillboardText).fontSharedMaterial;
((TMP_Text)maskedNameBillboard.usernameText).fontSizeMin = ((TMP_Text)mimickingPlayer.usernameBillboardText).fontSizeMin;
((TMP_Text)maskedNameBillboard.usernameText).fontSizeMax = ((TMP_Text)mimickingPlayer.usernameBillboardText).fontSizeMax;
((TMP_Text)maskedNameBillboard.usernameText).enableKerning = ((TMP_Text)mimickingPlayer.usernameBillboardText).enableKerning;
RectTransform component = ((Component)mimickingPlayer.usernameBillboardText).GetComponent<RectTransform>();
RectTransform component2 = ((Component)maskedNameBillboard.usernameText).GetComponent<RectTransform>();
((Transform)component2).localPosition = ((Transform)component).localPosition;
component2.sizeDelta = component.sizeDelta;
component2.anchorMin = component.anchorMin;
component2.anchorMax = component.anchorMax;
component2.pivot = component.pivot;
component2.anchoredPosition = component.anchoredPosition;
((Transform)component2).localScale = ((Transform)component).localScale;
component2.offsetMin = component.offsetMin;
component2.offsetMax = component.offsetMax;
((Transform)component2).right = ((Transform)component).right;
((Component)maskedNameBillboard.usernameText).gameObject.SetActive(true);
((Behaviour)maskedNameBillboard.usernameText).enabled = true;
((Behaviour)maskedNameBillboard.usernameCanvas).enabled = true;
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class MaskedSpawnSettings
{
[HarmonyPatch("BeginEnemySpawning")]
[HarmonyPrefix]
private static void UpdateSpawnRates(ref SelectableLevel ___currentLevel)
{
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: 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_01d4: Expected O, but got Unknown
//IL_01e8: 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_01fe: 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_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Expected O, but got Unknown
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: 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_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
if (Plugin.UseVanillaSpawns)
{
return;
}
try
{
SpawnableEnemyWithRarity maskedPrefab = Plugin.maskedPrefab;
SpawnableEnemyWithRarity val = Plugin.flowerPrefab;
List<SpawnableEnemyWithRarity> enemies = ___currentLevel.Enemies;
for (int i = 0; i < ___currentLevel.Enemies.Count; i++)
{
SpawnableEnemyWithRarity val2 = ___currentLevel.Enemies[i];
if (val2.enemyType.enemyName == "Masked")
{
enemies.Remove(val2);
}
if (val2.enemyType.enemyName == "Flowerman")
{
val = val2;
}
}
___currentLevel.Enemies = enemies;
maskedPrefab.enemyType.PowerLevel = 1;
maskedPrefab.enemyType.probabilityCurve = val.enemyType.probabilityCurve;
if (Plugin.UseSpawnRarity)
{
maskedPrefab.rarity = Plugin.SpawnRarity;
}
else
{
maskedPrefab.rarity = val.rarity;
}
maskedPrefab.enemyType.MaxCount = Plugin.MaxSpawnCount;
int num = 0;
num = ((StartOfRound.Instance.randomMapSeed.ToString().Length >= 3) ? int.Parse(StartOfRound.Instance.randomMapSeed.ToString().Substring(1, 2)) : 0);
num = Mathf.Clamp(num, 0, 100);
if (Plugin.ZombieApocalypseMode || (num <= Plugin.RandomChanceZombieApocalypse && Plugin.RandomChanceZombieApocalypse >= 0))
{
maskedPrefab.enemyType.MaxCount = Plugin.MaxZombies;
Plugin.RandomChanceZombieApocalypse = -1;
___currentLevel.enemySpawnChanceThroughoutDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, Plugin.InsideEnemySpawnCurve),
new Keyframe(0.5f, Plugin.MiddayInsideEnemySpawnCurve)
});
___currentLevel.daytimeEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, 7f),
new Keyframe(0.5f, 7f)
});
___currentLevel.outsideEnemySpawnChanceThroughDay = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
{
new Keyframe(0f, Plugin.StartOutsideEnemySpawnCurve),
new Keyframe(20f, Plugin.MidOutsideEnemySpawnCurve),
new Keyframe(21f, Plugin.EndOutsideEnemySpawnCurve)
});
maskedPrefab.rarity = 1000000;
}
maskedPrefab.enemyType.isOutsideEnemy = Plugin.CanSpawnOutside;
if (Plugin.CanSpawnOutside)
{
___currentLevel.OutsideEnemies.Add(maskedPrefab);
}
SelectableLevel obj = ___currentLevel;
obj.maxEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
SelectableLevel obj2 = ___currentLevel;
obj2.maxDaytimeEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
SelectableLevel obj3 = ___currentLevel;
obj3.maxOutsideEnemyPowerCount += maskedPrefab.enemyType.MaxCount;
___currentLevel.Enemies.Add(maskedPrefab);
}
catch
{
}
}
}
[HarmonyPatch(typeof(MaskedPlayerEnemy))]
internal class MaskedVisualRework
{
private static int randomPlayerIndex;
private static IEnumerator coroutine;
[HarmonyPatch("Start")]
[HarmonyBefore(new string[] { "AdvancedCompany" })]
[HarmonyPostfix]
private static void ReformVisuals(ref MaskedPlayerEnemy __instance)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
int num = StartOfRound.Instance.ClientPlayerList.Count;
if (num == 0)
{
num = 1;
val.LogError((object)"Player count was zero");
}
if (Plugin.PlayerMimicList.Count <= 1 || Plugin.InitialPlayerCount != num)
{
Plugin.InitialPlayerCount = num;
State state = Random.state;
Random.InitState(1234);
for (int i = 0; i < 50; i++)
{
Plugin.PlayerMimicList.Add(Random.Range(0, num));
}
Random.state = state;
}
randomPlayerIndex = Plugin.PlayerMimicList[Plugin.PlayerMimicIndex % 50];
randomPlayerIndex = Mathf.Clamp(randomPlayerIndex, 0, num);
Plugin.PlayerMimicIndex++;
if ((Object)(object)__instance.mimickingPlayer == (Object)null)
{
__instance.mimickingPlayer = allPlayerScripts[randomPlayerIndex];
}
__instance.SetSuit(__instance.mimickingPlayer.currentSuitID);
if (Plugin.RemoveMasks || Plugin.RevealMasks)
{
((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskComedy")).gameObject.SetActive(false);
((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskTragedy")).gameObject.SetActive(false);
}
if (Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany") && !Chainloader.PluginInfos.ContainsKey("com.potatoepet.AdvancedCompany"))
{
MoreCompanyPatch.ApplyCosmetics(__instance);
}
if (Plugin.ShowMaskedNames)
{
MaskedNamePatch.SetNameBillboard(__instance);
}
}
[HarmonyPatch("SetHandsOutClientRpc")]
[HarmonyPrefix]
private static void MaskAndArmsReveal(ref bool setOut, ref MaskedPlayerEnemy __instance)
{
GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskComedy")).gameObject;
if (Plugin.RevealMasks && !gameObject.activeSelf && ((EnemyAI)__instance).currentBehaviourStateIndex == 1)
{
ManualLogSource val = Logger.CreateLogSource("MaskedEnemyRework");
IEnumerator enumerator = FadeInAndOut(gameObject, fadeIn: true, 1f);
((MonoBehaviour)__instance).StartCoroutine(enumerator);
}
if (Plugin.RemoveZombieArms)
{
setOut = false;
}
if (Plugin.ShowMaskedNames)
{
MaskedNamePatch.SetNameBillboard(__instance);
}
}
[HarmonyPatch("SetEnemyOutside")]
[HarmonyPostfix]
[HarmonyPriority(300)]
private static void HideCosmeticsIfMarked(ref MaskedPlayerEnemy __instance)
{
if (Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany") && !Chainloader.PluginInfos.ContainsKey("com.potatoepet.AdvancedCompany"))
{
MoreCompanyPatch.ApplyCosmetics(__instance);
}
}
[HarmonyPatch("DoAIInterval")]
[HarmonyPostfix]
private static void HideRevealedMask(ref MaskedPlayerEnemy __instance)
{
if (Plugin.RevealMasks && (Object)(object)((EnemyAI)__instance).targetPlayer == (Object)null)
{
GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/HeadMaskComedy")).gameObject;
if (gameObject.activeSelf)
{
IEnumerator enumerator = FadeInAndOut(gameObject, fadeIn: false, 1f);
((MonoBehaviour)__instance).StartCoroutine(enumerator);
}
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdateMaskName(ref MaskedPlayerEnemy __instance)
{
if (Plugin.ShowMaskedNames)
{
MaskedNamePatch.UpdateNameBillboard(__instance);
}
}
private static IEnumerator FadeInAndOut(GameObject mask, bool fadeIn, float duration)
{
float counter = 0f;
mask.SetActive(true);
float startLoc;
float endLoc;
if (fadeIn)
{
startLoc = 0.095f;
endLoc = 0.215f;
}
else
{
startLoc = 0.215f;
endLoc = 0.095f;
}
while (counter < duration)
{
counter += Time.deltaTime;
float loc = Mathf.Lerp(startLoc, endLoc, counter / duration);
mask.transform.localPosition = new Vector3(-0.009f, 0.143f, loc);
yield return null;
}
if (!fadeIn)
{
mask.SetActive(false);
}
}
}
internal class MoreCompanyPatch
{
public static void ApplyCosmetics(MaskedPlayerEnemy masked)
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
if (!MainClass.showCosmetics || MainClass.playerIdsAndCosmetics.Count == 0)
{
return;
}
Transform val = ((Component)masked).transform.Find("ScavengerModel").Find("metarig");
CosmeticApplication component = ((Component)val).GetComponent<CosmeticApplication>();
if (Object.op_Implicit((Object)(object)component))
{
component.ClearCosmetics();
Object.Destroy((Object)(object)component);
}
List<string> list = MainClass.playerIdsAndCosmetics[(int)masked.mimickingPlayer.playerClientId];
component = ((Component)val).gameObject.AddComponent<CosmeticApplication>();
foreach (string item in list)
{
component.ApplyCosmetic(item, true);
}
foreach (CosmeticInstance spawnedCosmetic in component.spawnedCosmetics)
{
Transform transform = ((Component)spawnedCosmetic).transform;
transform.localScale *= 0.38f;
}
}
}
internal class RemoveZombieArms
{
[HarmonyPatch(typeof(MaskedPlayerEnemy), "SetHandsOutClientRpc")]
[HarmonyPrefix]
private static void RemoveArms(ref bool setOut)
{
if (Plugin.RemoveZombieArms)
{
setOut = false;
}
}
}
}
namespace MaskedEnemyRework.External_Classes
{
internal class MaskedMimicFields : MonoBehaviour
{
public PlayerControllerB MimickingPlayerController { get; set; }
}
internal class MaskedNameBillboard : MonoBehaviour
{
public Canvas usernameCanvas;
public TextMeshProUGUI usernameText;
}
}