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 BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Snowlance.Something.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("Snowlance.Something")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+8e11899496046b0110891401b4f11c2bd29ea78b")]
[assembly: AssemblyProduct("Something")]
[assembly: AssemblyTitle("Snowlance.Something")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 Something
{
internal class BreathingBehavior : MonoBehaviour
{
public Slider BreathSlider;
public GameObject SliderObj;
public AudioClip BreathInSFX;
public AudioClip BreathOutSFX;
public Sprite[] JumpscareSprites;
public GameObject PanelObj;
public Image PanelImage;
private const float insanityToShowTooltip = 10f;
private bool active;
private bool holdingKey;
private string keyBind = "";
private bool showedTooltip;
private float multiplier = 0.5f;
private float insanityMultiplier = 2.5f;
public void Start()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
InputBinding val = SomethingInputs.Instance.BreathKey.bindings[0];
keyBind = InputControlPath.ToHumanReadableString(((InputBinding)(ref val)).path, (HumanReadableStringOptions)2, (InputControl)null);
}
public void Update()
{
if (showedTooltip || Plugin.localPlayer.insanityLevel >= 10f)
{
HUDManager.Instance.ChangeControlTip(HUDManager.Instance.controlTipLines.Length - 1, "Breath [" + keyBind + "]", false);
if (!showedTooltip)
{
HUDManager.Instance.DisplayTip("???", "Hold [" + keyBind + "] to breath", false, true, "SomethingTip");
}
showedTooltip = true;
}
if (SomethingInputs.Instance.BreathKey.WasPressedThisFrame())
{
Plugin.LoggerInstance.LogDebug((object)"Start Breathing");
Plugin.localPlayer.movementAudio.Stop();
Plugin.localPlayer.movementAudio.loop = false;
Plugin.localPlayer.movementAudio.clip = BreathInSFX;
Plugin.localPlayer.movementAudio.Play();
holdingKey = true;
}
else if (SomethingInputs.Instance.BreathKey.WasReleasedThisFrame())
{
Plugin.LoggerInstance.LogDebug((object)"Stop Breathing");
Plugin.localPlayer.movementAudio.Stop();
Plugin.localPlayer.movementAudio.loop = false;
Plugin.localPlayer.movementAudio.clip = BreathOutSFX;
Plugin.localPlayer.movementAudio.Play();
holdingKey = false;
}
if (holdingKey)
{
if (BreathSlider.value < 1f)
{
Slider breathSlider = BreathSlider;
breathSlider.value += Time.deltaTime * multiplier;
if (Plugin.localPlayer.insanityLevel > 0f)
{
PlayerControllerB localPlayer = Plugin.localPlayer;
localPlayer.insanityLevel -= Time.deltaTime * insanityMultiplier;
Plugin.LoggerInstance.LogDebug((object)("Insanity: " + Plugin.localPlayer.insanityLevel));
}
}
if (BreathSlider.value > 0f && !active)
{
SliderObj.SetActive(true);
active = true;
}
}
else
{
if (BreathSlider.value > 0f)
{
Slider breathSlider2 = BreathSlider;
breathSlider2.value -= Time.deltaTime * multiplier;
}
if (BreathSlider.value <= 0f && active)
{
SliderObj.SetActive(false);
active = false;
}
}
}
public void JumpscarePlayer()
{
PanelObj.SetActive(true);
int num = Random.Range(0, JumpscareSprites.Length);
PanelImage.sprite = JumpscareSprites[num];
}
}
internal class LesserSomethingAI : MonoBehaviour
{
private static ManualLogSource logger = Plugin.LoggerInstance;
public Transform turnCompass;
public NavMeshAgent agent;
public AudioSource creatureSFX;
public AudioClip[] ambientSFX;
public AudioClip[] alertSFX;
public AudioClip[] attackSFX;
public float AITimeInterval;
public PlayerControllerB targetPlayer;
private Coroutine wanderRoutine;
public Transform spawnNode;
private float timeSinceAIInterval;
private float timeSpawned;
private bool chasing;
private float stareTime;
public bool init;
public float destroyTime;
private float idleMinInterval = 3f;
private float idleMaxInterval = 10f;
private float maxStareTime = 1f;
private int damage = 2;
private float insanityMultiplier = 1f;
private float insanityChaseMultiplier = 1.2f;
private float chaseSpeed = 1.5f;
private float wanderSpeed = 1f;
private float insanityOnCollision = 5f;
public void Start()
{
wanderRoutine = ((MonoBehaviour)this).StartCoroutine(WanderingCoroutine());
}
public void Update()
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
if (init)
{
timeSinceAIInterval += Time.deltaTime;
timeSpawned += Time.deltaTime;
if (timeSinceAIInterval >= AITimeInterval)
{
timeSinceAIInterval = 0f;
DoAIInterval();
}
turnCompass.LookAt(((Component)Plugin.localPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 10f * Time.deltaTime);
}
}
public void DoAIInterval()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
bool flag = targetPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f);
if (!flag && timeSpawned > destroyTime)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
if (chasing)
{
agent.speed = chaseSpeed;
agent.SetDestination(((Component)targetPlayer).transform.position);
if (flag)
{
PlayerControllerB obj = targetPlayer;
obj.insanityLevel += AITimeInterval * insanityChaseMultiplier;
}
return;
}
agent.speed = wanderSpeed;
if (flag)
{
PlayerControllerB obj2 = targetPlayer;
obj2.insanityLevel += AITimeInterval * insanityMultiplier;
stareTime += AITimeInterval;
if (stareTime >= maxStareTime)
{
((MonoBehaviour)this).StopCoroutine(wanderRoutine);
chasing = true;
RoundManager.PlayRandomClip(creatureSFX, alertSFX, true, 1f, 0, 1000);
}
}
}
private IEnumerator WanderingCoroutine()
{
yield return null;
yield return (object)new WaitUntil((Func<bool>)(() => init));
while (true)
{
float timeStuck = 0f;
float idleTime = Random.Range(idleMinInterval, idleMaxInterval);
Vector3 position = RoundManager.Instance.GetRandomNavMeshPositionInRadius(spawnNode.position, 3f, RoundManager.Instance.navHit);
agent.SetDestination(position);
while (true)
{
yield return (object)new WaitForSeconds(AITimeInterval);
if (!agent.hasPath || timeStuck > 1f)
{
break;
}
if (agent.velocity == Vector3.zero)
{
timeStuck += AITimeInterval;
}
}
RoundManager.PlayRandomClip(creatureSFX, ambientSFX, true, 1f, 0, 1000);
yield return (object)new WaitForSeconds(idleTime);
}
}
public void OnTriggerEnter(Collider other)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = default(PlayerControllerB);
if (((Component)other).CompareTag("Player") && ((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) && !((Object)(object)val != (Object)(object)Plugin.localPlayer))
{
Plugin.log("Player collided with lesser something");
Plugin.localPlayer.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
PlayerControllerB localPlayer = Plugin.localPlayer;
localPlayer.insanityLevel += insanityOnCollision;
RoundManager.PlayRandomClip(Plugin.localPlayer.statusEffectAudio, attackSFX, true, 1f, 0, 1000);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
internal class TESTING : MonoBehaviour
{
private static ManualLogSource logger = Plugin.LoggerInstance;
private static bool toggle;
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
public static void PingScan_performedPostFix()
{
Plugin.log("Insanity: " + Plugin.localPlayer.insanityLevel);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
public static void SubmitChat_performedPrefix(HUDManager __instance)
{
try
{
string text = __instance.chatTextField.text;
string[] array = text.Split(" ");
switch (array[0])
{
case "/insanity":
Plugin.localPlayer.insanityLevel = float.Parse(array[1]);
break;
case "/refresh":
RoundManager.Instance.RefreshEnemiesList();
HoarderBugAI.RefreshGrabbableObjectsInMapList();
break;
case "/levels":
{
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val2 in levels)
{
Plugin.log(((Object)val2).name);
}
break;
}
case "/dungeon":
Plugin.log(((Object)RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow).name);
break;
case "/dungeons":
{
IndoorMapType[] dungeonFlowTypes = RoundManager.Instance.dungeonFlowTypes;
foreach (IndoorMapType val in dungeonFlowTypes)
{
Plugin.log(((Object)val.dungeonFlow).name);
}
break;
}
}
}
catch
{
logger.LogError((object)"Invalid chat command");
}
}
}
[BepInPlugin("Snowlance.Something", "Something", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static Plugin PluginInstance;
public static ManualLogSource LoggerInstance;
private readonly Harmony harmony = new Harmony("Snowlance.Something");
public static AssetBundle? ModAssets;
public static ConfigEntry<bool> configEnableDebugging;
public static ConfigEntry<string> configSomethingLevelRarities;
public static ConfigEntry<string> configSomethingCustomLevelRarities;
public static PlayerControllerB localPlayer => GameNetworkManager.Instance.localPlayerController;
public static bool IsServerOrHost => NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost;
public static PlayerControllerB PlayerFromId(ulong id)
{
return StartOfRound.Instance.allPlayerScripts.Where((PlayerControllerB x) => x.actualClientId == id).First();
}
private void Awake()
{
if ((Object)(object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
harmony.PatchAll();
InitializeNetworkBehaviours();
SomethingInputs.Init();
configEnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debuggin", "Enable Debugging", false, "Set to true to enable debug logs");
configSomethingLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("Something Rarities", "Level Rarities", "All: 20", "Rarities for each level. See default for formatting.");
configSomethingCustomLevelRarities = ((BaseUnityPlugin)this).Config.Bind<string>("Something Rarities", "Custom Level Rarities", "", "Rarities for modded levels. Same formatting as level rarities.");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "something_assets"));
if ((Object)(object)ModAssets == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
return;
}
LoggerInstance.LogDebug((object)("Got AssetBundle at: " + Path.Combine(directoryName, "something_assets")));
EnemyType val = ModAssets.LoadAsset<EnemyType>("Assets/ModAssets/SomethingEnemy.asset");
if ((Object)(object)val == (Object)null)
{
LoggerInstance.LogError((object)"Error: Couldnt get Something enemy from assets");
return;
}
LoggerInstance.LogDebug((object)"Got Something enemy prefab");
TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("Assets/ModAssets/Bestiary/SomethingTN.asset");
TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("Assets/ModAssets/Bestiary/SomethingTK.asset");
LoggerInstance.LogDebug((object)"Registering enemy network prefab...");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
LoggerInstance.LogDebug((object)"Registering enemy...");
Enemies.RegisterEnemy(val, GetLevelRarities(configSomethingLevelRarities.Value), GetCustomLevelRarities(configSomethingCustomLevelRarities.Value), val2, val3);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Snowlance.Something v0.1.1 has loaded!");
}
public Dictionary<LevelTypes, int> GetLevelRarities(string levelsString)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
try
{
Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
if (levelsString != null && levelsString != "")
{
string[] array = levelsString.Split(',');
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(':');
if (array3.Length == 2)
{
string text2 = array3[0].Trim();
string text3 = array3[1].Trim();
if (Enum.TryParse<LevelTypes>(text2, out LevelTypes result) && int.TryParse(text3, out var result2))
{
dictionary.Add(result, result2);
}
else
{
LoggerInstance.LogError((object)("Error: Invalid level rarity: " + text2 + ":" + text3));
}
}
}
}
return dictionary;
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Error: {arg}");
return null;
}
}
public Dictionary<string, int> GetCustomLevelRarities(string levelsString)
{
try
{
Dictionary<string, int> dictionary = new Dictionary<string, int>();
if (levelsString != null)
{
string[] array = levelsString.Split(',');
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(':');
if (array3.Length == 2)
{
string text2 = array3[0].Trim();
string text3 = array3[1].Trim();
if (int.TryParse(text3, out var result))
{
dictionary.Add(text2, result);
}
else
{
LoggerInstance.LogError((object)("Error: Invalid level rarity: " + text2 + ":" + text3));
}
}
}
}
return dictionary;
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Error: {arg}");
return null;
}
}
public static void FreezePlayer(PlayerControllerB player, bool value)
{
player.disableInteract = value;
player.disableLookInput = value;
player.disableMoveInput = value;
}
public static void log(string msg)
{
if (configEnableDebugging.Value)
{
LoggerInstance.LogDebug((object)msg);
}
}
private static void InitializeNetworkBehaviours()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
LoggerInstance.LogDebug((object)"Finished initializing network behaviours");
}
}
internal class SomethingAI : EnemyAI
{
public enum State
{
Inactive,
Chasing
}
private static ManualLogSource logger = Plugin.LoggerInstance;
public Transform turnCompass;
public GameObject[] lesserSomethingPrefabs;
public GameObject littleOnePrefab;
public AudioClip disappearSFX;
public AudioClip[] ambientSFX;
public AudioClip[] attackSFX;
public SpriteRenderer somethingMesh;
public GameObject ScanNode;
public GameObject BreathingMechanicPrefab;
private Random random;
private BreathingBehavior BreathingUI;
private List<GameObject> SpawnedTinySomethings = new List<GameObject>();
private bool enemyMeshEnabled;
private bool initializedRandomSeed;
private bool hauntingLocalPlayer;
private float timeSinceSpawnLS;
private float nextSpawnTimeLS;
private float timeSinceStare;
private float timeSinceChaseAttempt;
private bool staring;
private bool choosingNewPlayerToHaunt = true;
private const float maxInsanity = 50f;
private float lsMinSpawnTime = 10f;
private float lsMaxSpawnTime = 30f;
private float lsAmount = 0.1f;
private float tsAmount = 0.5f;
private float insanityPhase3 = 0.3f;
private float stareCooldown = 20f;
private float stareBufferTime = 5f;
private float stareTime = 10f;
private float insanityIncreaseOnLook = 10f;
private float somethingChaseSpeed = 10f;
private float chaseCooldown = 5f;
private float insanityPhase1 = 0f;
private float insanityPhase2 = 0.1f;
public override void Start()
{
Plugin.log("Something spawned");
((EnemyAI)this).Start();
if (!RoundManager.Instance.hasInitializedLevelRandomSeed)
{
RoundManager.Instance.InitializeRandomNumberGenerators();
}
Plugin.log("initialized random number generators");
base.currentBehaviourStateIndex = 0;
((MonoBehaviour)this).StartCoroutine(ChoosePlayerToHauntCoroutine(5f));
}
public override void Update()
{
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (StartOfRound.Instance.allPlayersDead)
{
return;
}
if (Plugin.IsServerOrHost && (Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerControlled && !choosingNewPlayerToHaunt)
{
choosingNewPlayerToHaunt = true;
ChooseNewPlayerToHauntClientRpc();
return;
}
if (!((NetworkBehaviour)this).IsOwner)
{
if (enemyMeshEnabled)
{
((EnemyAI)this).EnableEnemyMesh(false, false);
}
return;
}
if ((Object)(object)base.targetPlayer != (Object)null && (Object)(object)Plugin.localPlayer != (Object)(object)base.targetPlayer)
{
((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
}
if (!((Object)(object)base.targetPlayer == (Object)null) && !base.targetPlayer.isPlayerDead && !base.targetPlayer.disconnectedMidGame && !base.inSpecialAnimation && !choosingNewPlayerToHaunt && ((NetworkBehaviour)this).IsOwner)
{
turnCompass.LookAt(((Component)Plugin.localPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 10f * Time.deltaTime);
float num = base.targetPlayer.insanityLevel / 50f;
base.targetPlayer.playersManager.fearLevel = Mathf.Max(base.targetPlayer.playersManager.fearLevel, num);
timeSinceSpawnLS += Time.deltaTime;
timeSinceStare += Time.deltaTime;
timeSinceChaseAttempt += Time.deltaTime;
}
}
public override void DoAIInterval()
{
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (!((NetworkBehaviour)this).IsOwner || StartOfRound.Instance.allPlayersDead || (Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || base.targetPlayer.disconnectedMidGame || base.inSpecialAnimation || choosingNewPlayerToHaunt)
{
return;
}
switch (base.currentBehaviourStateIndex)
{
case 0:
base.agent.speed = 0f;
if (!base.targetPlayer.isInsideFactory)
{
break;
}
if (base.targetPlayer.insanityLevel >= 50f && timeSinceChaseAttempt > chaseCooldown)
{
timeSinceChaseAttempt = 0f;
TryStartChase();
break;
}
if (staring)
{
if (base.targetPlayer.HasLineOfSightToPosition(((Component)this).transform.position, 45f, 60, -1f))
{
PlayerControllerB targetPlayer = base.targetPlayer;
targetPlayer.insanityLevel += insanityIncreaseOnLook;
if (base.targetPlayer.insanityLevel >= 50f)
{
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
base.creatureVoice.Play();
staring = false;
timeSinceStare = 0f;
}
else
{
timeSinceStare = 0f;
staring = false;
base.creatureAnimator.SetTrigger("despawn");
base.creatureSFX.PlayOneShot(disappearSFX);
}
break;
}
}
else if (50f * insanityPhase3 <= base.targetPlayer.insanityLevel && timeSinceStare > stareCooldown)
{
Plugin.log("Attempting stare player");
staring = true;
StarePlayer();
}
if (timeSinceSpawnLS > nextSpawnTimeLS && 50f * insanityPhase1 <= base.targetPlayer.insanityLevel)
{
timeSinceSpawnLS = 0f;
nextSpawnTimeLS = Random.Range(lsMinSpawnTime, lsMaxSpawnTime);
SpawnLittleOnes(reset: false);
if (50f * insanityPhase2 <= base.targetPlayer.insanityLevel)
{
SpawnLesserSomethings();
}
}
break;
case 1:
base.agent.speed = somethingChaseSpeed;
if (!base.targetPlayer.isPlayerAlone || !base.targetPlayer.isInsideFactory)
{
StopChase();
}
((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
break;
default:
logger.LogWarning((object)("Invalid state: " + base.currentBehaviourStateIndex));
break;
}
}
private void TryStartChase()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
Plugin.log("Trying to start chase");
base.targetNode = ChoosePositionInFrontOfPlayer(5f);
if ((Object)(object)base.targetNode == (Object)null)
{
Plugin.log("targetNode is null!");
return;
}
((MonoBehaviour)this).StartCoroutine(FreezePlayerCoroutine(3f));
Teleport(base.targetNode.position);
((EnemyAI)this).EnableEnemyMesh(true, false);
staring = false;
base.inSpecialAnimation = true;
base.creatureAnimator.SetTrigger("spawn");
((EnemyAI)this).SwitchToBehaviourServerRpc(1);
}
private void StopChase()
{
base.creatureVoice.Stop();
((EnemyAI)this).EnableEnemyMesh(false, false);
((EnemyAI)this).SwitchToBehaviourServerRpc(0);
}
private IEnumerator FreezePlayerCoroutine(float freezeTime)
{
Plugin.FreezePlayer(base.targetPlayer, value: true);
yield return (object)new WaitForSeconds(freezeTime);
Plugin.FreezePlayer(base.targetPlayer, value: false);
}
private void StarePlayer()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
base.targetNode = TryFindingHauntPosition();
if ((Object)(object)base.targetNode == (Object)null)
{
Plugin.log("targetNode is null!");
timeSinceStare = stareCooldown - stareBufferTime;
staring = false;
}
else
{
Teleport(base.targetNode.position);
((EnemyAI)this).EnableEnemyMesh(true, false);
RoundManager.PlayRandomClip(base.creatureVoice, ambientSFX, true, 1f, 0, 1000);
((MonoBehaviour)this).StartCoroutine(StopStareAfterDelay(stareTime));
}
}
private IEnumerator StopStareAfterDelay(float delay)
{
yield return (object)new WaitForSeconds(delay);
if (enemyMeshEnabled && base.currentBehaviourStateIndex != 1)
{
((EnemyAI)this).EnableEnemyMesh(false, false);
timeSinceStare = 0f;
staring = false;
}
}
private Transform? TryFindingHauntPosition(bool mustBeInLOS = true)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
if (base.targetPlayer.isInsideFactory)
{
for (int i = 0; i < base.allAINodes.Length; i++)
{
if ((!mustBeInLOS || !Physics.Linecast(((Component)base.targetPlayer.gameplayCamera).transform.position, base.allAINodes[i].transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault)) && !base.targetPlayer.HasLineOfSightToPosition(base.allAINodes[i].transform.position, 80f, 100, 8f))
{
Debug.DrawLine(((Component)base.targetPlayer.gameplayCamera).transform.position, base.allAINodes[i].transform.position, Color.green, 2f);
Debug.Log((object)$"Player distance to haunt position: {Vector3.Distance(((Component)base.targetPlayer).transform.position, base.allAINodes[i].transform.position)}");
return base.allAINodes[i].transform;
}
}
}
return null;
}
public Transform? ChoosePositionInFrontOfPlayer(float minDistance)
{
//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_0070: 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)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
Plugin.log("Choosing position in front of player");
Transform result = null;
Plugin.log(base.allAINodes.Count() + " ai nodes");
GameObject[] allAINodes = base.allAINodes;
foreach (GameObject val in allAINodes)
{
if (!((Object)(object)val == (Object)null))
{
Vector3 val2 = val.transform.position + Vector3.up * 0.5f;
Vector3 position = ((Component)base.targetPlayer.gameplayCamera).transform.position;
float num = Vector3.Distance(position, val2);
if (!(num < minDistance) && !Physics.Linecast(val2, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && base.targetPlayer.HasLineOfSightToPosition(val2, 45f, 60, -1f))
{
base.mostOptimalDistance = num;
result = val.transform;
}
}
}
Plugin.log($"null: {(Object)(object)base.targetNode == (Object)null}");
return result;
}
public override void EnableEnemyMesh(bool enable, bool overrideDoNotSet = false)
{
Plugin.log($"EnableEnemyMesh({enable})");
((Renderer)somethingMesh).enabled = enable;
ScanNode.SetActive(enable);
enemyMeshEnabled = enable;
}
private Vector3 FindPositionOutOfLOS()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
base.targetNode = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)base.targetPlayer).transform.position, true, 0);
return RoundManager.Instance.GetNavMeshPosition(base.targetNode.position, default(NavMeshHit), 5f, -1);
}
private IEnumerator ChoosePlayerToHauntCoroutine(float delay)
{
choosingNewPlayerToHaunt = true;
Plugin.log($"choosing player to haunt in {delay} seconds");
yield return (object)new WaitForSeconds(delay);
if ((Object)(object)base.targetPlayer == (Object)null)
{
ChoosePlayerToHaunt();
}
choosingNewPlayerToHaunt = false;
}
private void ChoosePlayerToHaunt()
{
Plugin.log("starting ChoosePlayerToHaunt()");
if (!initializedRandomSeed)
{
int seed = StartOfRound.Instance.randomMapSeed + 158;
Plugin.log("Assigning new random with seed: " + seed);
random = new Random(seed);
}
float num = 0f;
float num2 = 0f;
int num3 = 0;
int num4 = 0;
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
if (StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount > num3)
{
num3 = StartOfRound.Instance.gameStats.allPlayerStats[i].turnAmount;
num4 = i;
}
if (StartOfRound.Instance.allPlayerScripts[i].insanityLevel > num)
{
num = StartOfRound.Instance.allPlayerScripts[i].insanityLevel;
num2 = i;
}
}
int[] array = new int[StartOfRound.Instance.allPlayerScripts.Length];
for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++)
{
if (!StartOfRound.Instance.allPlayerScripts[j].isPlayerControlled)
{
array[j] = 0;
Plugin.log($"{StartOfRound.Instance.allPlayerScripts[j].playerUsername}: {array[j]}");
continue;
}
array[j] += 80;
if (num2 == (float)j && num > 1f)
{
array[j] += 50;
}
if (num4 == j)
{
array[j] += 30;
}
if (!StartOfRound.Instance.allPlayerScripts[j].hasBeenCriticallyInjured)
{
array[j] += 10;
}
if ((Object)(object)StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer != (Object)null && StartOfRound.Instance.allPlayerScripts[j].currentlyHeldObjectServer.scrapValue > 150)
{
array[j] += 30;
}
Plugin.log($"{StartOfRound.Instance.allPlayerScripts[j].playerUsername}: {array[j]}");
}
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[RoundManager.Instance.GetRandomWeightedIndex(array, random)];
if (val.isPlayerDead)
{
for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++)
{
if (!StartOfRound.Instance.allPlayerScripts[k].isPlayerDead)
{
val = StartOfRound.Instance.allPlayerScripts[k];
break;
}
}
}
Debug.Log((object)$"Something: Haunting player with playerClientId: {val.playerClientId}; actualClientId: {val.actualClientId}");
((EnemyAI)this).ChangeOwnershipOfEnemy(val.actualClientId);
hauntingLocalPlayer = (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)val;
val.insanityLevel = 0f;
base.targetPlayer = val;
if (Plugin.IsServerOrHost)
{
((NetworkBehaviour)this).NetworkObject.ChangeOwnership(base.targetPlayer.actualClientId);
}
SpawnLittleOnes(reset: true);
if (hauntingLocalPlayer)
{
BreathingUI = Object.Instantiate<GameObject>(BreathingMechanicPrefab).GetComponent<BreathingBehavior>();
}
}
public void Teleport(Vector3 position)
{
//IL_0023: 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)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Plugin.log("Teleporting to " + ((object)(Vector3)(ref position)).ToString());
position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 5f, -1);
base.agent.Warp(position);
}
private void SpawnLesserSomethings()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
int num2 = (int)((float)base.allAINodes.Length * lsAmount);
List<GameObject> list = base.allAINodes.ToList();
for (int i = 0; i < num2; i++)
{
if (list.Count <= 0)
{
break;
}
GameObject randomAINode = GetRandomAINode(list);
list.Remove(randomAINode);
if (base.targetPlayer.HasLineOfSightToPosition(randomAINode.transform.position, 45f, 60, -1f))
{
i--;
continue;
}
int num3 = Random.Range(0, lesserSomethingPrefabs.Length);
Vector3 randomNavMeshPositionInBoxPredictable = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(randomAINode.transform.position, 10f, RoundManager.Instance.navHit, random, -1);
LesserSomethingAI component = Object.Instantiate<GameObject>(lesserSomethingPrefabs[num3], randomNavMeshPositionInBoxPredictable, Quaternion.identity).GetComponent<LesserSomethingAI>();
component.spawnNode = randomAINode.transform;
component.targetPlayer = base.targetPlayer;
component.destroyTime = nextSpawnTimeLS;
component.init = true;
num++;
}
Plugin.log($"Spawned {num}/{base.allAINodes.Length} lesser_somethings which will self destruct in {nextSpawnTimeLS} seconds");
}
private void SpawnLittleOnes(bool reset)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (SpawnedTinySomethings.Count > 0)
{
foreach (GameObject item in SpawnedTinySomethings.ToList())
{
if ((Object)(object)item == (Object)null)
{
SpawnedTinySomethings.Remove(item);
}
else if (reset || !base.targetPlayer.HasLineOfSightToPosition(item.transform.position, 45f, 60, -1f))
{
SpawnedTinySomethings.Remove(item);
Object.Destroy((Object)(object)item);
}
}
if (reset)
{
SpawnedTinySomethings.Clear();
}
}
if (hauntingLocalPlayer)
{
int num = (int)((float)base.allAINodes.Length * tsAmount);
List<GameObject> list = base.allAINodes.ToList();
for (int i = 0; i < num; i++)
{
GameObject randomAINode = GetRandomAINode(list);
list.Remove(randomAINode);
Vector3 randomNavMeshPositionInBoxPredictable = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(randomAINode.transform.position, 10f, RoundManager.Instance.navHit, random, -1);
SpawnedTinySomethings.Add(Object.Instantiate<GameObject>(littleOnePrefab, randomNavMeshPositionInBoxPredictable, Quaternion.identity));
}
}
}
private GameObject GetRandomAINode(List<GameObject> nodes)
{
int index = Random.Range(0, nodes.Count);
return nodes[index];
}
public override void OnCollideWithPlayer(Collider other)
{
((EnemyAI)this).OnCollideWithPlayer(other);
PlayerControllerB val = default(PlayerControllerB);
if (!base.inSpecialAnimation && base.currentBehaviourStateIndex != 0 && ((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) && !((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Plugin.localPlayer))
{
base.inSpecialAnimation = true;
((MonoBehaviour)this).StartCoroutine(KillPlayerCoroutine());
}
}
private IEnumerator KillPlayerCoroutine()
{
Plugin.log("In KillPlayerCoroutine()");
yield return null;
((MonoBehaviour)this).StartCoroutine(FreezePlayerCoroutine(3f));
((EnemyAI)this).EnableEnemyMesh(false, false);
base.creatureVoice.Stop();
RoundManager.PlayRandomClip(base.creatureSFX, attackSFX, true, 1f, 0, 1000);
BreathingUI.JumpscarePlayer();
yield return (object)new WaitForSeconds(3f);
Plugin.localPlayer.KillPlayer(Vector3.zero, false, (CauseOfDeath)0, 0, default(Vector3));
PlayDisappearSFXClientRpc();
}
private void ResetHallucinations()
{
Plugin.log("Destroying little ones");
foreach (GameObject item in SpawnedTinySomethings.ToList())
{
Object.Destroy((Object)(object)item);
}
Plugin.log("Destroying breathing UI");
if ((Object)(object)BreathingUI != (Object)null)
{
Object.Destroy((Object)(object)((Component)BreathingUI).gameObject);
}
((EnemyAI)this).EnableEnemyMesh(false, false);
base.creatureVoice.Stop();
}
public override void OnDestroy()
{
ResetHallucinations();
((EnemyAI)this).OnDestroy();
}
public void EndSpawnAnimation()
{
Plugin.log("In EndSpawnAnimation()");
base.inSpecialAnimation = false;
base.creatureVoice.Play();
Plugin.FreezePlayer(base.targetPlayer, value: false);
}
public void EndDespawnAnimation()
{
Plugin.log("In EndDespawnAnimation");
base.creatureVoice.Stop();
base.inSpecialAnimation = false;
((EnemyAI)this).EnableEnemyMesh(false, false);
}
[ServerRpc(RequireOwnership = false)]
public void ChangeTargetPlayerServerRpc(ulong clientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(720653872u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, clientId);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 720653872u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && Plugin.IsServerOrHost)
{
ChangeTargetPlayerClientRpc(clientId);
}
}
}
[ClientRpc]
public void ChangeTargetPlayerClientRpc(ulong clientId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2558234219u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, clientId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2558234219u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
ResetHallucinations();
PlayerControllerB val3 = Plugin.PlayerFromId(clientId);
val3.insanityLevel = 0f;
base.targetPlayer = val3;
Plugin.log($"Something: Haunting player with playerClientId: {base.targetPlayer.playerClientId}; actualClientId: {base.targetPlayer.actualClientId}");
((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
hauntingLocalPlayer = (Object)(object)Plugin.localPlayer == (Object)(object)base.targetPlayer;
if (Plugin.IsServerOrHost)
{
((NetworkBehaviour)this).NetworkObject.ChangeOwnership(base.targetPlayer.actualClientId);
}
SpawnLittleOnes(reset: true);
if (hauntingLocalPlayer)
{
BreathingUI = Object.Instantiate<GameObject>(BreathingMechanicPrefab).GetComponent<BreathingBehavior>();
choosingNewPlayerToHaunt = false;
}
}
}
[ClientRpc]
public void PlayDisappearSFXClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(218996551u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 218996551u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureVoice.PlayOneShot(disappearSFX, 1f);
}
}
}
[ClientRpc]
public void ChooseNewPlayerToHauntClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2569486336u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2569486336u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
choosingNewPlayerToHaunt = true;
ResetHallucinations();
base.targetPlayer = null;
((MonoBehaviour)this).StartCoroutine(ChoosePlayerToHauntCoroutine(5f));
}
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_SomethingAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(720653872u, new RpcReceiveHandler(__rpc_handler_720653872));
NetworkManager.__rpc_func_table.Add(2558234219u, new RpcReceiveHandler(__rpc_handler_2558234219));
NetworkManager.__rpc_func_table.Add(218996551u, new RpcReceiveHandler(__rpc_handler_218996551));
NetworkManager.__rpc_func_table.Add(2569486336u, new RpcReceiveHandler(__rpc_handler_2569486336));
}
private static void __rpc_handler_720653872(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong clientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
target.__rpc_exec_stage = (__RpcExecStage)1;
((SomethingAI)(object)target).ChangeTargetPlayerServerRpc(clientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2558234219(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
ulong clientId = default(ulong);
ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
target.__rpc_exec_stage = (__RpcExecStage)2;
((SomethingAI)(object)target).ChangeTargetPlayerClientRpc(clientId);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_218996551(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((SomethingAI)(object)target).PlayDisappearSFXClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2569486336(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((SomethingAI)(object)target).ChooseNewPlayerToHauntClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "SomethingAI";
}
}
internal class SomethingInputs : LcInputActions
{
public static SomethingInputs Instance;
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction BreathKey { get; set; }
public static void Init()
{
Instance = new SomethingInputs();
}
}
internal class TinySomethingAI : MonoBehaviour
{
private static ManualLogSource logger = Plugin.LoggerInstance;
public Transform turnCompass;
public AudioSource creatureSFX;
public void Update()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
turnCompass.LookAt(((Component)Plugin.localPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 10f * Time.deltaTime);
}
public void OnTriggerEnter(Collider other)
{
PlayerControllerB val = default(PlayerControllerB);
if (((Component)other).CompareTag("Player") && ((Component)other).gameObject.TryGetComponent<PlayerControllerB>(ref val) && !((Object)(object)val != (Object)(object)Plugin.localPlayer))
{
Plugin.log("Player stepped on little one");
PlayerControllerB localPlayer = Plugin.localPlayer;
localPlayer.insanityLevel += 1f;
creatureSFX.Play();
Object.Destroy((Object)(object)((Component)this).gameObject, 0.5f);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Snowlance.Something";
public const string PLUGIN_NAME = "Something";
public const string PLUGIN_VERSION = "0.1.1";
}
}
namespace Something.Items.Polaroids
{
public class BadPolaroidBehavior : PhysicsProp
{
public MeshRenderer Renderer;
public Texture2D[] Photos;
private Material uniqueMaterial;
public GameObject SomethingPrefab;
public AudioSource ItemSFX;
public AudioClip[] clips;
public override void Start()
{
if (Plugin.IsServerOrHost)
{
int index = Random.Range(0, Photos.Length);
ChangePhotoClientRpc(index);
}
}
[ClientRpc]
public void ChangePhotoClientRpc(int index)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1492745073u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, index);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1492745073u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
uniqueMaterial = new Material(((Renderer)Renderer).material);
uniqueMaterial.mainTexture = (Texture)(object)Photos[index];
((Renderer)Renderer).material = uniqueMaterial;
}
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_BadPolaroidBehavior()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1492745073u, new RpcReceiveHandler(__rpc_handler_1492745073));
}
private static void __rpc_handler_1492745073(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int index = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref index);
target.__rpc_exec_stage = (__RpcExecStage)2;
((BadPolaroidBehavior)(object)target).ChangePhotoClientRpc(index);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "BadPolaroidBehavior";
}
}
public class CursedPolaroidBehavior : PhysicsProp
{
public AudioSource ItemAudio;
public AudioClip[] clips;
public Animator ItemAnimator;
public GameObject SomethingPrefab;
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "CursedPolaroidBehavior";
}
}
public class GoodPolaroidBehavior : PhysicsProp
{
public MeshRenderer Renderer;
public Texture2D[] Photos;
private Material uniqueMaterial;
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "GoodPolaroidBehavior";
}
}
public class NeutralPolaroidBehavior : PhysicsProp
{
public MeshRenderer Renderer;
public Texture2D[] Photos;
private Material uniqueMaterial;
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[MethodImpl(MethodImplOptions.NoInlining)]
protected internal override string __getTypeName()
{
return "NeutralPolaroidBehavior";
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace Snowlance.Something.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}