public void OnEvent(PlayerSanityModule.SanityEventType evn, int mul = 1) { if (MainLevel.Instance.m_Tutorial) { this.m_Sanity = 100; return; } if (!base.enabled) { return; } SanityEventData sanityEventData = this.m_EventsMap[(int)evn]; if (sanityEventData.m_LastEventTime == 0f || Time.time - sanityEventData.m_LastEventTime >= sanityEventData.m_Interval) { int num = Mathf.Clamp(this.m_Sanity + sanityEventData.m_SanityChange[(int)GreenHellGame.Instance.m_GameDifficulty] * mul, 0, 100); int num2 = num - this.m_Sanity; if (num2 == 0) { return; } this.m_Sanity = num; sanityEventData.m_LastEventTime = Time.time; this.OnChangeSanity((float)num2, sanityEventData.m_TextID); } }
private void UpdateActiveInjuries() { this.m_SanityDictionary.Clear(); PlayerSanityModule playerSanityModule = PlayerSanityModule.Get(); for (int i = 0; i < this.m_Injuries.Count; i++) { Injury injury = this.m_Injuries[i]; if (!injury.m_Healing) { this.m_DamageInfo.m_Damager = base.gameObject; float num = 1f; if (SleepController.Get().IsActive() && !SleepController.Get().IsWakingUp()) { num = Player.GetSleepTimeFactor(); this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * num; } else { this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * Time.deltaTime * num; } if (injury.m_State == InjuryState.Infected) { this.m_DamageInfo.m_DamageType = DamageType.Infection; } else if (injury.m_PoisonLevel > 0) { if (injury.m_Type == InjuryType.SnakeBite) { this.m_DamageInfo.m_DamageType = DamageType.SnakePoison; } else { this.m_DamageInfo.m_DamageType = DamageType.VenomPoison; } } else { this.m_DamageInfo.m_DamageType = DamageType.None; } this.m_DamageInfo.m_FromInjury = true; this.m_DamageInfo.m_PlayDamageSound = false; this.m_Player.TakeDamage(this.m_DamageInfo); int num2 = 0; if (this.m_SanityDictionary.TryGetValue((int)injury.m_Type, out num2)) { Dictionary <int, int> sanityDictionary = this.m_SanityDictionary; int type = (int)injury.m_Type; int num3 = sanityDictionary[type]; sanityDictionary[type] = num3 + 1; } else { this.m_SanityDictionary.Add((int)injury.m_Type, 1); } } injury.Update(); } Dictionary <int, int> .Enumerator enumerator = this.m_SanityDictionary.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair <int, int> keyValuePair = enumerator.Current; switch (keyValuePair.Key) { case 0: { PlayerSanityModule playerSanityModule2 = playerSanityModule; PlayerSanityModule.SanityEventType evn = PlayerSanityModule.SanityEventType.SmallWoundAbrassion; keyValuePair = enumerator.Current; playerSanityModule2.OnEvent(evn, keyValuePair.Value); break; } case 1: { PlayerSanityModule playerSanityModule3 = playerSanityModule; PlayerSanityModule.SanityEventType evn2 = PlayerSanityModule.SanityEventType.SmallWoundScratch; keyValuePair = enumerator.Current; playerSanityModule3.OnEvent(evn2, keyValuePair.Value); break; } case 2: { PlayerSanityModule playerSanityModule4 = playerSanityModule; PlayerSanityModule.SanityEventType evn3 = PlayerSanityModule.SanityEventType.Laceration; keyValuePair = enumerator.Current; playerSanityModule4.OnEvent(evn3, keyValuePair.Value); break; } case 3: { PlayerSanityModule playerSanityModule5 = playerSanityModule; PlayerSanityModule.SanityEventType evn4 = PlayerSanityModule.SanityEventType.LacerationCat; keyValuePair = enumerator.Current; playerSanityModule5.OnEvent(evn4, keyValuePair.Value); break; } case 4: { PlayerSanityModule playerSanityModule6 = playerSanityModule; PlayerSanityModule.SanityEventType evn5 = PlayerSanityModule.SanityEventType.Rash; keyValuePair = enumerator.Current; playerSanityModule6.OnEvent(evn5, keyValuePair.Value); break; } case 5: { PlayerSanityModule playerSanityModule7 = playerSanityModule; PlayerSanityModule.SanityEventType evn6 = PlayerSanityModule.SanityEventType.Worm; keyValuePair = enumerator.Current; playerSanityModule7.OnEvent(evn6, keyValuePair.Value); break; } case 6: { PlayerSanityModule playerSanityModule8 = playerSanityModule; PlayerSanityModule.SanityEventType evn7 = PlayerSanityModule.SanityEventType.WormHole; keyValuePair = enumerator.Current; playerSanityModule8.OnEvent(evn7, keyValuePair.Value); break; } case 7: { PlayerSanityModule playerSanityModule9 = playerSanityModule; PlayerSanityModule.SanityEventType evn8 = PlayerSanityModule.SanityEventType.Leech; keyValuePair = enumerator.Current; playerSanityModule9.OnEvent(evn8, keyValuePair.Value); break; } case 8: { PlayerSanityModule playerSanityModule10 = playerSanityModule; PlayerSanityModule.SanityEventType evn9 = PlayerSanityModule.SanityEventType.LeechHole; keyValuePair = enumerator.Current; playerSanityModule10.OnEvent(evn9, keyValuePair.Value); break; } case 9: { PlayerSanityModule playerSanityModule11 = playerSanityModule; PlayerSanityModule.SanityEventType evn10 = PlayerSanityModule.SanityEventType.VenomBite; keyValuePair = enumerator.Current; playerSanityModule11.OnEvent(evn10, keyValuePair.Value); break; } case 10: { PlayerSanityModule playerSanityModule12 = playerSanityModule; PlayerSanityModule.SanityEventType evn11 = PlayerSanityModule.SanityEventType.SnakeBite; keyValuePair = enumerator.Current; playerSanityModule12.OnEvent(evn11, keyValuePair.Value); break; } } } enumerator.Dispose(); }
private void UpdateActiveInjuries() { this.m_SanityDictionary.Clear(); PlayerSanityModule playerSanityModule = PlayerSanityModule.Get(); for (int i = 0; i < this.m_Injuries.Count; i++) { Injury injury = this.m_Injuries[i]; if (!injury.m_Healing) { this.m_DamageInfo.m_Damager = base.gameObject; float num = 1f; if (SleepController.Get().IsActive()) { num = PlayerInjuryModule.GetSleepTimeFactor(); this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * num; } else { this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * Time.deltaTime * num; } this.m_DamageInfo.m_PlayDamageSound = false; this.m_Player.TakeDamage(this.m_DamageInfo); int num2 = 0; if (this.m_SanityDictionary.TryGetValue((int)injury.m_Type, out num2)) { Dictionary <int, int> sanityDictionary; int type; (sanityDictionary = this.m_SanityDictionary)[type = (int)injury.m_Type] = sanityDictionary[type] + 1; } else { this.m_SanityDictionary.Add((int)injury.m_Type, 1); } } injury.Update(); } foreach (KeyValuePair <int, int> keyValuePair in this.m_SanityDictionary) { switch (keyValuePair.Key) { case 0: { PlayerSanityModule playerSanityModule2 = playerSanityModule; PlayerSanityModule.SanityEventType evn = PlayerSanityModule.SanityEventType.SmallWoundAbrassion; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair2 = enumerator.Current; playerSanityModule2.OnEvent(evn, keyValuePair2.Value); break; } case 1: { PlayerSanityModule playerSanityModule3 = playerSanityModule; PlayerSanityModule.SanityEventType evn2 = PlayerSanityModule.SanityEventType.SmallWoundScratch; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair3 = enumerator.Current; playerSanityModule3.OnEvent(evn2, keyValuePair3.Value); break; } case 2: { PlayerSanityModule playerSanityModule4 = playerSanityModule; PlayerSanityModule.SanityEventType evn3 = PlayerSanityModule.SanityEventType.Laceration; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair4 = enumerator.Current; playerSanityModule4.OnEvent(evn3, keyValuePair4.Value); break; } case 3: { PlayerSanityModule playerSanityModule5 = playerSanityModule; PlayerSanityModule.SanityEventType evn4 = PlayerSanityModule.SanityEventType.LacerationCat; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair5 = enumerator.Current; playerSanityModule5.OnEvent(evn4, keyValuePair5.Value); break; } case 4: { PlayerSanityModule playerSanityModule6 = playerSanityModule; PlayerSanityModule.SanityEventType evn5 = PlayerSanityModule.SanityEventType.Rash; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair6 = enumerator.Current; playerSanityModule6.OnEvent(evn5, keyValuePair6.Value); break; } case 5: { PlayerSanityModule playerSanityModule7 = playerSanityModule; PlayerSanityModule.SanityEventType evn6 = PlayerSanityModule.SanityEventType.Worm; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair7 = enumerator.Current; playerSanityModule7.OnEvent(evn6, keyValuePair7.Value); break; } case 6: { PlayerSanityModule playerSanityModule8 = playerSanityModule; PlayerSanityModule.SanityEventType evn7 = PlayerSanityModule.SanityEventType.WormHole; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair8 = enumerator.Current; playerSanityModule8.OnEvent(evn7, keyValuePair8.Value); break; } case 7: { PlayerSanityModule playerSanityModule9 = playerSanityModule; PlayerSanityModule.SanityEventType evn8 = PlayerSanityModule.SanityEventType.Leech; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair9 = enumerator.Current; playerSanityModule9.OnEvent(evn8, keyValuePair9.Value); break; } case 8: { PlayerSanityModule playerSanityModule10 = playerSanityModule; PlayerSanityModule.SanityEventType evn9 = PlayerSanityModule.SanityEventType.LeechHole; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair10 = enumerator.Current; playerSanityModule10.OnEvent(evn9, keyValuePair10.Value); break; } case 9: { PlayerSanityModule playerSanityModule11 = playerSanityModule; PlayerSanityModule.SanityEventType evn10 = PlayerSanityModule.SanityEventType.VenomBite; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair11 = enumerator.Current; playerSanityModule11.OnEvent(evn10, keyValuePair11.Value); break; } case 10: { PlayerSanityModule playerSanityModule12 = playerSanityModule; PlayerSanityModule.SanityEventType evn11 = PlayerSanityModule.SanityEventType.SnakeBite; Dictionary <int, int> .Enumerator enumerator; KeyValuePair <int, int> keyValuePair12 = enumerator.Current; playerSanityModule12.OnEvent(evn11, keyValuePair12.Value); break; } } } }
private void LoadScript() { TextAsset textAsset = Resources.Load(this.m_SanityScript) as TextAsset; if (!textAsset) { DebugUtils.Assert("Can't load Sanity script - " + this.m_SanityScript, true, DebugUtils.AssertType.Info); return; } TextAssetParser textAssetParser = new TextAssetParser(textAsset); for (int i = 0; i < textAssetParser.GetKeysCount(); i++) { Key key = textAssetParser.GetKey(i); if (key.GetName() == "ItemHallucinationsSanityLevel") { this.m_ItemHallucinationsSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "ItemHallucinationMinInterval") { this.m_ItemHallucinationMinInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "ItemHallucinationMaxInterval") { this.m_ItemHallucinationMaxInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "ItemHallucinationsMinCount") { this.m_ItemHallucinationsMinCount = key.GetVariable(0).IValue; } else if (key.GetName() == "ItemHallucinationsMaxCount") { this.m_ItemHallucinationsMaxCount = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationsSanityLevel") { this.m_AIHallucinationsSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationMinInterval") { this.m_AIHallucinationMinInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "AIHallucinationMaxInterval") { this.m_AIHallucinationMaxInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "AIHallucinationsMinCount") { this.m_AIHallucinationsMinCount = key.GetVariable(0).IValue; } else if (key.GetName() == "AIHallucinationsMaxCount") { this.m_AIHallucinationsMaxCount = key.GetVariable(0).IValue; } else if (key.GetName() == "StartEffectSanityLevel") { this.m_StartEffectSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "DisappearChatterChance") { this.m_DisappearChatterChance = key.GetVariable(0).FValue; } else if (key.GetName() == "MinSpawnStalkerInterval") { this.m_MinSpawnStalkerInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxSpawnStalkerInterval") { this.m_MaxSpawnStalkerInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "WhispersSanityLevel") { this.m_WhispersSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "MinWhispersInterval") { this.m_MinWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxWhispersInterval") { this.m_MaxWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MinRandomWhispersInterval") { this.m_MinRandomWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxRandomWhispersInterval") { this.m_MaxRandomWhispersInterval = key.GetVariable(0).FValue; } else if (key.GetName() == "MaxWhispersQueue") { this.m_MaxWhispersQueue = key.GetVariable(0).IValue; } else if (key.GetName() == "Event") { string svalue = key.GetVariable(0).SValue; if (Enum.IsDefined(typeof(PlayerSanityModule.SanityEventType), svalue)) { PlayerSanityModule.SanityEventType key2 = (PlayerSanityModule.SanityEventType)Enum.Parse(typeof(PlayerSanityModule.SanityEventType), svalue); this.m_EventsMap[(int)key2].m_SanityChange[0] = key.GetVariable(1).IValue; this.m_EventsMap[(int)key2].m_SanityChange[1] = key.GetVariable(2).IValue; this.m_EventsMap[(int)key2].m_SanityChange[2] = key.GetVariable(3).IValue; this.m_EventsMap[(int)key2].m_Interval = key.GetVariable(4).FValue; this.m_EventsMap[(int)key2].m_TextID = key.GetVariable(5).SValue; } } else if (key.GetName() == "StalkerStalkingSanityLevel") { this.m_StalkerStalkingSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "StalkerAttackSanityLevel") { this.m_StalkerAttackSanityLevel = key.GetVariable(0).IValue; } else if (key.GetName() == "Whisper") { PlayerSanityModule.WhisperType key3 = (PlayerSanityModule.WhisperType)Enum.Parse(typeof(PlayerSanityModule.WhisperType), key.GetVariable(0).SValue); for (int j = 0; j < key.GetKeysCount(); j++) { Key key4 = key.GetKey(j); if (key4.GetName() == "Clip") { AudioClip audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key4.GetVariable(0).SValue); if (!audioClip) { audioClip = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key4.GetVariable(0).SValue); } if (!audioClip) { DebugUtils.Assert("Can't find clip - " + key4.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_WhispersMap.ContainsKey((int)key3)) { List <AudioClip> value = new List <AudioClip>(); this.m_WhispersMap.Add((int)key3, value); } this.m_WhispersMap[(int)key3].Add(audioClip); } } } else if (key.GetName() == "DisappearItemSounds") { for (int k = 0; k < key.GetKeysCount(); k++) { Key key5 = key.GetKey(k); if (key5.GetName() == "Clip") { AudioClip audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key5.GetVariable(0).SValue); if (!audioClip2) { audioClip2 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key5.GetVariable(0).SValue); } if (!audioClip2) { DebugUtils.Assert("Can't find clip - " + key5.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_DisappearItem.Contains(audioClip2)) { this.m_DisappearItem.Add(audioClip2); } } } } else if (key.GetName() == "DisappearAISounds") { for (int l = 0; l < key.GetKeysCount(); l++) { Key key6 = key.GetKey(l); if (key6.GetName() == "Clip") { AudioClip audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Whispers/" + key6.GetVariable(0).SValue); if (!audioClip3) { audioClip3 = Resources.Load <AudioClip>("Sounds/Chatters/Temp_Whispers/" + key6.GetVariable(0).SValue); } if (!audioClip3) { DebugUtils.Assert("Can't find clip - " + key6.GetVariable(0).SValue, true, DebugUtils.AssertType.Info); } if (!this.m_DisappearAI.Contains(audioClip3)) { this.m_DisappearAI.Add(audioClip3); } } } } else if (key.GetName() == "LowEnegryWhispersLevel") { this.m_LowEnegryWhispersLevel = key.GetVariable(0).FValue; } } Resources.UnloadAsset(textAsset); }
public void ResetEventCooldown(PlayerSanityModule.SanityEventType evn) { SanityEventData sanityEventData = this.m_EventsMap[(int)evn]; sanityEventData.m_LastEventTime = Time.time; }
public float GetEventInterval(PlayerSanityModule.SanityEventType evn) { SanityEventData sanityEventData = this.m_EventsMap[(int)evn]; return(sanityEventData.m_Interval); }
public float GetEventInterval(PlayerSanityModule.SanityEventType evn) { return(this.m_EventsMap[(int)evn].m_Interval[(int)DifficultySettings.ActivePreset.m_BaseDifficulty]); }