using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using StaticNetcodeLib;
using TheThing.Scripts;
using TheThing.Utils;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
[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("TheThing")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("TheThing")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6643bf7a6199da9b806b093a26c48c1aa96463bf")]
[assembly: AssemblyProduct("TheThing")]
[assembly: AssemblyTitle("TheThing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 TheThing
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("evaisa.lethallib", "0.15.1")]
[BepInPlugin("wexop.the_thing", "TheThing", "1.0.5")]
public class TheThingPlugin : BaseUnityPlugin
{
private const string GUID = "wexop.the_thing";
private const string NAME = "TheThing";
private const string VERSION = "1.0.5";
public GameObject roomObject;
public GameObject actualRoomObjectInstantiated;
public ThingRoomManager actualRoomObjectManager;
public Dictionary<int, LightInformation> lightsInUse = new Dictionary<int, LightInformation>();
public static TheThingPlugin instance;
public ConfigEntry<string> spawnMoonRarity;
public ConfigEntry<int> maxSeePlayerCount;
public ConfigEntry<float> timeBetweenTeleport;
public ConfigEntry<float> minDistanceBetweenPlayerToTeleport;
public ConfigEntry<float> TimeToEscapeRoom;
public ConfigEntry<int> monsterToHitToEscapeRoom;
public ConfigEntry<float> enemyPower;
public ConfigEntry<float> roomFogDistance;
private void Awake()
{
instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"TheThing starting....");
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "thing");
AssetBundle bundle = AssetBundle.LoadFromFile(text);
((BaseUnityPlugin)this).Logger.LogInfo((object)"TheThing bundle found !");
LoadConfigs();
RegisterMonster(bundle);
LoadRoom(bundle);
((BaseUnityPlugin)this).Logger.LogInfo((object)"TheThing is ready!");
}
private void LoadConfigs()
{
spawnMoonRarity = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SpawnRarity", "Modded:40,ExperimentationLevel:20,AssuranceLevel:20,VowLevel:20,OffenseLevel:25,MarchLevel:25,RendLevel:30,DineLevel:30,TitanLevel:40,Adamance:35,Embrion:40,Artifice:45", "Chance for thing to spawn for any moon, example => assurance:100,offense:50 . You need to restart the game.");
CreateStringConfig(spawnMoonRarity, requireRestart: true);
enemyPower = ((BaseUnityPlugin)this).Config.Bind<float>("General", "EnemyPower", 2f, "Enemy power for Thing monster. You need to restart the game.");
CreateFloatConfig(enemyPower, 0f, 10f);
maxSeePlayerCount = ((BaseUnityPlugin)this).Config.Bind<int>("Behavior", "MaxSeePlayerCount", 4, "Max player see by the monster before teleporting him into his room. No need to restart the game !");
CreateIntConfig(maxSeePlayerCount);
timeBetweenTeleport = ((BaseUnityPlugin)this).Config.Bind<float>("Behavior", "timeBetweenTeleport", 20f, "Time to wait before teleport to another place after the thing see a player. No need to restart the game !");
CreateFloatConfig(timeBetweenTeleport);
minDistanceBetweenPlayerToTeleport = ((BaseUnityPlugin)this).Config.Bind<float>("Behavior", "minDistanceBetweenPlayerToTeleport", 45f, "Minimum distance to have with any player to teleport somewhere to wait. No need to restart the game !");
CreateFloatConfig(minDistanceBetweenPlayerToTeleport);
monsterToHitToEscapeRoom = ((BaseUnityPlugin)this).Config.Bind<int>("Behavior", "MonsterToHitToEscapeRoom", 2, "Monsters to hit to escape the room. No need to restart the game !");
CreateIntConfig(monsterToHitToEscapeRoom);
roomFogDistance = ((BaseUnityPlugin)this).Config.Bind<float>("RoomSettings", "roomFogDistance", 10f, "Thing room fog distance. No need to restart the game !");
CreateFloatConfig(roomFogDistance);
TimeToEscapeRoom = ((BaseUnityPlugin)this).Config.Bind<float>("RoomSettings", "TimeToEscapeRoom", 90f, "Time to escape the room. No need to restart the game !");
CreateFloatConfig(TimeToEscapeRoom, 0f, 300f);
}
private void RegisterMonster(AssetBundle bundle)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
EnemyType val = bundle.LoadAsset<EnemyType>("Assets/LethalCompany/Mods/ThingMonster/Thing.asset");
((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND"));
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val.enemyPrefab} prefab");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Utilities.FixMixerGroups(val.enemyPrefab);
TerminalNode val2 = new TerminalNode();
val2.creatureName = "Thing";
val2.displayText = "";
TerminalKeyword val3 = new TerminalKeyword();
val3.word = "Thing";
RegisterUtil.RegisterEnemyWithConfig(spawnMoonRarity.Value, val, val2, val3, instance.enemyPower.Value, val.MaxCount);
}
private void LoadRoom(AssetBundle bundle)
{
GameObject val = (roomObject = bundle.LoadAsset<GameObject>("Assets/LethalCompany/Mods/ThingMonster/ThingRoom.prefab"));
((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND"));
Utilities.FixMixerGroups(val);
}
public void InstantiateRoom()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
DestroyRoom();
actualRoomObjectInstantiated = Object.Instantiate<GameObject>(roomObject, Vector3.up * -500f, Quaternion.identity);
actualRoomObjectManager = actualRoomObjectInstantiated.GetComponent<ThingRoomManager>();
}
public void DestroyRoom()
{
if ((Object)(object)actualRoomObjectInstantiated != (Object)null)
{
Object.Destroy((Object)(object)actualRoomObjectInstantiated);
Object.Destroy((Object)(object)actualRoomObjectManager);
actualRoomObjectManager = null;
actualRoomObjectInstantiated = null;
}
}
private void CreateFloatConfig(ConfigEntry<float> configEntry, float min = 0f, float max = 100f)
{
//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: Expected O, but got Unknown
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
FloatSliderOptions val = new FloatSliderOptions();
((BaseRangeOptions<float>)val).Min = min;
((BaseRangeOptions<float>)val).Max = max;
((BaseOptions)val).RequiresRestart = false;
FloatSliderConfigItem val2 = new FloatSliderConfigItem(configEntry, val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
}
private void CreateIntConfig(ConfigEntry<int> configEntry, int min = 0, int max = 100)
{
//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: Expected O, but got Unknown
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
IntSliderOptions val = new IntSliderOptions();
((BaseRangeOptions<int>)val).Min = min;
((BaseRangeOptions<int>)val).Max = max;
((BaseOptions)val).RequiresRestart = false;
IntSliderConfigItem val2 = new IntSliderConfigItem(configEntry, val);
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
}
private void CreateStringConfig(ConfigEntry<string> configEntry, bool requireRestart = false)
{
//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_0014: Expected O, but got Unknown
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
TextInputFieldConfigItem val = new TextInputFieldConfigItem(configEntry, new TextInputFieldOptions
{
RequiresRestart = requireRestart
});
LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "TheThing";
public const string PLUGIN_NAME = "TheThing";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace TheThing.Utils
{
public class RegisterUtil
{
public static void RegisterEnemyWithConfig(string configMoonRarity, EnemyType enemy, TerminalNode terminalNode, TerminalKeyword terminalKeyword, float powerLevel, int spawnCount)
{
enemy.MaxCount = spawnCount;
enemy.PowerLevel = powerLevel;
var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword);
}
public static void RegisterScrapWithConfig(string configMoonRarity, Item scrap)
{
var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
Items.RegisterScrap(scrap, dictionary, dictionary2);
}
public static void RegisterShopItemWithConfig(bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity)
{
Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost);
if (enabledScrap)
{
RegisterScrapWithConfig(configMoonRarity, item);
}
}
public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
foreach (string item in from s in configMoonRarity.Split(',')
select s.Trim())
{
string[] array = item.Split(':');
if (array.Length != 2)
{
continue;
}
string text = array[0];
if (!int.TryParse(array[1], out var result))
{
continue;
}
if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
{
dictionary[result2] = result;
continue;
}
string value = text + "Level";
if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result2))
{
dictionary[result2] = result;
}
else
{
dictionary2[text] = result;
}
}
return (dictionary, dictionary2);
}
}
}
namespace TheThing.Scripts
{
public class EscapeRoomObject : MonoBehaviour, IHittable
{
private static readonly int Disapear = Animator.StringToHash("disappear");
public Animator animator;
public AudioSource AudioSource;
public AudioClip onHitSound;
public int id;
public ThingRoomManager thingRoomManager;
private bool alreadyHit = false;
public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
if (alreadyHit)
{
return true;
}
animator.SetTrigger(Disapear);
thingRoomManager.OnHitEscapeObject(id);
alreadyHit = true;
((Behaviour)((Component)this).GetComponentInChildren<Light>()).enabled = false;
AudioSource.PlayOneShot(onHitSound);
return true;
}
}
public class LightInformation
{
public Light Light;
public Color color;
public float intensity;
public FlashlightItem flashlightItem;
}
[StaticNetcode]
public class NetworkThing
{
public static ThingEnemyAI GetThingEnemyAI(ulong networkId)
{
List<ThingEnemyAI> list = Object.FindObjectsByType<ThingEnemyAI>((FindObjectsSortMode)0).ToList();
ThingEnemyAI thingEnemyAI = list.Find((ThingEnemyAI e) => ((NetworkBehaviour)e).NetworkObjectId == networkId);
if ((Object)(object)thingEnemyAI == (Object)null)
{
Debug.LogError((object)$"ROLLER BALL NOT FOUND {networkId}");
return null;
}
return thingEnemyAI;
}
[ServerRpc]
public static void SetPlayerIdServerRpc(ulong networkId, ulong playerId)
{
SetPlayerIdClientRpc(networkId, playerId);
}
[ClientRpc]
public static void SetPlayerIdClientRpc(ulong networkId, ulong playerId)
{
ThingEnemyAI thingEnemyAI = GetThingEnemyAI(networkId);
if (Object.op_Implicit((Object)(object)thingEnemyAI))
{
thingEnemyAI.OnSetPlayerId(playerId);
}
}
[ServerRpc]
public static void EnableEscapeObjectServerRpc(int id)
{
EnableEscapeObjectClientRpc(id);
}
[ClientRpc]
public static void EnableEscapeObjectClientRpc(int id)
{
TheThingPlugin.instance.actualRoomObjectManager.EnableEscapeObject(id);
}
[ServerRpc]
public static void EscapeRoomServerRpc()
{
EscapeRoomClientRpc();
}
[ClientRpc]
public static void EscapeRoomClientRpc()
{
((MonoBehaviour)TheThingPlugin.instance.actualRoomObjectManager).StartCoroutine(TheThingPlugin.instance.actualRoomObjectManager.OnEscaped());
}
}
public class ThingEnemyAI : EnemyAI
{
private static readonly int Idle = Animator.StringToHash("idle");
private static readonly int Jumpscare = Animator.StringToHash("jumpscare");
public GameObject headObject;
public GameObject modelObject;
public Light redLight;
public AudioClip seePlayerSound;
public AudioClip scaryAmbiantSound;
public AudioClip JumpscareSound;
public float aiInterval;
public int lastBehaviorState;
public ulong lastPlayerIdToKill;
private PlayerControllerB playerToKIll = null;
private List<LightInformation> lights = new List<LightInformation>();
public bool playerToKillIsLocal;
private Vector3 positionJumpScare;
private bool _isActive;
private bool _shouldResetLights;
private bool _shouldTpToPlayer;
private int _sawPlayerCount;
private float _lightAnimationDuration = 3f;
private float _lightAnimationTimer;
private int _lastNodeIndex;
private float _timeBetweenTeleport = 10f;
private float _teleportTimer;
private float _notSeePlayerTimer;
private float _changePositionSeePlayerDuration = 45f;
public override void Start()
{
((EnemyAI)this).Start();
AllClientOnSwitchBehaviorState();
ActivateMonster(active: false);
base.agent.speed = 0f;
base.debugEnemyAI = true;
_timeBetweenTeleport = TheThingPlugin.instance.timeBetweenTeleport.Value;
}
public override void EnableEnemyMesh(bool enable, bool overrideDoNotSet = false)
{
}
public override void OnSyncPositionFromServer(Vector3 pos)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.position = pos;
}
public override void Update()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
aiInterval -= Time.deltaTime;
_lightAnimationTimer -= Time.deltaTime;
_teleportTimer -= Time.deltaTime;
if (base.currentBehaviourStateIndex == 1)
{
_notSeePlayerTimer -= Time.deltaTime;
}
if (lastBehaviorState != base.currentBehaviourStateIndex)
{
lastBehaviorState = base.currentBehaviourStateIndex;
AllClientOnSwitchBehaviorState();
}
if (base.currentBehaviourStateIndex == 2 && GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.25f, 100f, 60, -1f))
{
GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.8f, true);
}
if (_lightAnimationTimer < -0.5f && _shouldResetLights)
{
ResetLights();
_shouldResetLights = false;
}
if (aiInterval <= 0f && ((NetworkBehaviour)this).IsOwner)
{
aiInterval = base.AIIntervalTime;
((EnemyAI)this).DoAIInterval();
}
}
private void LateUpdate()
{
//IL_0099: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
if (base.currentBehaviourStateIndex == 2 && _lightAnimationTimer > -0.5f)
{
lights.ForEach(delegate(LightInformation l)
{
//IL_0061: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
float num = Math.Clamp(_lightAnimationTimer, 0f, _lightAnimationDuration) / _lightAnimationDuration;
if (num < 0.2f)
{
num = 0f;
}
l.Light.intensity = num * l.intensity;
if (Object.op_Implicit((Object)(object)l.flashlightItem))
{
l.flashlightItem.flashlightBulb.color = l.color * num;
l.flashlightItem.flashlightBulbGlow.color = l.color * num;
}
});
}
if (base.currentBehaviourStateIndex == 1 && !Object.op_Implicit((Object)(object)base.targetPlayer))
{
PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
if (Object.op_Implicit((Object)(object)closestPlayer))
{
((Component)this).transform.LookAt(((Component)closestPlayer.gameplayCamera).transform);
((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y, 0f);
}
}
if (base.currentBehaviourStateIndex == 4 && Object.op_Implicit((Object)(object)base.targetPlayer))
{
if (playerToKillIsLocal)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
((Component)localPlayerController.gameplayCamera).transform.eulerAngles = new Vector3(0f, ((Component)localPlayerController.gameplayCamera).transform.eulerAngles.y, ((Component)localPlayerController.gameplayCamera).transform.eulerAngles.z);
}
positionJumpScare = ((Component)base.targetPlayer.gameplayCamera).transform.position + ((Component)base.targetPlayer.gameplayCamera).transform.forward * 1.4f;
((Component)this).transform.position = positionJumpScare - Vector3.up * 2.5f;
((Component)this).transform.LookAt(((Component)base.targetPlayer.gameplayCamera).transform);
((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y, 0f);
}
}
public override void DoAIInterval()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).SyncPositionToClients();
switch (base.currentBehaviourStateIndex)
{
case 0:
if (!_isActive && _teleportTimer < 0f)
{
Vector3 randomNodeObjectPos = GetRandomNodeObjectPos();
if (CheckIfPlayerAreInRange(randomNodeObjectPos))
{
_notSeePlayerTimer = _changePositionSeePlayerDuration;
((Component)this).transform.position = randomNodeObjectPos;
((EnemyAI)this).SyncPositionToClients();
((EnemyAI)this).SwitchToBehaviourState(1);
}
}
break;
case 1:
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if (_notSeePlayerTimer < 0f)
{
((EnemyAI)this).SwitchToBehaviourState(0);
}
if (!((Object)(object)base.targetPlayer == (Object)null) && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false))
{
NetworkThing.SetPlayerIdServerRpc(((NetworkBehaviour)this).NetworkObjectId, base.targetPlayer.actualClientId);
_sawPlayerCount++;
_teleportTimer = _timeBetweenTeleport;
((EnemyAI)this).SwitchToBehaviourState(2);
}
break;
case 2:
if (_lightAnimationTimer <= 0.5f)
{
((EnemyAI)this).SwitchToBehaviourState((_sawPlayerCount >= TheThingPlugin.instance.maxSeePlayerCount.Value) ? 3 : 0);
}
break;
case 3:
break;
case 4:
break;
}
}
public void AllClientOnSwitchBehaviorState()
{
//IL_018b: 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)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
base.creatureAnimator.SetBool(Jumpscare, false);
((Behaviour)redLight).enabled = false;
((Behaviour)base.agent).enabled = base.currentBehaviourStateIndex != 4;
switch (base.currentBehaviourStateIndex)
{
case 0:
base.targetPlayer = null;
ActivateMonster(active: false);
_shouldTpToPlayer = false;
break;
case 1:
ActivateMonster(active: true);
base.creatureAnimator.SetBool(Idle, true);
break;
case 2:
base.creatureSFX.PlayOneShot(seePlayerSound);
_lightAnimationTimer = _lightAnimationDuration;
_shouldResetLights = true;
GetLightsClose();
break;
case 3:
ActivateMonster(active: false);
TheThingPlugin.instance.InstantiateRoom();
TheThingPlugin.instance.actualRoomObjectManager.ThingEnemyAI = this;
SpawnShovel();
if (Object.op_Implicit((Object)(object)base.targetPlayer))
{
((MonoBehaviour)this).StartCoroutine(DropItemsAndTeleportPlayer());
}
TheThingPlugin.instance.actualRoomObjectManager.OnPlayerSpawnIntoRoom();
break;
case 4:
_sawPlayerCount = 0;
ActivateMonster(active: true);
((Behaviour)redLight).enabled = true;
((MonoBehaviour)this).StartCoroutine(JumpScareAnimation());
base.creatureAnimator.SetBool(Jumpscare, true);
base.creatureSFX.PlayOneShot(JumpscareSound);
positionJumpScare = ((Component)base.targetPlayer.gameplayCamera).transform.position + ((Component)base.targetPlayer.gameplayCamera).transform.forward * 1.4f;
if (playerToKillIsLocal)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
localPlayerController.JumpToFearLevel(0.9f, true);
localPlayerController.disableMoveInput = true;
localPlayerController.disableLookInput = true;
localPlayerController.disableInteract = true;
}
break;
}
}
public void OnSetPlayerId(ulong playerId)
{
lastPlayerIdToKill = playerId;
base.targetPlayer = StartOfRound.Instance.allPlayerScripts.ToList().Find((PlayerControllerB p) => p.actualClientId == playerId);
}
private IEnumerator DropItemsAndTeleportPlayer()
{
if (base.targetPlayer.playerClientId == GameNetworkManager.Instance.localPlayerController.playerClientId)
{
playerToKillIsLocal = true;
}
if (playerToKillIsLocal)
{
GameNetworkManager.Instance.localPlayerController.DropAllHeldItemsAndSync();
}
yield return (object)new WaitForSeconds(0.3f);
((Component)base.targetPlayer).transform.position = TheThingPlugin.instance.actualRoomObjectInstantiated.transform.position + new Vector3(1f, 1f, 0f);
if (playerToKillIsLocal)
{
PlayerControllerB player = GameNetworkManager.Instance.localPlayerController;
((Component)player).transform.position = TheThingPlugin.instance.actualRoomObjectInstantiated.transform.position + new Vector3(1f, 1f, 0f);
}
}
private IEnumerator JumpScareAnimation()
{
yield return (object)new WaitForSeconds(2f);
if (playerToKillIsLocal)
{
GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.zero, true, (CauseOfDeath)8, 0, default(Vector3));
CancelPlayerEffects();
}
base.targetPlayer = null;
playerToKillIsLocal = false;
playerToKIll = null;
_teleportTimer = _timeBetweenTeleport;
if (((NetworkBehaviour)this).IsOwner)
{
Vector3 pos = GetRandomNodeObjectPos();
((Component)this).transform.position = pos;
((EnemyAI)this).SwitchToBehaviourState(0);
}
((MonoBehaviour)this).StartCoroutine(DestroyRoom());
}
private IEnumerator DestroyRoom()
{
yield return (object)new WaitForSeconds(2f);
TheThingPlugin.instance.DestroyRoom();
}
public void MonsterAttackPlayer()
{
Debug.Log((object)"MONSTER ATTACK");
if (Object.op_Implicit((Object)(object)base.targetPlayer) && base.targetPlayer.isPlayerDead)
{
((EnemyAI)this).SwitchToBehaviourState(0);
}
_shouldTpToPlayer = true;
((EnemyAI)this).SwitchToBehaviourServerRpc(4);
}
public void CancelMonsterAttack()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
_sawPlayerCount = 0;
if (playerToKillIsLocal)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
((Component)localPlayerController).transform.position = StartOfRound.Instance.insideShipPositions[0].position;
}
base.targetPlayer = null;
playerToKillIsLocal = false;
playerToKIll = null;
_teleportTimer = _timeBetweenTeleport;
if (((NetworkBehaviour)this).IsOwner)
{
Vector3 randomNodeObjectPos = GetRandomNodeObjectPos();
((Component)this).transform.position = randomNodeObjectPos;
((EnemyAI)this).SwitchToBehaviourState(0);
}
try
{
((MonoBehaviour)this).StartCoroutine(DestroyRoom());
((MonoBehaviour)this).StopCoroutine(JumpScareAnimation());
}
catch
{
}
}
private void CancelPlayerEffects()
{
if (playerToKillIsLocal)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
localPlayerController.disableMoveInput = false;
localPlayerController.disableLookInput = false;
localPlayerController.disableInteract = false;
}
}
private void ActivateMonster(bool active)
{
_isActive = active;
modelObject.SetActive(active);
}
private Vector3 GetRandomNodeObjectPos()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (base.allAINodes.Length != 0)
{
int num;
for (num = Random.Range(0, base.allAINodes.Length); num == _lastNodeIndex; num = Random.Range(0, base.allAINodes.Length))
{
}
lastBehaviorState = num;
return base.allAINodes[num].transform.position;
}
return ((Component)this).transform.position;
}
private bool CheckIfPlayerAreInRange(Vector3 position)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
bool result = true;
StartOfRound.Instance.allPlayerScripts.ToList().ForEach(delegate(PlayerControllerB p)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Distance(((Component)p.gameplayCamera).transform.position, position) < TheThingPlugin.instance.minDistanceBetweenPlayerToTeleport.Value)
{
result = false;
}
});
return result;
}
private void ResetLights()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
foreach (LightInformation light in lights)
{
if (Object.op_Implicit((Object)(object)light.Light))
{
light.Light.intensity = light.intensity;
}
if (Object.op_Implicit((Object)(object)light.flashlightItem))
{
light.Light.color = light.color;
}
}
}
private void GetLightsClose()
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
lights.Clear();
List<Light> list = Object.FindObjectsByType<Light>((FindObjectsInactive)1, (FindObjectsSortMode)0).ToList().FindAll((Light light) => Vector3.Distance(((Component)light).transform.position, ((Component)this).transform.position) < 30f && Object.op_Implicit((Object)(object)light));
foreach (Light item in list)
{
if (!((Object)(object)((Component)item).GetComponentInParent<animatedSun>() != (Object)null) && !(((Object)item).name == "NightVision") && !((Object)item).name.Contains("Spot Light") && !((Object)item).name.Contains("RedLight") && !((Object)item).name.Contains("RadarCamNightVision"))
{
FlashlightItem componentInParent = ((Component)item).GetComponentInParent<FlashlightItem>();
LightInformation lightInformation = new LightInformation();
lightInformation.Light = item;
lightInformation.color = item.color;
lightInformation.intensity = item.intensity;
lightInformation.flashlightItem = componentInParent;
lights.Add(lightInformation);
}
}
}
public void SpawnShovel()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
GameObject shovel = null;
((NetworkBehaviour)this).NetworkManager.NetworkConfig.Prefabs.NetworkPrefabsLists?.ForEach(delegate(NetworkPrefabsList list)
{
list.PrefabList?.ToList().ForEach(delegate(NetworkPrefab prefab)
{
GrabbableObject component = prefab.Prefab.GetComponent<GrabbableObject>();
if ((Object)(object)component != (Object)null && component.itemProperties.itemName == "Shovel")
{
shovel = prefab.Prefab;
}
});
});
GameObject val = Object.Instantiate<GameObject>(shovel, TheThingPlugin.instance.actualRoomObjectInstantiated.transform);
val.transform.localPosition = TheThingPlugin.instance.actualRoomObjectManager.shovelPosition;
val.GetComponent<NetworkObject>().Spawn(false);
}
public override void OnCollideWithPlayer(Collider other)
{
PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component != (Object)null && component.actualClientId == GameNetworkManager.Instance.localPlayerController.actualClientId)
{
base.targetPlayer = GameNetworkManager.Instance.localPlayerController;
playerToKillIsLocal = true;
NetworkThing.SetPlayerIdServerRpc(((NetworkBehaviour)this).NetworkObjectId, base.targetPlayer.actualClientId);
MonsterAttackPlayer();
}
}
}
public class ThingRoomManager : MonoBehaviour
{
public AudioSource ambientSource;
public AudioClip welcomeSound;
public AudioClip scaryAmbientSound;
public Vector3 shovelPosition;
public List<LightInformation> lights = new List<LightInformation>();
public List<EscapeRoomObject> EscapeRoomObjects = new List<EscapeRoomObject>();
public List<int> escapeRoomNumbersHit = new List<int>();
public LocalVolumetricFog localVolumetricFog;
public ThingEnemyAI ThingEnemyAI;
private LightInformation _playerNightVision;
private float _lightAnimationsTimer;
private float _scaryAmbientAnimationTimer = 90f;
private bool _scarySoundPlayed;
private bool _hasEscaped;
private int escapeObjectToHit = 2;
private int escapeObjectHitCount;
public void Start()
{
_scaryAmbientAnimationTimer = TheThingPlugin.instance.TimeToEscapeRoom.Value - 22f;
escapeObjectToHit = TheThingPlugin.instance.monsterToHitToEscapeRoom.Value;
localVolumetricFog.parameters.meanFreePath = TheThingPlugin.instance.roomFogDistance.Value;
}
public void OnPlayerSpawnIntoRoom()
{
ambientSource.PlayOneShot(welcomeSound);
GetAllLights();
DisableEveryEscapeObject();
EnableRandomEscapeObject(0);
}
public void DisableEveryEscapeObject()
{
int i = 0;
EscapeRoomObjects.ForEach(delegate(EscapeRoomObject o)
{
o.id = i;
i++;
((Component)o).gameObject.SetActive(false);
});
}
public void Update()
{
_lightAnimationsTimer -= Time.deltaTime;
_scaryAmbientAnimationTimer -= Time.deltaTime;
if (_lightAnimationsTimer < 0f && _scaryAmbientAnimationTimer >= 0f)
{
_lightAnimationsTimer = Random.Range(4, 7);
((MonoBehaviour)this).StartCoroutine(LightAnimation());
}
if (_scaryAmbientAnimationTimer < 0f && !_scarySoundPlayed && escapeObjectHitCount < escapeObjectToHit)
{
_scarySoundPlayed = true;
ambientSource.PlayOneShot(scaryAmbientSound);
((MonoBehaviour)this).StartCoroutine(OnScaryAmbientRunned());
}
if (Object.op_Implicit((Object)(object)ThingEnemyAI) && ThingEnemyAI.playerToKillIsLocal && GameNetworkManager.Instance.localPlayerController.isPlayerDead && !_hasEscaped)
{
_hasEscaped = true;
NetworkThing.EscapeRoomServerRpc();
}
}
private IEnumerator OnScaryAmbientRunned()
{
yield return (object)new WaitForSeconds(22f);
GetAllLights();
LightsManagement(active: false, lights);
DisableEveryEscapeObject();
ambientSource.PlayOneShot(welcomeSound);
if (Object.op_Implicit((Object)(object)ThingEnemyAI) && ThingEnemyAI.playerToKillIsLocal)
{
GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.8f, true);
}
yield return (object)new WaitForSeconds(4f);
if (Object.op_Implicit((Object)(object)ThingEnemyAI))
{
ThingEnemyAI.MonsterAttackPlayer();
}
lights.Clear();
((MonoBehaviour)this).StopCoroutine(LightAnimation());
}
private IEnumerator LightAnimation()
{
if (lights.Count <= 0 || !Object.op_Implicit((Object)(object)lights?[0].Light))
{
yield return null;
}
List<LightInformation> lightsAnimated = new List<LightInformation>();
lights.ForEach(delegate(LightInformation l)
{
if (Random.Range(0, 3) == 0)
{
lightsAnimated.Add(l);
}
});
LightsManagement(active: false, lightsAnimated);
yield return (object)new WaitForSeconds(0.5f);
LightsManagement(active: true, lightsAnimated);
yield return (object)new WaitForSeconds(0.5f);
LightsManagement(active: false, lightsAnimated);
yield return (object)new WaitForSeconds(0.8f);
LightsManagement(active: true, lightsAnimated);
yield return (object)new WaitForSeconds(0.2f);
LightsManagement(active: false, lightsAnimated);
yield return (object)new WaitForSeconds(1f);
LightsManagement(active: true, lightsAnimated);
}
public Color GetRandomRedColor()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
return new Color(Random.Range(0.3f, 0.75f), 0f, 0f, 1f);
}
public void LightsManagement(bool active, List<LightInformation> lightsInfos)
{
lightsInfos.ForEach(delegate(LightInformation l)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)l.Light != (Object)null)
{
l.Light.color = (active ? GetRandomRedColor() : Color.black);
}
});
}
public void GetAllLights()
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
lights.Clear();
List<Light> list = Object.FindObjectsByType<Light>((FindObjectsInactive)1, (FindObjectsSortMode)0).ToList().FindAll((Light light) => Vector3.Distance(((Component)light).transform.position, ((Component)this).transform.position) < 150f && Vector3.Distance(new Vector3(0f, ((Component)light).transform.position.y, 0f), new Vector3(0f, ((Component)this).transform.position.y, 0f)) < 25f && Object.op_Implicit((Object)(object)light));
foreach (Light item in list)
{
if (!((Object)(object)((Component)item).GetComponentInParent<animatedSun>() != (Object)null) && !(((Object)((Component)item).transform.parent).name == "HelmetLights") && !((Object)(object)item == (Object)(object)ThingEnemyAI.redLight) && !((Object)((Component)item).transform.parent).name.Contains("EscapeObject") && !((Object)item).name.Contains("Spot Light") && !((Object)item).name.Contains("RedLight") && !((Object)item).name.Contains("RadarCamNightVision") && !((Object)item).name.Contains("Near") && !((Object)item).name.Contains("VisorCamera") && !((Object)item).name.Contains("MainCamera"))
{
FlashlightItem componentInParent = ((Component)item).GetComponentInParent<FlashlightItem>();
LightInformation lightInformation = new LightInformation();
lightInformation.Light = item;
lightInformation.color = item.color;
lightInformation.intensity = item.intensity;
lightInformation.flashlightItem = componentInParent;
if (((Object)item).name == "NightVision")
{
_playerNightVision = lightInformation;
}
else
{
lights.Add(lightInformation);
}
}
}
}
public void EnableRandomEscapeObject(int notId)
{
if (ThingEnemyAI.playerToKillIsLocal)
{
int num = Random.Range(0, EscapeRoomObjects.Count);
while (num == notId || escapeRoomNumbersHit.Contains(num))
{
num = Random.Range(0, EscapeRoomObjects.Count);
}
NetworkThing.EnableEscapeObjectServerRpc(num);
escapeRoomNumbersHit.Add(num);
}
}
public void EnableEscapeObject(int id)
{
((Component)EscapeRoomObjects[id]).gameObject.SetActive(true);
}
public IEnumerator OnEscaped()
{
_hasEscaped = true;
((MonoBehaviour)this).StopCoroutine(LightAnimation());
((MonoBehaviour)this).StopCoroutine(OnScaryAmbientRunned());
LightsManagement(active: false, lights);
ambientSource.PlayOneShot(welcomeSound);
yield return (object)new WaitForSeconds(4f);
if (Object.op_Implicit((Object)(object)ThingEnemyAI))
{
ThingEnemyAI.CancelMonsterAttack();
}
}
public void OnHitEscapeObject(int id)
{
escapeObjectHitCount++;
if (escapeObjectHitCount == escapeObjectToHit)
{
NetworkThing.EscapeRoomServerRpc();
}
else
{
EnableRandomEscapeObject(id);
}
}
}
}