private void UpdateSymptoms() { foreach (KeyValuePair <int, global::DiseaseSymptom> keyValuePair in this.m_Symptoms) { global::DiseaseSymptom value = keyValuePair.Value; if (value.IsActive()) { bool flag = true; foreach (KeyValuePair <int, Disease> keyValuePair2 in this.m_Diseases) { Disease value2 = keyValuePair2.Value; if (value2.IsActive() && value2.GetAllSymptoms().Contains(value.m_Type)) { flag = false; } } if (flag) { value.Deactivate(); } } } foreach (KeyValuePair <int, global::DiseaseSymptom> keyValuePair3 in this.m_Symptoms) { global::DiseaseSymptom value3 = keyValuePair3.Value; if (value3.IsActive()) { value3.Update(); } } }
public global::DiseaseSymptom GetSymptom(Enums.DiseaseSymptom type) { global::DiseaseSymptom result = null; this.m_Symptoms.TryGetValue((int)type, out result); return(result); }
public void OnDrink(LiquidType liquid_type, float hydration_amount) { using (Dictionary <int, Disease> .KeyCollection.Enumerator enumerator = this.m_Diseases.Keys.GetEnumerator()) { while (enumerator.MoveNext()) { ConsumeEffect key = (ConsumeEffect)enumerator.Current; Disease disease = this.m_Diseases[(int)key]; if (disease.IsActive()) { disease.OnDrink(liquid_type); } } } using (Dictionary <int, global::DiseaseSymptom> .KeyCollection.Enumerator enumerator2 = this.m_Symptoms.Keys.GetEnumerator()) { while (enumerator2.MoveNext()) { Enums.DiseaseSymptom key2 = (Enums.DiseaseSymptom)enumerator2.Current; global::DiseaseSymptom diseaseSymptom = this.m_Symptoms[(int)key2]; if (diseaseSymptom.IsActive()) { diseaseSymptom.OnDrink(liquid_type, hydration_amount); } } } }
public void OnEat(ConsumableInfo info) { using (Dictionary <int, Disease> .KeyCollection.Enumerator enumerator = this.m_Diseases.Keys.GetEnumerator()) { while (enumerator.MoveNext()) { ConsumeEffect key = (ConsumeEffect)enumerator.Current; Disease disease = this.m_Diseases[(int)key]; if (disease.IsActive() || this.IsRequested(disease)) { disease.OnEat(info); } } } using (Dictionary <int, global::DiseaseSymptom> .KeyCollection.Enumerator enumerator2 = this.m_Symptoms.Keys.GetEnumerator()) { while (enumerator2.MoveNext()) { Enums.DiseaseSymptom key2 = (Enums.DiseaseSymptom)enumerator2.Current; global::DiseaseSymptom diseaseSymptom = this.m_Symptoms[(int)key2]; if (diseaseSymptom.IsActive()) { diseaseSymptom.OnEat(info); } } } }
private void ActivateSymptoms() { for (int i = 0; i < this.m_Symptoms.Count; i++) { global::DiseaseSymptom symptom = PlayerDiseasesModule.Get().GetSymptom(this.m_Symptoms[i]); if (symptom == null) { DebugUtils.Assert(DebugUtils.AssertType.Info); } else if (!symptom.IsActive()) { symptom.Activate(); } } }
private void LoadScript() { ScriptParser scriptParser = new ScriptParser(); scriptParser.Parse("Player/Player_Diseases.txt", true); for (int i = 0; i < scriptParser.GetKeysCount(); i++) { Key key = scriptParser.GetKey(i); if (key.GetName() == "Disease") { string svalue = key.GetVariable(0).SValue; Type type = Type.GetType(svalue); if (type == null) { DebugUtils.Assert(DebugUtils.AssertType.Info); } else { Disease disease = Activator.CreateInstance(type) as Disease; string svalue2 = key.GetVariable(0).SValue; disease.m_Type = (ConsumeEffect)Enum.Parse(typeof(ConsumeEffect), svalue2); for (int j = 0; j < key.GetKeysCount(); j++) { Key key2 = key.GetKey(j); disease.Load(key2); } this.m_Diseases.Add((int)disease.GetDiseaseType(), disease); } } else if (key.GetName() == "Symptom") { string svalue3 = key.GetVariable(0).SValue; Type type2 = Type.GetType(svalue3); if (type2 == null) { DebugUtils.Assert(DebugUtils.AssertType.Info); } else { global::DiseaseSymptom diseaseSymptom = Activator.CreateInstance(type2) as global::DiseaseSymptom; diseaseSymptom.Initialize(); diseaseSymptom.SetPlayerDiseasesModule(this); diseaseSymptom.ParseKey(key); this.m_Symptoms.Add((int)diseaseSymptom.GetSymptomType(), diseaseSymptom); } } } }