using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreUpgrades.Classes;
using REPOLib.Commands;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Desjul20")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SanityMod")]
[assembly: AssemblyTitle("SanityMod")]
[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.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 SanityMod
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
SanityMod.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
SanityMod.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("Desjul20.SanityMod", "SanityMod", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[RequireComponent(typeof(AudioSource))]
public class SanityMod : BaseUnityPlugin
{
public static float sanityPercent = 1f;
private AudioSource audioSource;
private AudioSource droneAudioSource;
private AudioSource boomAudioSource;
private AudioClip heartbeat;
private AudioClip droneAudio;
private AudioClip boomAudio;
public bool playingHeartbeat;
private bool playingDrone;
public bool playerIsDed;
public bool sanityDecreasing;
private bool alreadyResetSanity;
private List<string> deathMessages = new List<string>
{
"Goodbye world", "This is too scary", "I can't do this anymore", "I'm already dead, anyways", "(screams psychotically)", "Desjul20 wanted me dead", "I can't look at their faces anymore", "AAAAAAAAAAAAAAAAAAAAAAAH", "Leave me alone", "I can't bear their presence no more",
"Being chased petrifies me", "If only the duck was here to help"
};
private EnemyDuck[] duckEnemy;
private EnemyRunner[] runnerEnemy;
private List<AudioClip> enemiesOneShot;
private List<AudioClip>[] enemiesFootsteps;
private float enemySoundTimer = 20f;
public static ConfigEntry<int> difficultyConfig;
public static ConfigEntry<bool> noSanityRegain;
public static ConfigEntry<bool> noDeathOnNoSanity;
public static ConfigEntry<int> maxSanityDecreaseStrength;
public static ConfigEntry<bool> disableEffects;
public static ConfigEntry<bool> disableSounds;
public static ConfigEntry<bool> resetSanityAfterLevel;
internal static SanityMod Instance { get; private set; } = null;
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
LoadAssets();
Patch();
LoadConfig();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0025: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void LoadAssets()
{
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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_0121: Expected O, but got Unknown
Logger.LogInfo((object)"Loading SanityMod Bundle...");
AssetBundle val = LoadAssetBundle("SanityMod");
heartbeat = val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/heartbeat-02-225103.ogg");
audioSource = ((Component)this).GetComponent<AudioSource>();
droneAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
boomAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
droneAudio = val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/amb_lf-drone-49474.ogg");
boomAudio = val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/boom-geomorphism-cinematic-trailer-sound-effects-123876.ogg");
droneAudioSource.clip = droneAudio;
droneAudioSource.loop = true;
boomAudioSource.volume = 0.5f;
boomAudioSource.clip = boomAudio;
audioSource.clip = heartbeat;
audioSource.loop = true;
UpgradeItemBase val2 = new UpgradeItemBase
{
name = "Sanity",
maxAmount = 1000,
maxAmountInShop = 2,
minPrice = 6000f,
maxPrice = 10000f,
maxPurchaseAmount = 0,
priceIncreaseScaling = 0.5f
};
MoreUpgradesLib.Register("Desjul20.SanityMod", val.LoadAsset<Item>("Assets/REPO/Game/Resources/items/items/Item Upgrade Player Sanity.asset"), val.LoadAsset<GameObject>("Assets/REPO/Game/Resources/items/Item Upgrade Player Sanity.prefab"), val2);
enemiesOneShot = new List<AudioClip>
{
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy animal notice01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy animal notice02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy animal notice03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bang idle breaker vo01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bang idle breaker vo02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bang idle breaker vo03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bang idle breaker vo04.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bang idle breaker vo05.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy beamer attack intro.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy bowtie scream start global.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy duck notice01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy duck notice02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy duck notice03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy duck transition.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy gnome notice01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy gnome notice02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy gnome notice03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy gnome pickaxe hit.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hidden man land.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hidden man land02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hidden man land03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hunter aim start global01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hunter aim start global02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy hunter aim start global03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy robe attack_short global.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy robe noise01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy robe noise02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy robe noise03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy robe noise04.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy slow mouth chase loop.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy slow walker attack buildup vo.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy slow walker notice vo01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy slow walker notice vo02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy slow walker notice vo03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy thin man notice01.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy thin man notice02.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy thin man notice03.ogg"),
val.LoadAsset<AudioClip>("Assets/REPO/Game/Audio/AudioClips/enemy tumbler notice player.ogg")
};
}
public static AssetBundle LoadAssetBundle(string name)
{
Logger.LogDebug((object)("Loading Asset Bundle: " + name));
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, name);
return AssetBundle.LoadFromFile(text);
}
private void LoadConfig()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
Logger.LogInfo((object)"Loading Config...");
difficultyConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Difficulty Settings", "Starting Difficulty Level", 0, new ConfigDescription("Increases Sanity Difficulty", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
noSanityRegain = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty Settings", "No Sanity Regain", false, "Removes the ability to regain your sanity");
maxSanityDecreaseStrength = ((BaseUnityPlugin)this).Config.Bind<int>("Difficulty Settings", "Max Sanity Deduction Level", 20, new ConfigDescription("Change the sanity deduction limit", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 35), Array.Empty<object>()));
noDeathOnNoSanity = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty Settings", "No Death on Zero Sanity", false, "Removes the ability to die when your sanity reaches 0%");
disableEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual/Audio Settings", "Disable Effects", false, "Disables Sanity Effects");
disableSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual/Audio Settings", "Disable Sounds", false, "Disables Sanity Sound Effects");
resetSanityAfterLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty Settings", "Reset Sanity After Each Level", true, "Reset Player's Sanity to 100% at the Beginning of Each Level");
}
public void resetSanity(bool resetSanityPercent)
{
playerIsDed = false;
if (resetSanityPercent)
{
sanityPercent = 1f;
}
sanityDecreasing = false;
GameDirector.instance.CameraShake.Strength = 0f;
GameDirector.instance.CameraShake.Speed = 1f;
GameDirector.instance.CameraShake.InstantShake = false;
PostProcessing.Instance.vignetteIntensity = 0f;
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.contrast).value = 0f;
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.saturation).value = 0f;
}
public void stopHeartBeat()
{
audioSource.Stop();
audioSource.time = 0f;
playingHeartbeat = false;
}
public void playHeartBeat()
{
audioSource.Play();
playingHeartbeat = true;
}
private void selfDestruct()
{
PlayerAvatar.instance.playerHealth.health = 0;
PlayerAvatar.instance.playerHealth.Hurt(1, false, -1);
}
private void multiplayerDeathSequence()
{
((MonoBehaviour)this).Invoke("selfDestruct", 6f);
}
public void KillPlayer()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (!disableSounds.Value)
{
boomAudioSource.Play();
}
if (SemiFunc.IsMultiplayer())
{
ChatManager.instance.PossessChatScheduleStart(-1);
UnityEvent val = new UnityEvent();
val.AddListener(new UnityAction(multiplayerDeathSequence));
string text = deathMessages[Random.Range(0, deathMessages.Count)];
ChatManager.instance.PossessChat((PossessChatID)3, text, 2f, Color.red, 0f, true, 2, val);
ChatManager.instance.PossessChatScheduleEnd();
}
else
{
selfDestruct();
}
}
public float sanitySubtractionCalculation(int strength)
{
sanityDecreasing = true;
float num = strength;
IReadOnlyList<UpgradeItem> upgradeItemsByMod = MoreUpgradesLib.GetUpgradeItemsByMod("Desjul20.SanityMod");
return Time.deltaTime / ((180f - num * 5f + (float)upgradeItemsByMod[0].GetAmount((string)null) * 20f) / ((float)(RunManager.instance.levelsCompleted + difficultyConfig.Value) / 10f + 1f));
}
public float sanityAdditionCalculation(int strength)
{
float num = strength;
sanityDecreasing = false;
if (noSanityRegain.Value)
{
return 0f;
}
return Time.deltaTime / ((240f - num * 5f) * ((float)(RunManager.instance.levelsCompleted + difficultyConfig.Value) / 10f + 1f));
}
public void crouchSanity()
{
if (PlayerController.instance.Crouching)
{
sanityPercent = Mathf.Max(sanityPercent - sanitySubtractionCalculation(0), 0f);
}
else
{
sanityPercent = Mathf.Min(sanityPercent + sanityAdditionCalculation(0), 1f);
}
}
public int duckSanity(EnemyDuck enemy)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Invalid comparison between Unknown and I4
if ((int)enemy.currentState == 15 || (int)enemy.currentState == 14 || (int)enemy.currentState == 13)
{
if (enemy.enemy.PlayerDistance.PlayerDistanceLocal <= 20f)
{
return 15;
}
}
else if (enemy.enemy.PlayerDistance.PlayerDistanceLocal <= 6f)
{
sanityPercent = Mathf.Min(sanityPercent + sanityAdditionCalculation(0), 1f);
return 0;
}
return 0;
}
public int runnerSanity(EnemyRunner enemy)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
if ((int)enemy.currentState == 7 || (int)enemy.currentState == 8 || (int)enemy.currentState == 9)
{
if (enemy.enemy.PlayerDistance.PlayerDistanceLocal <= 20f)
{
return 10;
}
}
else
{
if (enemy.enemy.OnScreen.OnScreenLocal)
{
return 6;
}
if (enemy.enemy.PlayerDistance.PlayerDistanceLocal <= 6f)
{
return 4;
}
if (enemy.enemy.PlayerRoom.SameLocal)
{
return 2;
}
}
return 0;
}
private int countEnemyInList(List<EnemyParent> list, string name)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Invalid comparison between Unknown and I4
int num = 0;
foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
{
if (item.enemyName == name && (int)item.Enemy.CurrentState != 11)
{
num++;
}
}
return num;
}
public void enemySanity()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Invalid comparison between Unknown and I4
int num = 0;
foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
{
if (num >= maxSanityDecreaseStrength.Value || (Object)(object)item.Enemy == (Object)null || (Object)(object)item.Enemy.OnScreen == (Object)null || item.Enemy.Health.dead || (int)item.Enemy.CurrentState == 11)
{
continue;
}
if (item.enemyName == "Apex Predator")
{
if (duckEnemy == null || countEnemyInList(EnemyDirector.instance.enemiesSpawned, "Apex Predator") != duckEnemy.Length)
{
duckEnemy = Object.FindObjectsOfType<EnemyDuck>();
}
EnemyDuck[] array = duckEnemy;
foreach (EnemyDuck enemy in array)
{
num += duckSanity(enemy);
}
}
else if (item.enemyName == "Reaper")
{
if (runnerEnemy == null || countEnemyInList(EnemyDirector.instance.enemiesSpawned, "Reaper") != runnerEnemy.Length)
{
runnerEnemy = Object.FindObjectsOfType<EnemyRunner>();
}
EnemyRunner[] array2 = runnerEnemy;
foreach (EnemyRunner enemy2 in array2)
{
num += runnerSanity(enemy2);
}
}
else if ((int)item.Enemy.CurrentState == 4 && item.Enemy.PlayerDistance.PlayerDistanceLocal <= 20f)
{
num += 10;
}
else if (item.Enemy.OnScreen.OnScreenLocal)
{
num += 6;
}
else if (item.Enemy.PlayerDistance.PlayerDistanceLocal <= 6f)
{
num += 4;
}
else if (item.Enemy.PlayerRoom.SameLocal)
{
num += 2;
}
}
if (num == 0)
{
crouchSanity();
}
else
{
sanityPercent = Mathf.Max(sanityPercent - sanitySubtractionCalculation(Mathf.Min(num, 20)), 0f);
}
}
private Vector3 GetRandomPosition(Vector3 centerPoint, float radius)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0016: Unknown result type (might be due to invalid IL or missing references)
Vector3 insideUnitSphere = Random.insideUnitSphere;
Vector3 val = insideUnitSphere * radius;
return centerPoint + val;
}
public void mimicEnemies(int frequency)
{
//IL_0061: 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)
enemySoundTimer -= Time.deltaTime;
if (enemySoundTimer <= 0f)
{
enemySoundTimer = 20f;
if (frequency <= Random.Range(0, 40))
{
AudioSource.PlayClipAtPoint(enemiesOneShot[Random.Range(0, enemiesOneShot.Count)], GetRandomPosition(((Component)PlayerAvatar.instance).gameObject.transform.position, Random.Range(15f, 30f)), 1f);
}
}
}
public void sanityHeartBeat(float sanity)
{
if (sanity < 0.66f)
{
if (!playingHeartbeat && !playerIsDed)
{
playHeartBeat();
}
audioSource.volume = 1f - sanity - 0.34f;
audioSource.pitch = (1f - sanity) * 1.5f + 0.666f;
}
else if (playingHeartbeat)
{
stopHeartBeat();
}
}
private void Update()
{
if (SemiFunc.RunIsLevel() && PlayerAvatar.instance.playerHealth.health != 0)
{
if (!disableEffects.Value)
{
if (sanityPercent < 0.95f)
{
GameDirector.instance.CameraShake.InstantShake = true;
GameDirector.instance.CameraShake.Strength = (1f - sanityPercent) * 7f;
GameDirector.instance.CameraShake.Speed = 10f;
}
else if ((double)GameDirector.instance.CameraShake.Strength > 0.0)
{
GameDirector.instance.CameraShake.Strength = 0f;
GameDirector.instance.CameraShake.Speed = 1f;
GameDirector.instance.CameraShake.InstantShake = false;
}
}
if (alreadyResetSanity)
{
alreadyResetSanity = false;
}
enemySanity();
if (sanityPercent <= 0f && !playerIsDed && !noDeathOnNoSanity.Value)
{
KillPlayer();
playingDrone = false;
droneAudioSource.Stop();
playerIsDed = true;
}
if (!disableSounds.Value)
{
if ((double)sanityPercent <= 0.5)
{
mimicEnemies((int)Math.Ceiling((1f - sanityPercent * 2f) * 5f));
}
if (!playingDrone && !playerIsDed)
{
droneAudioSource.Play();
playingDrone = true;
}
droneAudioSource.volume = (1f - sanityPercent) * 0.75f;
if (playerIsDed)
{
audioSource.pitch += Time.deltaTime / 5f;
}
else
{
sanityHeartBeat(sanityPercent);
}
}
}
else
{
if (playingHeartbeat)
{
stopHeartBeat();
}
if (playingDrone)
{
playingDrone = false;
droneAudioSource.Stop();
}
if (!alreadyResetSanity)
{
alreadyResetSanity = true;
resetSanity(resetSanityAfterLevel.Value);
}
if (duckEnemy != null)
{
duckEnemy = null;
}
if (runnerEnemy != null)
{
runnerEnemy = null;
}
}
}
private void LateUpdate()
{
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_0042: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.RunIsLevel() && PlayerAvatar.instance.playerHealth.health != 0 && !disableEffects.Value)
{
if (sanityDecreasing)
{
PostProcessing.Instance.vignetteColor = Color.black;
PostProcessing.Instance.vignetteIntensity = Mathf.Max((1f - sanityPercent) * 0.75f, PostProcessing.Instance.vignetteIntensity);
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.contrast).value = Mathf.Max((sanityPercent - 1f) * -10f, ((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.contrast).value);
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.saturation).value = Mathf.Min((sanityPercent - 1f) * 100f, ((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.saturation).value);
}
else
{
PostProcessing.Instance.vignetteColor = Color.black;
PostProcessing.Instance.vignetteIntensity = (1f - sanityPercent) * 0.75f;
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.contrast).value = (sanityPercent - 1f) * -10f;
((ParameterOverride<float>)(object)PostProcessing.Instance.colorGrading.saturation).value = (sanityPercent - 1f) * 100f;
}
}
}
[CommandInitializer]
public static void Initialize()
{
}
[CommandExecution("Set Sanity Percent", "Changes sanity percent to argument", true, false)]
[CommandAlias("sanity")]
public static void Execute(string args)
{
sanityPercent = (float)Convert.ToDouble(args);
}
}
}