using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Debugger;
using GameNetcodeStuff;
using HarmonyLib;
using HideAndSeek;
using HideAndSeek.Patches;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
[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("HideAndSeek")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HideAndSeek")]
[assembly: AssemblyTitle("HideAndSeek")]
[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;
}
}
}
public class NetworkHandler : NetworkBehaviour
{
public static LethalClientMessage<string> NetworkMessage = new LethalClientMessage<string>("HASMessage", (Action<string>)null, (Action<string, ulong>)null);
public static NetworkHandler Instance { get; private set; }
public static event Action<string, MessageProperties> NetworkEvent;
public override void OnNetworkSpawn()
{
NetworkHandler.NetworkEvent = null;
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
NetworkHandler instance = Instance;
if (instance != null)
{
((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
}
}
Instance = this;
((NetworkBehaviour)this).OnNetworkSpawn();
NetworkEvent += SyncingPatch.LevelLoading;
NetworkEvent += SyncingPatch.LevelLoaded;
NetworkEvent += SyncingPatch.PlayerChosen;
NetworkEvent += SyncingPatch.LockDoor;
NetworkEvent += SyncingPatch.OpenDoor;
NetworkEvent += SyncingPatch.PlayerTeleported;
NetworkEvent += SyncingPatch.DisplayTip;
Debugger.Debug.LogMessage("Connecting events....");
NetworkMessage.OnReceivedFromClient += EventRecivedRpc;
}
public void EventSendRpc(string eventName, MessageProperties message = null)
{
if (message != null)
{
NetworkHandler.NetworkEvent?.Invoke(eventName, message);
}
else
{
NetworkHandler.NetworkEvent?.Invoke(eventName, new MessageProperties());
}
Debugger.Debug.LogMessage("[Server] Event! + " + eventName + " Info: " + message);
string text = eventName + "|" + JsonUtility.ToJson((object)message);
NetworkMessage.SendAllClients(text, false, false);
}
public void EventRecivedRpc(string data, ulong playerID)
{
string text = data.Split("|")[0];
string text2 = data.Split("|")[1];
MessageProperties messageProperties = (MessageProperties)JsonUtility.FromJson(text2, typeof(MessageProperties));
if (messageProperties != null)
{
NetworkHandler.NetworkEvent?.Invoke(text, messageProperties);
}
else
{
NetworkHandler.NetworkEvent?.Invoke(text, new MessageProperties());
}
Debugger.Debug.LogMessage("[Client] Event! + " + text + " Info: " + messageProperties?.ToString() + " Raw Data: " + data);
}
}
namespace Debugger
{
public static class Debug
{
public static void Log(object m)
{
if (Config.debugEnabled.Value)
{
Plugin._Logger.LogInfo(m);
}
}
public static void LogMessage(object m)
{
if (Config.debugEnabled.Value)
{
Plugin._Logger.LogMessage(m);
}
}
public static void LogWarning(object m)
{
if (Config.debugEnabled.Value)
{
Plugin._Logger.LogWarning(m);
}
}
public static void LogError(object m)
{
if (Config.debugEnabled.Value)
{
Plugin._Logger.LogError(m);
}
}
}
}
namespace HideAndSeek
{
public class Config
{
public static ConfigEntry<bool> debugEnabled;
public static ConfigEntry<bool> circuitBeeEnabled;
public static ConfigEntry<bool> manticoilEnabled;
public static ConfigEntry<bool> roamingLocustEnabled;
public static ConfigEntry<bool> baboonHawkEnabled;
public static ConfigEntry<bool> earthLeviathanEnabled;
public static ConfigEntry<bool> eyelessDogEnabled;
public static ConfigEntry<bool> forestKeeperEnabled;
public static ConfigEntry<bool> tulipSnakeEnabled;
public static ConfigEntry<bool> mechEnabled;
public static ConfigEntry<bool> brackenEnabled;
public static ConfigEntry<bool> bunkerSpiderEnabled;
public static ConfigEntry<bool> coilHeadEnabled;
public static ConfigEntry<bool> ghostGirlEnabled;
public static ConfigEntry<bool> hoardingBugEnabled;
public static ConfigEntry<bool> hygrodereEnabled;
public static ConfigEntry<bool> jesterEnabled;
public static ConfigEntry<bool> maskedEnabled;
public static ConfigEntry<bool> nutcrackerEnabled;
public static ConfigEntry<bool> snareFleaEnabled;
public static ConfigEntry<bool> sporeLizardEnabled;
public static ConfigEntry<bool> thumperEnabled;
public static ConfigEntry<bool> butlerEnabled;
public static ConfigEntry<bool> turretsEnabled;
public static ConfigEntry<bool> landminesEnabled;
public static ConfigEntry<bool> spikeTrapEnabled;
public static ConfigEntry<string> seekerChooseBehavior;
public static ConfigEntry<bool> isSeekerImmune;
public static ConfigEntry<bool> hostilesIgnoreSeeker;
public static ConfigEntry<bool> shotgunInfiniteAmmo;
public static ConfigEntry<bool> shotgunAutoReload;
public static ConfigEntry<bool> teleportSeekerToEntrance;
public static ConfigEntry<bool> forceSeekerInside;
public static ConfigEntry<float> timeSeekerIsReleased;
public static ConfigEntry<string> seekerItemSlot1;
public static ConfigEntry<string> seekerItemSlot2;
public static ConfigEntry<string> seekerItemSlot3;
public static ConfigEntry<string> seekerItemSlot4;
public static ConfigEntry<bool> teleportHidersToEntrance;
public static ConfigEntry<bool> forceHidersInside;
public static ConfigEntry<bool> lockHidersInside;
public static ConfigEntry<string> hiderItemSlot1;
public static ConfigEntry<string> hiderItemSlot2;
public static ConfigEntry<string> hiderItemSlot3;
public static ConfigEntry<string> hiderItemSlot4;
public Config(ConfigFile cfg)
{
debugEnabled = cfg.Bind<bool>("0:Debug/Other", "DebugEnabled", false, "Used for random feature testing and debug logging. (Should be disabled for end user)");
circuitBeeEnabled = cfg.Bind<bool>("1:Entities.Daytime", "Spawn Circut Bees", false, "Determines if Circuit Bees should spawn.");
manticoilEnabled = cfg.Bind<bool>("1:Entities.Daytime", "Spawn Manticoils", true, "Determines if Manticoils should spawn.");
roamingLocustEnabled = cfg.Bind<bool>("1:Entities.Daytime", "Spawn Roaming Locusts", true, "Determines if Roaming Locusts should spawn.");
eyelessDogEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Eyeless Dogs", false, "Determines if Eyeless Dogs should spawn.");
forestKeeperEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Forest Keepers", false, "Determines if Forest Keepers should spawn.");
earthLeviathanEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Earth Leviathans", false, "Determines if Earth Leviathans should spawn.");
baboonHawkEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Baboon Hawks", false, "Determines if Baboon Hawks should spawn.");
tulipSnakeEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Tulip Snakes", false, "Determines if Tulip Snakes should spawn.");
mechEnabled = cfg.Bind<bool>("1:Entities.Outside", "Spawn Old Bird", false, "Determines if Old Birds should spawn.");
brackenEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Brackens", false, "Determines if Brackens should spawn.");
bunkerSpiderEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Bunker Spiders", false, "Determines if Bunker Spiders should spawn.");
coilHeadEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Coil Heads", false, "Determines if Coil Heads should spawn.");
ghostGirlEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Ghost Girls", false, "Determines if Ghost Girls should spawn.");
hoardingBugEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Hoarding Bugs", false, "Determines if Hoarding Bugs should spawn.");
hygrodereEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Hygroderes (Slimes)", false, "Determines if Hygroderes (Slimes) should spawn.");
jesterEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Jesters", false, "Determines if Jesters should spawn.");
maskedEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Masked (Player Mimics)", false, "Determines if Masked (Player Mimics) should spawn.");
nutcrackerEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Nutcrackers", false, "Determines if Nutcrackers should spawn.");
snareFleaEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Snare Fleas", false, "Determines if Snare Fleas should spawn.");
sporeLizardEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Spore Lizards", false, "Determines if Spore Lizards should spawn.");
thumperEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Thumpers", false, "Determines if Thumpers should spawn.");
butlerEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Butlers", false, "Determines if Butlers should spawn.");
turretsEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Turrets", false, "Determines if Turrets should spawn.");
landminesEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Land Mines", false, "Determines if Land Mines should spawn.");
spikeTrapEnabled = cfg.Bind<bool>("1:Entities.Indoor", "Spawn Spike Traps", false, "Determines if Spike Traps should spawn.");
seekerChooseBehavior = cfg.Bind<string>("2:Players.Seeker", "Seeker Choose Behavior", "Turns", "'None' (Just a random range generator), 'No Double' (Next Seeker can't be last seeker), 'Turns' (Will not pick someone that was already seeker, resets when everyone got a chance), 'Lever' (WIP DOES NOT WORK; The seeker is the lever puller)");
isSeekerImmune = cfg.Bind<bool>("2:Players.Seeker", "Is Seeker Immune", false, "Determines if the seeker could be harmed or not (god mode basically)");
hostilesIgnoreSeeker = cfg.Bind<bool>("2:Players.Seeker", "Is Seeker Ignored", true, "(To be implemented!) Determines if the seeker should be ignored by hostiles or not.");
shotgunInfiniteAmmo = cfg.Bind<bool>("2:Players.Seeker", "Shotgun Infinite Ammo", true, "Disables the need for ammo for the shotgun.");
shotgunAutoReload = cfg.Bind<bool>("2:Players.Seeker", "Shotgun Auto Reload", false, "(Only works if 'shotgunInfiniteAmmo' is enabled) Disables the need to reload a new shell, and lets you shoot like normal again.");
timeSeekerIsReleased = cfg.Bind<float>("2:Players.Seeker", "Seeking Time", 195f, "The time the seeker is released to wreak havoc in the land. 180 = 9:00 PM, 240 = 10:00 PM, +60 = +1 hour");
teleportSeekerToEntrance = cfg.Bind<bool>("2:Players.Seeker", "Teleport Seeker To Entrance", false, "Determines if the seeker should be teleported to the entrance on landing.");
forceSeekerInside = cfg.Bind<bool>("2:Players.Seeker", "Teleport Seeker Inside", false, "Determines if the seeker should be teleported into the building on landing. (teleportSeekerToEntrance Should Be Enabled!)");
seekerItemSlot1 = cfg.Bind<string>("2:Players.Seeker", "Seeker Item Slot 1", "Shotgun", "The id of the item that will spawn in the first slot of the seeker. (See README.md for list of Item IDs)");
seekerItemSlot2 = cfg.Bind<string>("2:Players.Seeker", "Seeker Item Slot 2", "", "The id of the item that will spawn in the second slot of the seeker. (See README.md for list of Item IDs)");
seekerItemSlot3 = cfg.Bind<string>("2:Players.Seeker", "Seeker Item Slot 3", "", "The id of the item that will spawn in the third slot of the seeker. (See README.md for list of Item IDs)");
seekerItemSlot4 = cfg.Bind<string>("2:Players.Seeker", "Seeker Item Slot 4", "", "The id of the item that will spawn in the fourth slot of the seeker. (See README.md for list of Item IDs)");
teleportHidersToEntrance = cfg.Bind<bool>("2:Players.Hider", "Teleport Hiders To Entrance", true, "Determines if all the hiders should be teleported to the entrance on landing.");
forceHidersInside = cfg.Bind<bool>("2:Players.Hider", "Teleport Hiders Inside", true, "Determines if all the hiders should be teleported into the building on landing. (teleportHidersToEntrance Should Be Enabled!)");
lockHidersInside = cfg.Bind<bool>("2:Players.Hider", "Lock Hiders Inside", true, "Determines if all the hiders should be locked inside the building. (forceHidersInside Should Be Enabled!)");
hiderItemSlot1 = cfg.Bind<string>("2:Players.Hider", "Hider Item Slot 1", "Pro-flashlight", "The id of the item that will spawn in the first slot of the hider. (See README.md for list of Item IDs)");
hiderItemSlot2 = cfg.Bind<string>("2:Players.Hider", "Hider Item Slot 2", "", "The id of the item that will spawn in the second slot of the hider. (See README.md for list of Item IDs)");
hiderItemSlot3 = cfg.Bind<string>("2:Players.Hider", "Hider Item Slot 3", "", "The id of the item that will spawn in the third slot of the hider. (See README.md for list of Item IDs)");
hiderItemSlot4 = cfg.Bind<string>("2:Players.Hider", "Hider Item Slot 4", "", "The id of the item that will spawn in the fourth slot of the hider. (See README.md for list of Item IDs)");
}
}
[BepInPlugin("gogozooom.HideAndSeek", "Hide And Seek", "1.1.3")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "gogozooom.HideAndSeek";
public const string PLUGIN_NAME = "Hide And Seek";
public const string PLUGIN_VERSION = "1.1.3";
public static ManualLogSource _Logger;
public static Plugin instance;
public static Config _Config;
public static PlayerControllerB seekerPlayer;
public static AssetBundle MainAssetBundle;
private readonly Harmony harmony = new Harmony("gogozooom.HideAndSeek");
private void Awake()
{
instance = this;
_Logger = ((BaseUnityPlugin)this).Logger;
_Config = new Config(((BaseUnityPlugin)this).Config);
Debug.Log((object)"Patching .RoundManagerPatch");
harmony.PatchAll(typeof(RoundManagerPatch));
Debug.Log((object)"Patching .TurretPatch");
harmony.PatchAll(typeof(TurretPatch));
Debug.Log((object)"Patching .LandminePatch");
harmony.PatchAll(typeof(LandminePatch));
Debug.Log((object)"Patching .SpikeRoofTrapPatch");
harmony.PatchAll(typeof(SpikeRoofTrapPatch));
Debug.Log((object)"Patching .ShotgunPatch");
harmony.PatchAll(typeof(ShotgunPatch));
Debug.Log((object)"Patching .PlayerControllerBPatch");
harmony.PatchAll(typeof(PlayerControllerBPatch));
Debug.Log((object)"Patching .EntranceTeleportPatch");
harmony.PatchAll(typeof(EntranceTeleportPatch));
Debug.Log((object)"Patching .TerminalPatch");
harmony.PatchAll(typeof(TerminalPatch));
Debug.Log((object)"Patching .TimeOfDayPatch");
harmony.PatchAll(typeof(TimeOfDayPatch));
Debug.Log((object)"Patching .HUDManagerPatch");
harmony.PatchAll(typeof(HUDManagerPatch));
Debug.Log((object)"Patching .GameNetworkManagerPatch");
harmony.PatchAll(typeof(GameNetworkManagerPatch));
Debug.Log((object)"Patching .StartOfRoundPatch");
harmony.PatchAll(typeof(StartOfRoundPatch));
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "networkhandler");
MainAssetBundle = AssetBundle.LoadFromFile(text);
_Logger.LogInfo((object)"Plugin gogozooom.HideAndSeek is loaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HideAndSeek";
public const string PLUGIN_NAME = "HideAndSeek";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HideAndSeek.Patches
{
[HarmonyPatch(typeof(RoundManager))]
public class RoundManagerPatch
{
public static RoundManager instance;
public static int playersTeleported;
public static int playersAlive;
public static List<(ulong playerId, Vector3 position)> itemSpawnPositions = new List<(ulong, Vector3)>();
public static bool levelLoading = false;
public static ulong lastSeekerId = 10001uL;
public static List<ulong> pastSeekers = new List<ulong>();
public static List<ulong> curretPool = new List<ulong>();
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePatch()
{
if (!Object.op_Implicit((Object)(object)GameNetworkManager.Instance.localPlayerController) || !((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsServer)
{
return;
}
int livingPlayers = StartOfRound.Instance.livingPlayers;
if (playersAlive < livingPlayers)
{
Debugger.Debug.LogWarning("Player count reset to: " + livingPlayers);
playersAlive = livingPlayers;
}
else if (playersAlive > livingPlayers)
{
Debugger.Debug.LogWarning("Player died! New Count: " + livingPlayers);
playersAlive = livingPlayers;
if (TimeOfDay.Instance.currentDayTime != 0f)
{
PlayerDied("Player Died!", livingPlayers);
}
}
}
[HarmonyPatch("LoadNewLevel")]
[HarmonyPrefix]
private static bool LoadLevelPatch(ref int randomSeed, ref SelectableLevel newLevel)
{
Debugger.Debug.LogMessage("[LoadLevelPatch] LoadLevel Start!");
if (levelLoading)
{
Debugger.Debug.LogError("levelLoading is true! This should be abnormal!");
return false;
}
levelLoading = true;
instance = Object.FindObjectOfType<RoundManager>();
NetworkHandler.Instance.EventSendRpc(".teleported", new MessageProperties
{
_bool = true
});
playersTeleported = 0;
SyncingPatch.TeleportPlayer();
if (!GameNetworkManager.Instance.isHostingGame)
{
return true;
}
NetworkHandler.Instance.EventSendRpc(".levelLoading");
foreach (SpawnableEnemyWithRarity daytimeEnemy in newLevel.DaytimeEnemies)
{
Debugger.Debug.Log("Checking DaytimeEnemey: " + daytimeEnemy.enemyType.enemyName);
switch (daytimeEnemy.enemyType.enemyName)
{
case "Red Locust Bees":
if (!Config.circuitBeeEnabled.Value)
{
daytimeEnemy.rarity = 0;
}
break;
case "Manticoil":
if (!Config.manticoilEnabled.Value)
{
daytimeEnemy.rarity = 0;
}
break;
case "Docile Locust Bees":
if (!Config.roamingLocustEnabled.Value)
{
daytimeEnemy.rarity = 0;
}
break;
}
Debugger.Debug.Log(daytimeEnemy.enemyType.enemyName + ".Rarity = " + daytimeEnemy.rarity);
}
foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
{
Debugger.Debug.Log("Checking OutsideEnemey: " + outsideEnemy.enemyType.enemyName);
switch (outsideEnemy.enemyType.enemyName)
{
case "MouthDog":
if (!Config.eyelessDogEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
case "ForestGiant":
if (!Config.forestKeeperEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
case "Baboon hawk":
if (!Config.baboonHawkEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
case "Earth Leviathan":
if (!Config.earthLeviathanEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
case "RadMech":
if (!Config.mechEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
case "Tulip Snake":
if (!Config.tulipSnakeEnabled.Value)
{
outsideEnemy.rarity = 0;
}
break;
}
Debugger.Debug.Log(outsideEnemy.enemyType.enemyName + ".Rarity = " + outsideEnemy.rarity);
}
foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
{
Debugger.Debug.Log("Checking Enemey: " + enemy.enemyType.enemyName);
switch (enemy.enemyType.enemyName)
{
case "Centipede":
if (!Config.snareFleaEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Bunker Spider":
if (!Config.bunkerSpiderEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Hoarding bug":
if (!Config.hoardingBugEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Flowerman":
if (!Config.brackenEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Crawler":
if (!Config.thumperEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Blob":
if (!Config.hygrodereEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Girl":
if (!Config.ghostGirlEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Puffer":
if (!Config.sporeLizardEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Nutcracker":
if (!Config.nutcrackerEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Jester":
if (!Config.jesterEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Spring":
if (!Config.coilHeadEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Masked":
if (!Config.maskedEnabled.Value)
{
enemy.rarity = 0;
}
break;
case "Butler":
if (!Config.butlerEnabled.Value)
{
enemy.rarity = 0;
}
break;
}
Debugger.Debug.Log(enemy.enemyType.enemyName + ".Rarity = " + enemy.rarity);
}
List<PlayerControllerB> list = new List<PlayerControllerB>();
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val in array)
{
if (val.isPlayerControlled)
{
Debugger.Debug.LogMessage("Found " + ((Object)val).name + "! Adding to active list.");
list.Add(val);
}
}
Plugin.seekerPlayer = PickRandomSeeker();
Debugger.Debug.LogMessage("Seeker Chosen: " + Plugin.seekerPlayer.playerUsername);
HUDManager.Instance.DisplayTip("Hide And Seek", "Seeker Chosen [" + Plugin.seekerPlayer.playerUsername + "]", false, false, "LC_Tip1");
NetworkHandler.Instance.EventSendRpc(".playerChosen", new MessageProperties
{
_ulong = ((NetworkBehaviour)Plugin.seekerPlayer).NetworkObjectId
});
itemSpawnPositions.Clear();
((MonoBehaviour)instance).StartCoroutine(GivePlayersItems());
levelLoading = false;
NetworkHandler.Instance.EventSendRpc(".levelLoaded", new MessageProperties());
return true;
}
public static PlayerControllerB PickRandomSeeker()
{
string text = Config.seekerChooseBehavior.Value.ToLower().Trim().Replace(" ", "");
ulong num = 10001uL;
Debugger.Debug.Log("Random Type ['" + text + "']");
if (text == "nodouble")
{
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val in array)
{
Debugger.Debug.Log($"Searching {val}, {val.isPlayerControlled}, {val.actualClientId}");
if (val.isPlayerControlled)
{
Debugger.Debug.Log($"Added {val}!");
curretPool.Add(val.actualClientId);
}
}
while (num == 10001 || num == lastSeekerId)
{
int index = Random.Range(0, curretPool.Count);
Debugger.Debug.Log("[NoDouble] RandomPlayerNumber = " + index);
num = curretPool[index];
if (GameNetworkManager.Instance.connectedPlayers == 1)
{
break;
}
}
}
else if (text == "turns")
{
PlayerControllerB[] array2 = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val2 in array2)
{
if (!curretPool.Contains(val2.actualClientId) && !pastSeekers.Contains(val2.actualClientId))
{
curretPool.Add(val2.actualClientId);
}
if (curretPool.Contains(val2.actualClientId) && !val2.isPlayerControlled && !val2.isPlayerDead)
{
curretPool.Remove(val2.actualClientId);
}
}
if (curretPool.Count == 0)
{
PlayerControllerB[] array3 = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val3 in array3)
{
if (val3.isPlayerControlled)
{
curretPool.Add(val3.actualClientId);
}
}
pastSeekers.Clear();
}
int index2 = Random.Range(0, curretPool.Count);
Debugger.Debug.Log("[Turns] RandomPlayerNumber = " + index2);
num = curretPool[index2];
if (curretPool.Contains(num))
{
curretPool.Remove(num);
pastSeekers.Add(num);
}
Debugger.Debug.LogWarning("---- New Pools! ----");
Debugger.Debug.LogWarning("CurrentPool = ");
Debugger.Debug.Log(curretPool.ToArray());
Debugger.Debug.LogWarning("PastSeekers = ");
Debugger.Debug.Log(pastSeekers.ToArray());
}
else
{
PlayerControllerB[] array4 = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val4 in array4)
{
if (val4.isPlayerControlled)
{
curretPool.Add(val4.actualClientId);
}
}
int index3 = Random.Range(0, curretPool.Count);
Debugger.Debug.Log("[Random] RandomPlayerNumber = " + index3);
num = curretPool[index3];
}
PlayerControllerB playerWithClientId = GetPlayerWithClientId(num);
if ((Object)(object)playerWithClientId == (Object)null)
{
playerWithClientId = GetPlayerWithClientId(0uL);
}
lastSeekerId = num;
return playerWithClientId;
}
public static PlayerControllerB GetPlayerWithClientId(ulong playerId)
{
PlayerControllerB val = null;
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val2 in array)
{
if (val2.actualClientId == playerId && val2.isPlayerControlled)
{
val = val2;
break;
}
}
Debugger.Debug.Log($"Got player '{val}' with '{playerId}'");
return val;
}
public static void PlayerDied(string reason = "", int aPC = -1, bool checking = false)
{
int num = aPC;
if (num == -1)
{
num = StartOfRound.Instance.livingPlayers;
}
if (checking)
{
Debugger.Debug.Log($"Checking dead people... Seeker dead: {Plugin.seekerPlayer.isPlayerDead} Alive hider count: {num - 1} Is ship leaving: {StartOfRound.Instance.shipIsLeaving}");
}
if (StartOfRound.Instance.shipIsLeaving)
{
return;
}
StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
if (Plugin.seekerPlayer.isPlayerDead)
{
if (!checking)
{
NetworkHandler.Instance.EventSendRpc(".tip", new MessageProperties
{
_string = "Seeker Died; Hiders Win!",
_bool = true
});
}
Debugger.Debug.LogMessage("_________ SEEKER DIED! _________");
val.EndGame();
val.LeverAnimation();
return;
}
if (!checking)
{
Debugger.Debug.LogMessage("_________ PLAYER DIED! _________");
}
if (num == 1 && GameNetworkManager.Instance.connectedPlayers != 1)
{
if (!checking)
{
NetworkHandler.Instance.EventSendRpc(".tip", new MessageProperties
{
_string = "Seeker Won!",
_bool = true
});
}
Debugger.Debug.LogMessage($"_________ SEEKER WON! _________ {GameNetworkManager.Instance.connectedPlayers} Connected player amount. != 1?: {StartOfRound.Instance.connectedPlayersAmount != 1} ");
val.EndGame();
val.LeverAnimation();
}
else if (num > 1 && !checking)
{
NetworkHandler.Instance.EventSendRpc(".tip", new MessageProperties
{
_string = $"{num - 1} Hiders Remain..."
});
}
if (!checking)
{
Debugger.Debug.LogMessage($"_________ ({num}) Players Left! _________");
}
}
public static IEnumerator GivePlayersItems()
{
List<PlayerControllerB> players = new List<PlayerControllerB>();
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB player in array)
{
if (player.isPlayerControlled)
{
players.Add(player);
}
}
Debugger.Debug.LogMessage("Game Has Started = " + GameNetworkManager.Instance.gameHasStarted);
while (itemSpawnPositions.Count == 0 || playersTeleported == 0 || !StartOfRound.Instance.shipHasLanded)
{
if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost)
{
PlayerDied("Before Item Give", -1, checking: true);
}
if (StartOfRound.Instance.shipIsLeaving)
{
yield break;
}
Debugger.Debug.Log($"[Progress] Players Teleported: {playersTeleported}, item Spawn Positions: {itemSpawnPositions.Count}");
yield return (object)new WaitForSeconds(1f);
}
int tries = 5;
while ((itemSpawnPositions.Count < players.Count || playersTeleported < players.Count || !StartOfRound.Instance.shipHasLanded) && tries > 0)
{
Debugger.Debug.Log($"[Progress Inter] Not fully there! We have: {tries} left before ending automatically! {playersTeleported}, {itemSpawnPositions.Count}");
yield return (object)new WaitForSeconds(1f);
tries--;
}
Debugger.Debug.Log($"[Final] Players Teleported: {playersTeleported}, item Spawn Positions: {itemSpawnPositions.Count}");
foreach (PlayerControllerB player2 in players)
{
if ((Object)(object)player2 == (Object)(object)Plugin.seekerPlayer)
{
if (!string.IsNullOrEmpty(Config.seekerItemSlot1.Value))
{
SpawnNewItem(Config.seekerItemSlot1.Value, player2);
}
if (!string.IsNullOrEmpty(Config.seekerItemSlot2.Value))
{
SpawnNewItem(Config.seekerItemSlot2.Value, player2);
}
if (!string.IsNullOrEmpty(Config.seekerItemSlot3.Value))
{
SpawnNewItem(Config.seekerItemSlot3.Value, player2);
}
if (!string.IsNullOrEmpty(Config.seekerItemSlot4.Value))
{
SpawnNewItem(Config.seekerItemSlot4.Value, player2);
}
}
else
{
if (!string.IsNullOrEmpty(Config.hiderItemSlot1.Value))
{
SpawnNewItem(Config.hiderItemSlot1.Value, player2);
}
if (!string.IsNullOrEmpty(Config.hiderItemSlot2.Value))
{
SpawnNewItem(Config.hiderItemSlot2.Value, player2);
}
if (!string.IsNullOrEmpty(Config.hiderItemSlot3.Value))
{
SpawnNewItem(Config.hiderItemSlot3.Value, player2);
}
if (!string.IsNullOrEmpty(Config.hiderItemSlot4.Value))
{
SpawnNewItem(Config.hiderItemSlot4.Value, player2);
}
}
}
}
public static GrabbableObject SpawnNewItem(string itemName, PlayerControllerB player)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
Debugger.Debug.LogMessage("SpawnNewItem()!");
Item[] array = Resources.FindObjectsOfTypeAll<Item>();
int num = 0;
Item[] array2 = array;
foreach (Item val in array2)
{
if (val.itemName.ToLower().Trim() == itemName.ToLower().Trim())
{
break;
}
num++;
}
if (num == array.Length)
{
Debugger.Debug.LogWarning("Could not find " + itemName + " in items id list! (Look at README.md to see item IDs)");
return null;
}
Vector3 val2 = ((Component)player).transform.position;
bool flag = false;
Debugger.Debug.Log($"Spawing Item with spawn positions: {itemSpawnPositions.Count}");
foreach (var itemSpawnPosition in itemSpawnPositions)
{
Debugger.Debug.Log($"Scanning {itemSpawnPosition.playerId} with position {itemSpawnPosition.position}");
if (itemSpawnPosition.playerId == player.actualClientId)
{
flag = true;
val2 = itemSpawnPosition.position;
Debugger.Debug.Log($"New Item Spawn Position! {val2}");
}
}
if (!flag)
{
Debugger.Debug.LogError("Could not find Spawn Position for player");
}
val2 += Vector3.up * 0.3f;
GrabbableObject component = Object.Instantiate<GameObject>(array[num].spawnPrefab, val2, Quaternion.identity).GetComponent<GrabbableObject>();
component.fallTime = 0f;
((Component)component).GetComponent<NetworkObject>().Spawn(false);
Debugger.Debug.LogMessage($"Spawning {((Object)component).name} for {player.playerUsername} at position {((Component)component).transform.position}");
return component;
}
}
[HarmonyPatch(typeof(Turret))]
public class TurretPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(Turret __instance)
{
Debugger.Debug.LogWarning("Turret Found! Deleteing...");
if (!Config.turretsEnabled.Value)
{
((NetworkBehaviour)__instance).NetworkObject.Despawn(true);
Debugger.Debug.Log("Deleteing...");
}
}
}
[HarmonyPatch(typeof(Landmine))]
public class LandminePatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(Landmine __instance)
{
Debugger.Debug.LogWarning("Landmine Found!");
if (!Config.landminesEnabled.Value && GameNetworkManager.Instance.isHostingGame)
{
((NetworkBehaviour)__instance).NetworkObject.Despawn(true);
Debugger.Debug.Log("Deleteing...");
}
}
}
[HarmonyPatch(typeof(SpikeRoofTrap))]
public class SpikeRoofTrapPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(SpikeRoofTrap __instance)
{
Debugger.Debug.LogWarning("Spike Found! Deleteing...");
if (!Config.spikeTrapEnabled.Value)
{
((NetworkBehaviour)__instance).NetworkObject.Despawn(true);
Debugger.Debug.Log("Deleteing...");
}
}
}
[HarmonyPatch(typeof(ShotgunItem))]
public class ShotgunPatch
{
[HarmonyPatch("StartReloadGun")]
[HarmonyPrefix]
private static bool StartReloadGunPatch(ref int ___ammoSlotToUse, ref Animator ___gunAnimator, ref Coroutine ___gunCoroutine)
{
ShotgunItem val = null;
ShotgunItem[] array = Object.FindObjectsOfType<ShotgunItem>();
foreach (ShotgunItem val2 in array)
{
if ((Object)(object)val2.gunAnimator == (Object)(object)___gunAnimator)
{
val = val2;
break;
}
}
if (!Traverse.Create((object)val).Method("ReloadedGun", Array.Empty<object>()).GetValue<bool>() && !Config.shotgunInfiniteAmmo.Value)
{
val.gunAudio.PlayOneShot(val.noAmmoSFX);
return false;
}
if (!((NetworkBehaviour)val).IsOwner)
{
return false;
}
if (___gunCoroutine != null)
{
((MonoBehaviour)val).StopCoroutine(___gunCoroutine);
}
___gunCoroutine = ((MonoBehaviour)val).StartCoroutine(Traverse.Create((object)val).Method("reloadGunAnimation", Array.Empty<object>()).GetValue<IEnumerator>());
return false;
}
[HarmonyPatch("ItemActivate")]
[HarmonyPrefix]
private static void ItemActivatePatch(ref int ___shellsLoaded)
{
if (Config.shotgunAutoReload.Value && Config.shotgunInfiniteAmmo.Value)
{
___shellsLoaded = 2;
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class PlayerControllerBPatch
{
[HarmonyPatch("DestroyItemInSlotAndSync")]
[HarmonyPrefix]
private static bool DestroyItemInSlotAndSyncPatch(int itemSlot)
{
Debugger.Debug.LogMessage("DestroyItemAndSync + " + itemSlot);
if (itemSlot < 0)
{
Debugger.Debug.LogMessage("Item slot out of range!");
return false;
}
return true;
}
[HarmonyPatch("DamagePlayer")]
[HarmonyPrefix]
private static bool DamagePlayerPatch(CauseOfDeath causeOfDeath = 0)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
Debugger.Debug.LogMessage($"Damaged recived: {causeOfDeath}");
if ((Object)(object)Plugin.seekerPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
if ((int)causeOfDeath == 10)
{
return false;
}
if (Config.isSeekerImmune.Value)
{
return false;
}
if ((int)causeOfDeath == 7)
{
Debugger.Debug.LogMessage("You can't die to your own weapon!");
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(EntranceTeleport))]
public class EntranceTeleportPatch
{
[HarmonyPatch("TeleportPlayer")]
[HarmonyPrefix]
public static bool TeleportPlayerPatch()
{
List<PlayerControllerB> list = new List<PlayerControllerB>();
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val in array)
{
if (val.isPlayerControlled)
{
list.Add(val);
}
}
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
Debugger.Debug.Log($"Comparing {localPlayerController} to {Plugin.seekerPlayer}");
if ((Object)(object)localPlayerController != (Object)(object)Plugin.seekerPlayer && RoundManagerPatch.playersTeleported >= list.Count && Config.lockHidersInside.Value)
{
HUDManager.Instance.DisplayTip("???", "The entrance appears to be blocked.", false, false, "LC_Tip1");
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Terminal))]
public class TerminalPatch
{
[HarmonyPatch("RunTerminalEvents")]
[HarmonyPostfix]
private static void RunTerminalEvents(ref int ___groupCredits)
{
___groupCredits = 50000;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
public class TimeOfDayPatch
{
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPostfix]
public static void SetBuyingRateForDayPatch()
{
StartOfRound.Instance.companyBuyingRate = 1f;
}
}
[HarmonyPatch(typeof(HUDManager))]
public class HUDManagerPatch
{
public static int CurrentRound = 1;
[HarmonyPatch("DisplayDaysLeft")]
[HarmonyPostfix]
public static void DisplayDaysLeftPatch()
{
((TMP_Text)HUDManager.Instance.profitQuotaDaysLeftText).text = $"Round {CurrentRound}";
((TMP_Text)HUDManager.Instance.profitQuotaDaysLeftText2).text = $"Round {CurrentRound}";
TimeOfDay.Instance.timeUntilDeadline = (int)(TimeOfDay.Instance.totalTime * (float)TimeOfDay.Instance.quotaVariables.deadlineDaysAmount);
((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = $"Round:\n {CurrentRound}";
CurrentRound++;
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
public class GameNetworkManagerPatch
{
public static GameObject networkPrefab;
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = (GameObject)Plugin.MainAssetBundle.LoadAsset("NetworkHandler");
networkPrefab.AddComponent<NetworkHandler>();
NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
}
}
[HarmonyPatch("ConnectionApproval")]
[HarmonyPostfix]
private static void ConnectionApprovalPatch()
{
Debugger.Debug.Log($"Joining Instance! Are we host? {GameNetworkManager.Instance.isHostingGame}");
if (GameNetworkManager.Instance.isHostingGame)
{
RoundManagerPatch.curretPool.Clear();
RoundManagerPatch.pastSeekers.Clear();
RoundManagerPatch.itemSpawnPositions.Clear();
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void SpawnNetworkHandler()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(GameNetworkManagerPatch.networkPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
}
}
public class MessageProperties
{
public bool _null = true;
public bool _bool = false;
public string _string = "";
public int _int = 0;
public float _float = 0f;
public ulong _ulong = 0uL;
public Vector3 _Vector3 = Vector3.zero;
}
internal class SyncingPatch
{
public static void LevelLoading(string eventName, MessageProperties mProps = null)
{
if (!(eventName != ".levelLoading"))
{
Debugger.Debug.LogMessage("Got LevelLoading Broadcast!");
RoundManager.Instance.LoadNewLevel(StartOfRound.Instance.randomMapSeed, StartOfRound.Instance.currentLevel);
}
}
public static void PlayerChosen(string eventName, MessageProperties mProps)
{
if (eventName != ".playerChosen")
{
return;
}
Debugger.Debug.LogMessage("Got PlayerChosen Broadcast!");
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
foreach (PlayerControllerB val in array)
{
if (((NetworkBehaviour)val).NetworkObjectId == mProps._ulong)
{
Plugin.seekerPlayer = val;
if (GameNetworkManager.Instance.localPlayerController.actualClientId == Plugin.seekerPlayer.actualClientId)
{
HUDManager.Instance.DisplayTip("Hide And Seek", "You are the seeker!", true, false, "LC_Tip1");
}
else
{
HUDManager.Instance.DisplayTip("Hide And Seek", "Seeker Chosen [" + Plugin.seekerPlayer.playerUsername + "]", false, false, "LC_Tip1");
}
break;
}
}
}
public static void LockDoor(string eventName, MessageProperties mProps = null)
{
if (!(eventName != ".lockDoor"))
{
Debugger.Debug.LogMessage("Got LockDoor Broadcast!");
HangarShipDoor val = Object.FindObjectOfType<HangarShipDoor>();
val.SetDoorClosed();
val.PlayDoorAnimation(true);
val.buttonsEnabled = false;
}
}
public static void OpenDoor(string eventName, MessageProperties mProps = null)
{
if (!(eventName != ".openDoor"))
{
Debugger.Debug.LogMessage("Got OpenDoor Broadcast!");
HangarShipDoor val = Object.FindObjectOfType<HangarShipDoor>();
val.buttonsEnabled = true;
val.SetDoorOpen();
val.PlayDoorAnimation(false);
}
}
public static void PlayerTeleported(string eventName, MessageProperties mProps)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (!(eventName != ".teleported"))
{
Debugger.Debug.LogMessage("Got Player Teleported Brodcast!");
if (mProps._bool)
{
RoundManagerPatch.playersTeleported = 0;
}
else if (!mProps._null)
{
RoundManagerPatch.itemSpawnPositions.Add((mProps._ulong, mProps._Vector3));
RoundManagerPatch.playersTeleported++;
}
else
{
Debugger.Debug.LogError("[Player Teleported] mProps == null! Called dry!");
}
}
}
public static void DisplayTip(string eventName, MessageProperties mProps)
{
if (!(eventName != ".tip"))
{
Debugger.Debug.LogMessage("Got Display Tip Brodcast!");
HUDManager.Instance.DisplayTip("Hide And Seek", mProps._string, mProps._bool, false, "LC_Tip1");
}
}
public static void LevelLoaded(string eventName, MessageProperties mProps)
{
if (!(eventName != ".levelLoaded"))
{
Debugger.Debug.LogMessage("Get Level Done Loading Brodcast!");
RoundManagerPatch.levelLoading = false;
}
}
public static void TeleportPlayer()
{
Debugger.Debug.LogMessage("Got Teleport Player Brodcast!");
((MonoBehaviour)RoundManager.Instance).StartCoroutine(TeleportSelf(waitForShipToLand: true));
}
public static IEnumerator TeleportSelf(bool waitForShipToLand)
{
PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController;
TimeOfDay timeOfDay = Object.FindObjectOfType<TimeOfDay>();
bool isHost = ((NetworkBehaviour)localPlayer).IsServer;
if (waitForShipToLand)
{
while (timeOfDay.currentDayTime <= 130f)
{
yield return (object)new WaitForSecondsRealtime(0.5f);
Debugger.Debug.Log($"[Client TeleportSelf] Tick {timeOfDay.currentDayTime}");
}
}
if (isHost)
{
RoundManagerPatch.PlayerDied("Teleport Self", -1, checking: true);
NetworkHandler.Instance.EventSendRpc(".lockDoor");
}
Debugger.Debug.Log($"TIME TO TELEPORT! Local Player {localPlayer} Seeker {Plugin.seekerPlayer}");
if ((Object)(object)localPlayer == (Object)(object)Plugin.seekerPlayer)
{
Debugger.Debug.LogMessage("[SEEKER] Attempted to teleport " + localPlayer.playerUsername + " but they are the seeker!");
if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>()))
{
Object.FindObjectOfType<AudioReverbPresets>().audioPresets[3].ChangeAudioReverbForPlayer(localPlayer);
}
localPlayer.isInElevator = true;
localPlayer.isInHangarShipRoom = true;
localPlayer.isInsideFactory = false;
localPlayer.averageVelocity = 0f;
localPlayer.velocityLastFrame = Vector3.zero;
localPlayer.TeleportPlayer(StartOfRound.Instance.playerSpawnPositions[0].position, false, 0f, false, true);
NetworkHandler.Instance.EventSendRpc(".teleported", new MessageProperties
{
_null = false,
_Vector3 = StartOfRound.Instance.playerSpawnPositions[0].position,
_ulong = localPlayer.actualClientId
});
}
else
{
Debugger.Debug.LogMessage("[HIDER] Teleporting to entrance... inside" + Config.forceHidersInside.Value);
localPlayer.DropAllHeldItems(true, false);
Vector3 entrancePosition = (Vector3)AccessTools.Method(typeof(RoundManager), "FindMainEntrancePosition", (Type[])null, (Type[])null).Invoke(null, new object[2]
{
true,
!Config.forceHidersInside.Value
});
EntranceTeleport entranceScript = (EntranceTeleport)AccessTools.Method(typeof(RoundManager), "FindMainEntranceScript", (Type[])null, (Type[])null).Invoke(null, new object[1] { Config.forceHidersInside.Value });
if ((Object)(object)entranceScript != (Object)null)
{
if (Config.teleportHidersToEntrance.Value)
{
entranceScript.TeleportPlayer();
Debugger.Debug.LogMessage("Player [" + localPlayer.playerUsername + "] teleported to entrance...");
}
else
{
entranceScript.TeleportPlayer();
Debugger.Debug.LogError("teleportPlayerOutOfShip NOT IMPLEMENTED! [" + localPlayer.playerUsername + "] teleported to entrance...");
}
NetworkHandler.Instance.EventSendRpc(".teleported", new MessageProperties
{
_null = false,
_Vector3 = entrancePosition,
_ulong = localPlayer.actualClientId
});
}
else
{
Debugger.Debug.LogMessage("Failed to find entrance");
}
}
while (timeOfDay.currentDayTime < Config.timeSeekerIsReleased.Value)
{
if (Plugin.seekerPlayer.isPlayerDead && !StartOfRound.Instance.shipIsLeaving)
{
if (isHost)
{
RoundManagerPatch.PlayerDied("Open Door Wait", -1, checking: true);
}
yield break;
}
if (!timeOfDay.timeHasStarted)
{
yield break;
}
yield return (object)new WaitForSeconds(1f);
}
if (isHost)
{
NetworkHandler.Instance.EventSendRpc(".openDoor");
}
if (Plugin.seekerPlayer.actualClientId != GameNetworkManager.Instance.localPlayerController.actualClientId)
{
yield break;
}
Debugger.Debug.LogMessage("Teleporting to entrance...");
EntranceTeleport entranceScript2 = (EntranceTeleport)AccessTools.Method(typeof(RoundManager), "FindMainEntranceScript", (Type[])null, (Type[])null).Invoke(null, new object[1] { Config.forceSeekerInside.Value });
int itemAmount = 0;
GrabbableObject[] itemSlots = localPlayer.ItemSlots;
foreach (GrabbableObject slot in itemSlots)
{
if ((Object)(object)slot != (Object)null)
{
itemAmount++;
}
}
if ((Object)(object)entranceScript2 != (Object)null && itemAmount != 0)
{
if (Config.teleportSeekerToEntrance.Value)
{
entranceScript2.TeleportPlayer();
Debugger.Debug.LogMessage("Player [" + localPlayer.playerUsername + "] teleported to entrance...");
}
}
else
{
Debugger.Debug.LogMessage("Failed to find entrance / Player did not pick up items");
}
}
}
}