static bool Prefix(ref Pawn __instance, DamageInfo?dinfo, Verse.Hediff exactCulprit = null) { bool hasBondageBed = false;//没有被束缚床束缚 for (int i = 0; i < __instance.health.hediffSet.hediffs.Count; i++) { if (__instance.health.hediffSet.hediffs[i].def == SR.DA.Hediff.HediffDefOf.SR_Hediff_BondageBed) { hasBondageBed = true; break; } } //如果已经被束缚 if (hasBondageBed) { Building_BondageBed bbb = (Building_BondageBed)__instance.CurrentBed();//获取当前躺着的束缚床 CompRemoveEffectBondageBed crebb = bbb.GetComp <CompRemoveEffectBondageBed>(); if (crebb != null) { crebb.DoEffect(__instance); //解除束缚 return(false); //解除成功是会通知Pawn_HealthTracker重新检测死亡性,所以本次跳过,否则会多次kill } } return(true); }
/// <summary> /// 作用效果 束缚 /// </summary> /// <param name="usedBy"></param> public override void DoEffect(Pawn usedBy) { base.DoEffect(usedBy); Building_BondageBed building_BondageBed = (Building_BondageBed)parent; HediffDef hediffBed = Hediff.HediffDefOf.SR_Hediff_BondageBed; List <Verse.Hediff> .Enumerator enumerator; enumerator = (from x in usedBy.health.hediffSet.hediffs where x.def == hediffBed select x).ToList().GetEnumerator();//获取小人身上所有hediffBed while (enumerator.MoveNext()) { Verse.Hediff h = enumerator.Current;//当前的hediffBed usedBy.health.RemoveHediff(h); } building_BondageBed.RemoveOccupant(); }
/// <summary> /// 被使用的效果 /// </summary> /// <param name="usedBy"></param> public new void UsedBy(Pawn usedBy) { HediffDef hediff = Hediff.HediffDefOf.SR_Hediff_BondageChains; List <Verse.Hediff> .Enumerator enumerator; enumerator = (from x in usedBy.health.hediffSet.hediffs where x.def == hediff select x).ToList().GetEnumerator();//获取小人身上所有hediffBed while (enumerator.MoveNext()) { Verse.Hediff h = enumerator.Current;//当前的hediff usedBy.health.RemoveHediff(h); } var thing = ThingMaker.MakeThing(Thing.ThingDefOf.SR_Item_Chains); thing.stackCount = 1; GenPlace.TryPlaceThing(thing, usedBy.Position, usedBy.Map, ThingPlaceMode.Near); isBondaged = false; }
public void CheckForStateChange(DamageInfo?dinfo, Hediff hediff) { if (Dead) { return; } if (ShouldBeDead()) { if (!pawn.Destroyed) { pawn.Kill(dinfo, hediff); } } else if (!Downed) { if (ShouldBeDowned()) { if (!forceIncap && dinfo.HasValue && dinfo.Value.Def.ExternalViolenceFor(pawn) && !pawn.IsWildMan() && (pawn.Faction == null || !pawn.Faction.IsPlayer) && (pawn.HostFaction == null || !pawn.HostFaction.IsPlayer)) { float num = (pawn.RaceProps.Animal ? 0.5f : ((!pawn.RaceProps.IsMechanoid) ? (HealthTuning.DeathOnDownedChance_NonColonyHumanlikeFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent) * Find.Storyteller.difficultyValues.enemyDeathOnDownedChanceFactor) : 1f)); if (Rand.Chance(num)) { if (DebugViewSettings.logCauseOfDeath) { Log.Message("CauseOfDeath: chance on downed " + num.ToStringPercent()); } pawn.Kill(dinfo); return; } } forceIncap = false; MakeDowned(dinfo, hediff); } else { if (capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { return; } if (pawn.carryTracker != null && pawn.carryTracker.CarriedThing != null && pawn.jobs != null && pawn.CurJob != null) { pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } if (pawn.equipment == null || pawn.equipment.Primary == null) { return; } if (pawn.kindDef.destroyGearOnDrop) { pawn.equipment.DestroyEquipment(pawn.equipment.Primary); } else if (pawn.InContainerEnclosed) { pawn.equipment.TryTransferEquipmentToContainer(pawn.equipment.Primary, pawn.holdingOwner); } else if (pawn.SpawnedOrAnyParentSpawned) { pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out var _, pawn.PositionHeld); } else if (pawn.IsCaravanMember()) { ThingWithComps primary = pawn.equipment.Primary; pawn.equipment.Remove(primary); if (!pawn.inventory.innerContainer.TryAdd(primary)) { primary.Destroy(); } } else { pawn.equipment.DestroyEquipment(pawn.equipment.Primary); } } } else if (!ShouldBeDowned()) { MakeUndowned(); } }
public virtual void Kill(DamageInfo?dinfo = null, Hediff exactCulprit = null) { Destroy(DestroyMode.KillFinalize); }
private static IEnumerable InfectionSimulatorWorker() { int trials = 2; List <Pawn> doctors = DebugOutputsInfection.GenerateDoctorArray(); List <int> testSkill = new List <int> { 4, 10, 16 }; List <ThingDef> testMedicine = new List <ThingDef> { null, ThingDefOf.MedicineHerbal, ThingDefOf.MedicineIndustrial, ThingDefOf.MedicineUltratech }; PawnGenerationRequest pawngen = new PawnGenerationRequest(PawnKindDefOf.Colonist, Faction.OfPlayer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null); int originalTicks = Find.TickManager.TicksGame; List <DebugOutputsInfection.InfectionSimRow> results = new List <DebugOutputsInfection.InfectionSimRow>(); int totalTests = DebugOutputsInfection.InfectionList().Count <HediffDef>() * testMedicine.Count <ThingDef>() * testSkill.Count <int>() * trials; int currentTest = 0; foreach (HediffDef hediff in DebugOutputsInfection.InfectionList()) { foreach (ThingDef meds in testMedicine) { foreach (int skill in testSkill) { DebugOutputsInfection.InfectionSimRow result = default(DebugOutputsInfection.InfectionSimRow); result.illness = hediff; result.skill = skill; result.medicine = meds; Pawn doctor = doctors[skill]; int i = 0; while (i < trials) { Pawn patient = PawnGenerator.GeneratePawn(pawngen); int startTicks = Find.TickManager.TicksGame; patient.health.AddHediff(result.illness, null, null, null); Hediff activeHediff = patient.health.hediffSet.GetFirstHediffOfDef(result.illness, false); while (!patient.Dead && patient.health.hediffSet.HasHediff(result.illness, false)) { if (activeHediff.TendableNow(false)) { activeHediff.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds), 0); result.medicineUsed += 1f; } foreach (Hediff current in patient.health.hediffSet.GetHediffsTendable()) { current.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds), 0); } Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1); patient.health.HealthTick(); if (Find.TickManager.TicksGame % 900 == 0) { yield return(null); } } if (patient.Dead) { result.deathChance += 1f; } else { result.recoveryTimeDays += (Find.TickManager.TicksGame - startTicks).TicksToDays(); } currentTest++; LongEventHandler.SetCurrentEventText(string.Format("Simulating ({0}/{1})", currentTest, totalTests)); yield return(null); } result.recoveryTimeDays /= (float)trials - result.deathChance; result.deathChance /= (float)trials; result.medicineUsed /= (float)trials; results.Add(result); } } } IEnumerable <DebugOutputsInfection.InfectionSimRow> arg_6D8_0 = results; TableDataGetter <DebugOutputsInfection.InfectionSimRow>[] expr_5DC = new TableDataGetter <DebugOutputsInfection.InfectionSimRow> [6]; expr_5DC[0] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("defName", (DebugOutputsInfection.InfectionSimRow isr) => isr.illness.defName); expr_5DC[1] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("meds", (DebugOutputsInfection.InfectionSimRow isr) => (isr.medicine == null) ? "(none)" : isr.medicine.defName); expr_5DC[2] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("skill", (DebugOutputsInfection.InfectionSimRow isr) => isr.skill.ToString()); expr_5DC[3] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("death chance", (DebugOutputsInfection.InfectionSimRow isr) => isr.deathChance.ToStringPercent()); expr_5DC[4] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("recovery time (days)", (DebugOutputsInfection.InfectionSimRow isr) => isr.recoveryTimeDays.ToString("F1")); expr_5DC[5] = new TableDataGetter <DebugOutputsInfection.InfectionSimRow>("medicine used", (DebugOutputsInfection.InfectionSimRow isr) => isr.medicineUsed.ToString()); DebugTables.MakeTablesDialog <DebugOutputsInfection.InfectionSimRow>(arg_6D8_0, expr_5DC); Find.TickManager.DebugSetTicksGame(originalTicks); }
public override void PostExposeData(object obj) { if (Scribe.mode == LoadSaveMode.PostLoadInit) { Map map = obj as Map; if (map != null) { if (map.retainedCaravanData == null) { map.retainedCaravanData = new RetainedCaravanData(map); } if (map.wildAnimalSpawner == null) { map.wildAnimalSpawner = new WildAnimalSpawner(map); } if (map.wildPlantSpawner == null) { map.wildPlantSpawner = new WildPlantSpawner(map); } } Thing thing = obj as Thing; if (thing != null && thing.def.useHitPoints && thing.MaxHitPoints != thing.HitPoints && Mathf.Abs((float)thing.HitPoints / (float)thing.MaxHitPoints - 0.617f) < 0.02f && thing.Stuff == ThingDefOf.WoodLog) { thing.HitPoints = thing.MaxHitPoints; } Pawn pawn = obj as Pawn; if (pawn != null && !pawn.Destroyed && !pawn.Dead && pawn.needs == null) { Log.Error(pawn.ToStringSafe() + " has null needs tracker even though he's not dead. Fixing..."); pawn.needs = new Pawn_NeedsTracker(pawn); pawn.needs.SetInitialLevels(); } History history = obj as History; if (history != null && history.archive == null) { history.archive = new Archive(); } WorldInfo worldInfo = obj as WorldInfo; if (worldInfo != null && worldInfo.persistentRandomValue == 0) { worldInfo.persistentRandomValue = Rand.Int; } Caravan caravan = obj as Caravan; if (caravan != null) { if (caravan.forage == null) { caravan.forage = new Caravan_ForageTracker(caravan); } if (caravan.needs == null) { caravan.needs = new Caravan_NeedsTracker(caravan); } if (caravan.carryTracker == null) { caravan.carryTracker = new Caravan_CarryTracker(caravan); } if (caravan.beds == null) { caravan.beds = new Caravan_BedsTracker(caravan); } } PlaySettings playSettings = obj as PlaySettings; if (playSettings != null) { playSettings.defaultCareForColonyHumanlike = MedicalCareCategory.Best; playSettings.defaultCareForColonyAnimal = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForColonyPrisoner = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForNeutralFaction = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForNeutralAnimal = MedicalCareCategory.HerbalOrWorse; playSettings.defaultCareForHostileFaction = MedicalCareCategory.HerbalOrWorse; } } if (Scribe.mode == LoadSaveMode.LoadingVars) { Hediff hediff = obj as Hediff; if (hediff != null) { Scribe_Values.Look(ref hediff.temp_partIndexToSetLater, "partIndex", -1); } Bill_Medical bill_Medical = obj as Bill_Medical; if (bill_Medical != null) { Scribe_Values.Look(ref bill_Medical.temp_partIndexToSetLater, "partIndex", -1); } FactionRelation factionRelation = obj as FactionRelation; if (factionRelation != null) { bool value = false; Scribe_Values.Look(ref value, "hostile", defaultValue: false); if (value || factionRelation.goodwill <= -75) { factionRelation.kind = FactionRelationKind.Hostile; } else if (factionRelation.goodwill >= 75) { factionRelation.kind = FactionRelationKind.Ally; } } HediffComp_GetsPermanent hediffComp_GetsPermanent = obj as HediffComp_GetsPermanent; if (hediffComp_GetsPermanent != null) { bool value2 = false; Scribe_Values.Look(ref value2, "isOld", defaultValue: false); if (value2) { hediffComp_GetsPermanent.isPermanentInt = true; } } if (obj is World) { UniqueIDsManager target = null; Scribe_Deep.Look(ref target, "uniqueIDsManager"); if (target != null) { Current.Game.uniqueIDsManager = target; } } WorldFeature worldFeature = obj as WorldFeature; if (worldFeature != null && worldFeature.maxDrawSizeInTiles == 0f) { Vector2 value3 = Vector2.zero; Scribe_Values.Look(ref value3, "maxDrawSizeInTiles"); worldFeature.maxDrawSizeInTiles = value3.x; } } if (Scribe.mode != LoadSaveMode.ResolvingCrossRefs) { return; } Hediff hediff2 = obj as Hediff; if (hediff2 != null && hediff2.temp_partIndexToSetLater >= 0 && hediff2.pawn != null) { if (hediff2.temp_partIndexToSetLater == 0) { hediff2.Part = hediff2.pawn.RaceProps.body.GetPartAtIndex(hediff2.temp_partIndexToSetLater); } else { hediff2.pawn.health.hediffSet.hediffs.Remove(hediff2); } hediff2.temp_partIndexToSetLater = -1; } Bill_Medical bill_Medical2 = obj as Bill_Medical; if (bill_Medical2 != null) { if (bill_Medical2.temp_partIndexToSetLater == 0) { bill_Medical2.Part = bill_Medical2.GiverPawn.RaceProps.body.GetPartAtIndex(bill_Medical2.temp_partIndexToSetLater); } else { bill_Medical2.GiverPawn.BillStack.Bills.Remove(bill_Medical2); } bill_Medical2.temp_partIndexToSetLater = -1; } }
public void HealthTick() { if (this.Dead) { return; } for (int i = this.hediffSet.hediffs.Count - 1; i >= 0; i--) { Hediff hediff = this.hediffSet.hediffs[i]; hediff.Tick(); hediff.PostTick(); } bool flag = false; for (int j = this.hediffSet.hediffs.Count - 1; j >= 0; j--) { Hediff hediff2 = this.hediffSet.hediffs[j]; if (hediff2.ShouldRemove) { this.hediffSet.hediffs.RemoveAt(j); hediff2.PostRemoved(); flag = true; } } if (flag) { this.Notify_HediffChanged(null); } if (this.Dead) { return; } this.immunity.ImmunityHandlerTick(); if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { bool flag2 = false; if (this.hediffSet.HasNaturallyHealingInjury()) { float num = 8f; if (this.pawn.GetPosture() != PawnPosture.Standing) { num += 4f; Building_Bed building_Bed = this.pawn.CurrentBed(); if (building_Bed != null) { num += building_Bed.def.building.bed_healPerDay; } } Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealNaturally)).RandomElement <Hediff_Injury>(); hediff_Injury.Heal(num * this.pawn.HealthScale * 0.01f); flag2 = true; } if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealFromTending)).RandomElement <Hediff_Injury>(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num2 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal(22f * num2 * this.pawn.HealthScale * 0.01f); flag2 = true; } if (flag2 && !this.HasHediffsNeedingTendByColony(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn)) { Messages.Message("MessageFullyHealed".Translate(new object[] { this.pawn.LabelCap }), this.pawn, MessageTypeDefOf.PositiveEvent); } } if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.1f) { float num3 = this.hediffSet.BleedRateTotal * this.pawn.BodySize; if (this.pawn.GetPosture() == PawnPosture.Standing) { num3 *= 0.008f; } else { num3 *= 0.0008f; } if (Rand.Value < num3) { this.TryDropBloodFilth(); } } List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null && this.pawn.IsHashIntervalTick(60)) { for (int k = 0; k < hediffGiverSets.Count; k++) { List <HediffGiver> hediffGivers = hediffGiverSets[k].hediffGivers; for (int l = 0; l < hediffGivers.Count; l++) { hediffGivers[l].OnIntervalPassed(this.pawn, null); if (this.pawn.Dead) { return; } } } } }
private static bool <Notify_Resurrected> m__0(Hediff x) { return(x.def.everCurableByItem && x.TryGetComp <HediffComp_Immunizable>() != null); }
public void HealthTick() { if (!Dead) { for (int num = hediffSet.hediffs.Count - 1; num >= 0; num--) { Hediff hediff = hediffSet.hediffs[num]; try { hediff.Tick(); hediff.PostTick(); } catch (Exception ex) { Log.Error("Exception ticking hediff " + hediff.ToStringSafe() + " for pawn " + pawn.ToStringSafe() + ". Removing hediff... Exception: " + ex); try { RemoveHediff(hediff); } catch (Exception arg) { Log.Error("Error while removing hediff: " + arg); } } } bool flag = false; for (int num2 = hediffSet.hediffs.Count - 1; num2 >= 0; num2--) { Hediff hediff2 = hediffSet.hediffs[num2]; if (hediff2.ShouldRemove) { hediffSet.hediffs.RemoveAt(num2); hediff2.PostRemoved(); flag = true; } } if (flag) { Notify_HediffChanged(null); } if (!Dead) { immunity.ImmunityHandlerTick(); if (pawn.RaceProps.IsFlesh && pawn.IsHashIntervalTick(600) && (pawn.needs.food == null || !pawn.needs.food.Starving)) { bool flag2 = false; if (hediffSet.HasNaturallyHealingInjury()) { float num3 = 8f; if (pawn.GetPosture() != 0) { num3 += 4f; Building_Bed building_Bed = pawn.CurrentBed(); if (building_Bed != null) { num3 += building_Bed.def.building.bed_healPerDay; } } Hediff_Injury hediff_Injury = hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealNaturally).RandomElement(); hediff_Injury.Heal(num3 * pawn.HealthScale * 0.01f); flag2 = true; } if (hediffSet.HasTendedAndHealingInjury() && (pawn.needs.food == null || !pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury2 = hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealFromTending).RandomElement(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num4 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal(8f * num4 * pawn.HealthScale * 0.01f); flag2 = true; } if (flag2 && !HasHediffsNeedingTendByPlayer() && !HealthAIUtility.ShouldSeekMedicalRest(pawn) && !hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(pawn)) { Messages.Message("MessageFullyHealed".Translate(pawn.LabelCap, pawn), pawn, MessageTypeDefOf.PositiveEvent); } } if (pawn.RaceProps.IsFlesh && hediffSet.BleedRateTotal >= 0.1f) { float num5 = hediffSet.BleedRateTotal * pawn.BodySize; num5 = ((pawn.GetPosture() != 0) ? (num5 * 0.0004f) : (num5 * 0.004f)); if (Rand.Value < num5) { DropBloodFilth(); } } if (pawn.IsHashIntervalTick(60)) { List <HediffGiverSetDef> hediffGiverSets = pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null) { for (int i = 0; i < hediffGiverSets.Count; i++) { List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers; for (int j = 0; j < hediffGivers.Count; j++) { hediffGivers[j].OnIntervalPassed(pawn, null); if (pawn.Dead) { return; } } } } if (pawn.story != null) { List <Trait> allTraits = pawn.story.traits.allTraits; for (int k = 0; k < allTraits.Count; k++) { TraitDegreeData currentData = allTraits[k].CurrentData; if (currentData.randomDiseaseMtbDays > 0f && Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f)) { BiomeDef biome; if (pawn.Tile != -1) { biome = Find.WorldGrid[pawn.Tile].biome; } else { biome = DefDatabase <BiomeDef> .GetRandom(); } IncidentDef incidentDef = (from d in DefDatabase <IncidentDef> .AllDefs where d.category == IncidentCategoryDefOf.DiseaseHuman select d).RandomElementByWeightWithFallback((IncidentDef d) => biome.CommonalityOfDisease(d)); if (incidentDef != null) { string blockedInfo; List <Pawn> list = ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle(pawn), out blockedInfo); if (PawnUtility.ShouldSendNotificationAbout(pawn)) { if (list.Contains(pawn)) { Find.LetterStack.ReceiveLetter("LetterLabelTraitDisease".Translate(incidentDef.diseaseIncident.label), "LetterTraitDisease".Translate(pawn.LabelCap, incidentDef.diseaseIncident.label, pawn.Named("PAWN")).AdjustedFor(pawn), LetterDefOf.NegativeEvent, pawn); } else if (!blockedInfo.NullOrEmpty()) { Messages.Message(blockedInfo, pawn, MessageTypeDefOf.NeutralEvent); } } } } } } } } } }
private static bool TryResolveSymbol(object obj, string subSymbol, string symbolArgs, out TaggedString resolvedStr, string fullStringForReference) { Pawn pawn = obj as Pawn; if (pawn != null) { switch (subSymbol) { case "": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Name.ToStringShort, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelIndefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "nameFull": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Name.ToStringFull, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelIndefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "nameFullDef": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.Name.ToStringFull, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelDefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "label": resolvedStr = pawn.LabelNoCountColored; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelShort": resolvedStr = ((pawn.Name != null) ? pawn.Name.ToStringShort.ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabel)); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "definite": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.Name.ToStringShort, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelDefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "nameDef": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.Name.ToStringShort, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelDefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "indefinite": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Name.ToStringShort, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelIndefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "nameIndef": resolvedStr = ((pawn.Name != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Name.ToStringShort, pawn.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)pawn.KindLabelIndefinite())); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pronoun": resolvedStr = pawn.gender.GetPronoun(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "possessive": resolvedStr = pawn.gender.GetPossessive(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "objective": resolvedStr = pawn.gender.GetObjective(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionName": resolvedStr = ((pawn.Faction != null) ? pawn.Faction.Name.ApplyTag(pawn.Faction) : ((TaggedString)"")); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnSingular": resolvedStr = ((pawn.Faction != null) ? pawn.Faction.def.pawnSingular : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnSingularDef": resolvedStr = ((pawn.Faction != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.Faction.def.pawnSingular) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnSingularIndef": resolvedStr = ((pawn.Faction != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Faction.def.pawnSingular) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnsPlural": resolvedStr = ((pawn.Faction != null) ? pawn.Faction.def.pawnsPlural : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnsPluralDef": resolvedStr = ((pawn.Faction != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.Faction.def.pawnsPlural, LanguageDatabase.activeLanguage.ResolveGender(pawn.Faction.def.pawnsPlural, pawn.Faction.def.pawnSingular), plural: true) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionPawnsPluralIndef": resolvedStr = ((pawn.Faction != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.Faction.def.pawnsPlural, LanguageDatabase.activeLanguage.ResolveGender(pawn.Faction.def.pawnsPlural, pawn.Faction.def.pawnSingular), plural: true) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionRoyalFavorLabel": resolvedStr = ((pawn.Faction != null) ? pawn.Faction.def.royalFavorLabel : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kind": resolvedStr = pawn.KindLabel; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindDef": resolvedStr = pawn.KindLabelDefinite(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindIndef": resolvedStr = pawn.KindLabelIndefinite(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindPlural": resolvedStr = pawn.GetKindLabelPlural(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.GetKindLabelPlural(), pawn.gender, plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.GetKindLabelPlural(), pawn.gender, plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBase": resolvedStr = pawn.kindDef.label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBaseDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.kindDef.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBaseIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.kindDef.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBasePlural": resolvedStr = pawn.kindDef.GetLabelPlural(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBasePluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.kindDef.GetLabelPlural(), LanguageDatabase.activeLanguage.ResolveGender(pawn.kindDef.GetLabelPlural(), pawn.kindDef.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "kindBasePluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.kindDef.GetLabelPlural(), LanguageDatabase.activeLanguage.ResolveGender(pawn.kindDef.GetLabelPlural(), pawn.kindDef.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "race": resolvedStr = pawn.def.label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "raceDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "raceIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "lifeStage": resolvedStr = pawn.ageTracker.CurLifeStage.label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "lifeStageDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.ageTracker.CurLifeStage.label, pawn.gender); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "lifeStageIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.ageTracker.CurLifeStage.label, pawn.gender); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "lifeStageAdjective": resolvedStr = pawn.ageTracker.CurLifeStage.Adjective; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "title": resolvedStr = ((pawn.story != null) ? pawn.story.Title : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "titleDef": resolvedStr = ((pawn.story != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(pawn.story.Title, pawn.gender) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "titleIndef": resolvedStr = ((pawn.story != null) ? Find.ActiveLanguageWorker.WithIndefiniteArticle(pawn.story.Title, pawn.gender) : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "bestRoyalTitle": resolvedStr = PawnResolveBestRoyalTitle(pawn); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "bestRoyalTitleIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(PawnResolveBestRoyalTitle(pawn)); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "bestRoyalTitleDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(PawnResolveBestRoyalTitle(pawn)); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "royalTitleInCurrentFaction": resolvedStr = PawnResolveRoyalTitleInCurrentFaction(pawn); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "royalTitleInCurrentFactionIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(PawnResolveRoyalTitleInCurrentFaction(pawn)); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "royalTitleInCurrentFactionDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(PawnResolveRoyalTitleInCurrentFaction(pawn)); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "age": resolvedStr = pawn.ageTracker.AgeBiologicalYears.ToString(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "chronologicalAge": resolvedStr = pawn.ageTracker.AgeChronologicalYears.ToString(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "ageFull": resolvedStr = pawn.ageTracker.AgeNumberString; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "relationInfo": { resolvedStr = ""; TaggedString text = resolvedStr; PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn); resolvedStr = text.RawText; return(true); } case "relationInfoInParentheses": resolvedStr = ""; PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref resolvedStr, pawn); if (!resolvedStr.NullOrEmpty()) { resolvedStr = "(" + resolvedStr + ")"; } return(true); case "gender": resolvedStr = ResolveGenderSymbol(pawn.gender, pawn.RaceProps.Animal, symbolArgs, fullStringForReference); return(true); case "humanlike": resolvedStr = ResolveHumanlikeSymbol(pawn.RaceProps.Humanlike, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } Thing thing = obj as Thing; if (thing != null) { switch (subSymbol) { case "": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(thing.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "label": resolvedStr = thing.Label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPlural": resolvedStr = Find.ActiveLanguageWorker.Pluralize(thing.LabelNoCount); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(Find.ActiveLanguageWorker.Pluralize(thing.LabelNoCount), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(thing.LabelNoCount), thing.LabelNoCount), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(Find.ActiveLanguageWorker.Pluralize(thing.LabelNoCount), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(thing.LabelNoCount), thing.LabelNoCount), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelShort": resolvedStr = thing.LabelShort; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "definite": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(thing.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "indefinite": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(thing.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pronoun": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(thing.LabelNoCount).GetPronoun(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "possessive": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(thing.LabelNoCount).GetPossessive(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "objective": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(thing.LabelNoCount).GetObjective(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionName": resolvedStr = ((thing.Faction != null) ? thing.Faction.Name : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "gender": resolvedStr = ResolveGenderSymbol(LanguageDatabase.activeLanguage.ResolveGender(thing.LabelNoCount), animal: false, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } Hediff hediff = obj as Hediff; if (hediff != null) { if (subSymbol == "label") { resolvedStr = hediff.Label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } if (subSymbol == "labelNoun") { resolvedStr = ((!hediff.def.labelNoun.NullOrEmpty()) ? hediff.def.labelNoun : hediff.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } } WorldObject worldObject = obj as WorldObject; if (worldObject != null) { switch (subSymbol) { case "": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(worldObject.Label, plural: false, worldObject.HasName); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "label": resolvedStr = worldObject.Label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPlural": resolvedStr = Find.ActiveLanguageWorker.Pluralize(worldObject.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(Find.ActiveLanguageWorker.Pluralize(worldObject.Label), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(worldObject.Label), worldObject.Label), plural: true, worldObject.HasName); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(Find.ActiveLanguageWorker.Pluralize(worldObject.Label), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(worldObject.Label), worldObject.Label), plural: true, worldObject.HasName); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "definite": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(worldObject.Label, plural: false, worldObject.HasName); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "indefinite": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(worldObject.Label, plural: false, worldObject.HasName); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pronoun": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(worldObject.Label).GetPronoun(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "possessive": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(worldObject.Label).GetPossessive(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "objective": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(worldObject.Label).GetObjective(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "factionName": resolvedStr = ((worldObject.Faction != null) ? worldObject.Faction.Name.ApplyTag(worldObject.Faction) : ((TaggedString)"")); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "gender": resolvedStr = ResolveGenderSymbol(LanguageDatabase.activeLanguage.ResolveGender(worldObject.Label), animal: false, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } Faction faction = obj as Faction; if (faction != null) { switch (subSymbol) { case "": resolvedStr = faction.Name.ApplyTag(faction); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "name": resolvedStr = faction.Name.ApplyTag(faction); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnSingular": resolvedStr = faction.def.pawnSingular; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnSingularDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(faction.def.pawnSingular); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnSingularIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(faction.def.pawnSingular); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnsPlural": resolvedStr = faction.def.pawnsPlural; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnsPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(faction.def.pawnsPlural, LanguageDatabase.activeLanguage.ResolveGender(faction.def.pawnsPlural, faction.def.pawnSingular), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pawnsPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(faction.def.pawnsPlural, LanguageDatabase.activeLanguage.ResolveGender(faction.def.pawnsPlural, faction.def.pawnSingular), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "royalFavorLabel": resolvedStr = faction.def.royalFavorLabel; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "leaderNameDef": resolvedStr = ((faction.leader != null && faction.leader.Name != null) ? Find.ActiveLanguageWorker.WithDefiniteArticle(faction.leader.Name.ToStringShort, faction.leader.gender, plural: false, name: true).ApplyTag(TagType.Name) : ((TaggedString)"")); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "leaderPossessive": resolvedStr = ((faction.leader != null) ? faction.leader.gender.GetPossessive() : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "leaderObjective": resolvedStr = ((faction.leader != null) ? faction.leader.gender.GetObjective() : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "leaderPronoun": resolvedStr = ((faction.leader != null) ? faction.leader.gender.GetPronoun() : ""); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } Def def = obj as Def; if (def != null) { PawnKindDef pawnKindDef = def as PawnKindDef; if (pawnKindDef != null) { switch (subSymbol) { case "labelPlural": resolvedStr = pawnKindDef.GetLabelPlural(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(pawnKindDef.GetLabelPlural(), LanguageDatabase.activeLanguage.ResolveGender(pawnKindDef.GetLabelPlural(), pawnKindDef.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(pawnKindDef.GetLabelPlural(), LanguageDatabase.activeLanguage.ResolveGender(pawnKindDef.GetLabelPlural(), pawnKindDef.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } } switch (subSymbol) { case "": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "label": resolvedStr = def.label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPlural": resolvedStr = Find.ActiveLanguageWorker.Pluralize(def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(Find.ActiveLanguageWorker.Pluralize(def.label), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(def.label), def.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "labelPluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(Find.ActiveLanguageWorker.Pluralize(def.label), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(def.label), def.label), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "definite": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "indefinite": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(def.label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pronoun": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(def.label).GetPronoun(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "possessive": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(def.label).GetPossessive(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "objective": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(def.label).GetObjective(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "gender": resolvedStr = ResolveGenderSymbol(LanguageDatabase.activeLanguage.ResolveGender(def.label), animal: false, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } RoyalTitle royalTitle = obj as RoyalTitle; if (royalTitle != null) { if (subSymbol == null || subSymbol.Length != 0) { if (!(subSymbol == "label")) { if (subSymbol == "indefinite") { resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticlePostProcessed(royalTitle.Label); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } resolvedStr = ""; return(false); } resolvedStr = royalTitle.Label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } resolvedStr = royalTitle.Label; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } string text2 = obj as string; if (text2 != null) { switch (subSymbol) { case "": resolvedStr = text2; EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "plural": resolvedStr = Find.ActiveLanguageWorker.Pluralize(text2); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pluralDef": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(Find.ActiveLanguageWorker.Pluralize(text2), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(text2), text2), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pluralIndef": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(Find.ActiveLanguageWorker.Pluralize(text2), LanguageDatabase.activeLanguage.ResolveGender(Find.ActiveLanguageWorker.Pluralize(text2), text2), plural: true); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "definite": resolvedStr = Find.ActiveLanguageWorker.WithDefiniteArticle(text2); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "indefinite": resolvedStr = Find.ActiveLanguageWorker.WithIndefiniteArticle(text2); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "pronoun": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(text2).GetPronoun(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "possessive": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(text2).GetPossessive(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "objective": resolvedStr = LanguageDatabase.activeLanguage.ResolveGender(text2).GetObjective(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); case "gender": resolvedStr = ResolveGenderSymbol(LanguageDatabase.activeLanguage.ResolveGender(text2), animal: false, symbolArgs, fullStringForReference); return(true); default: resolvedStr = ""; return(false); } } if (obj is int || obj is long) { int num = (int)((obj is int) ? ((int)obj) : ((long)obj)); if (subSymbol == null || subSymbol.Length != 0) { if (!(subSymbol == "ordinal")) { if (subSymbol == "multiple") { resolvedStr = ResolveMultipleSymbol(num, symbolArgs, fullStringForReference); return(true); } resolvedStr = ""; return(false); } resolvedStr = Find.ActiveLanguageWorker.OrdinalNumber(num).ToString(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } resolvedStr = num.ToString(); EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); return(true); } if (obj is TaggedString) { EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); resolvedStr = ((TaggedString)obj).RawText; } if (subSymbol.NullOrEmpty()) { EnsureNoArgs(subSymbol, symbolArgs, fullStringForReference); if (obj == null) { resolvedStr = ""; } else { resolvedStr = obj.ToString(); } return(true); } resolvedStr = ""; return(false); }
public void HealthTick() { if (this.Dead) { return; } for (int i = this.hediffSet.hediffs.Count - 1; i >= 0; i--) { Hediff hediff = this.hediffSet.hediffs[i]; try { hediff.Tick(); hediff.PostTick(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception ticking hediff ", hediff.ToStringSafe <Hediff>(), " for pawn ", this.pawn.ToStringSafe <Pawn>(), ". Removing hediff... Exception: ", ex }), false); try { this.RemoveHediff(hediff); } catch (Exception arg) { Log.Error("Error while removing hediff: " + arg, false); } } } bool flag = false; for (int j = this.hediffSet.hediffs.Count - 1; j >= 0; j--) { Hediff hediff2 = this.hediffSet.hediffs[j]; if (hediff2.ShouldRemove) { this.hediffSet.hediffs.RemoveAt(j); hediff2.PostRemoved(); flag = true; } } if (flag) { this.Notify_HediffChanged(null); } if (this.Dead) { return; } this.immunity.ImmunityHandlerTick(); if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { bool flag2 = false; if (this.hediffSet.HasNaturallyHealingInjury()) { float num = 8f; if (this.pawn.GetPosture() != PawnPosture.Standing) { num += 4f; Building_Bed building_Bed = this.pawn.CurrentBed(); if (building_Bed != null) { num += building_Bed.def.building.bed_healPerDay; } } Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealNaturally)).RandomElement <Hediff_Injury>(); hediff_Injury.Heal(num * this.pawn.HealthScale * 0.01f); flag2 = true; } if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(new Func <Hediff_Injury, bool>(HediffUtility.CanHealFromTending)).RandomElement <Hediff_Injury>(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num2 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal(8f * num2 * this.pawn.HealthScale * 0.01f); flag2 = true; } if (flag2 && !this.HasHediffsNeedingTendByPlayer(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn)) { Messages.Message("MessageFullyHealed".Translate(this.pawn.LabelCap, this.pawn), this.pawn, MessageTypeDefOf.PositiveEvent, true); } } if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.1f) { float num3 = this.hediffSet.BleedRateTotal * this.pawn.BodySize; if (this.pawn.GetPosture() == PawnPosture.Standing) { num3 *= 0.004f; } else { num3 *= 0.0004f; } if (Rand.Value < num3) { this.DropBloodFilth(); } } if (this.pawn.IsHashIntervalTick(60)) { List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null) { for (int k = 0; k < hediffGiverSets.Count; k++) { List <HediffGiver> hediffGivers = hediffGiverSets[k].hediffGivers; for (int l = 0; l < hediffGivers.Count; l++) { hediffGivers[l].OnIntervalPassed(this.pawn, null); if (this.pawn.Dead) { return; } } } } if (this.pawn.story != null) { List <Trait> allTraits = this.pawn.story.traits.allTraits; for (int m = 0; m < allTraits.Count; m++) { TraitDegreeData currentData = allTraits[m].CurrentData; if (currentData.randomDiseaseMtbDays > 0f && Rand.MTBEventOccurs(currentData.randomDiseaseMtbDays, 60000f, 60f)) { BiomeDef biome; if (this.pawn.Tile != -1) { biome = Find.WorldGrid[this.pawn.Tile].biome; } else { biome = DefDatabase <BiomeDef> .GetRandom(); } IncidentDef incidentDef = (from d in DefDatabase <IncidentDef> .AllDefs where d.category == IncidentCategoryDefOf.DiseaseHuman select d).RandomElementByWeightWithFallback((IncidentDef d) => biome.CommonalityOfDisease(d), null); if (incidentDef != null) { string text; List <Pawn> list = ((IncidentWorker_Disease)incidentDef.Worker).ApplyToPawns(Gen.YieldSingle <Pawn>(this.pawn), out text); if (PawnUtility.ShouldSendNotificationAbout(this.pawn)) { if (list.Contains(this.pawn)) { Find.LetterStack.ReceiveLetter("LetterLabelTraitDisease".Translate(incidentDef.diseaseIncident.label), "LetterTraitDisease".Translate(this.pawn.LabelCap, incidentDef.diseaseIncident.label, this.pawn.Named("PAWN")).AdjustedFor(this.pawn, "PAWN"), LetterDefOf.NegativeEvent, this.pawn, null, null); } else if (!text.NullOrEmpty()) { Messages.Message(text, this.pawn, MessageTypeDefOf.NeutralEvent, true); } } } } } } } }
public void AddDirect(Hediff hediff, DamageInfo?dinfo = null) { if (hediff.def == null) { Log.Error("Tried to add health diff with null def. Canceling."); return; } if (hediff.Part != null && !this.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Contains(hediff.Part)) { Log.Error("Tried to add health diff to missing part " + hediff.Part); return; } hediff.ageTicks = 0; hediff.pawn = this.pawn; bool flag = false; for (int i = 0; i < this.hediffs.Count; i++) { if (this.hediffs[i].TryMergeWith(hediff)) { flag = true; } } if (!flag) { this.hediffs.Add(hediff); hediff.PostAdd(dinfo); if (this.pawn.needs != null && this.pawn.needs.mood != null) { this.pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty(); } } bool flag2 = hediff is Hediff_MissingPart; if (!(hediff is Hediff_MissingPart) && hediff.Part != null && hediff.Part != this.pawn.RaceProps.body.corePart && this.GetPartHealth(hediff.Part) == 0f && hediff.Part != this.pawn.RaceProps.body.corePart) { bool flag3 = this.HasDirectlyAddedPartFor(hediff.Part); Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, this.pawn, null); hediff_MissingPart.IsFresh = !flag3; hediff_MissingPart.lastInjury = hediff.def; this.pawn.health.AddHediff(hediff_MissingPart, hediff.Part, dinfo); if (flag3) { if (dinfo.HasValue) { hediff_MissingPart.lastInjury = HealthUtility.GetHediffDefFromDamage(dinfo.Value.Def, this.pawn, hediff.Part); } else { hediff_MissingPart.lastInjury = null; } } flag2 = true; } this.DirtyCache(); if (flag2 && this.pawn.apparel != null) { this.pawn.apparel.Notify_LostBodyPart(); } if (hediff.def.causesNeed != null && !this.pawn.Dead) { this.pawn.needs.AddOrRemoveNeedsAsAppropriate(); } }
public void CheckForStateChange(DamageInfo?dinfo, Hediff hediff) { if (!this.Dead) { if (this.ShouldBeDead()) { if (!this.pawn.Destroyed) { this.pawn.Kill(dinfo, hediff); } return; } if (!this.Downed) { if (this.ShouldBeDowned()) { if (!this.forceIncap && dinfo.HasValue && dinfo.Value.Def.ExternalViolenceFor(this.pawn) && !this.pawn.IsWildMan() && (this.pawn.Faction == null || !this.pawn.Faction.IsPlayer) && (this.pawn.HostFaction == null || !this.pawn.HostFaction.IsPlayer)) { float chance; if (this.pawn.RaceProps.Animal) { chance = 0.5f; } else if (this.pawn.RaceProps.IsMechanoid) { chance = 1f; } else { chance = HealthTuning.DeathOnDownedChance_NonColonyHumanlikeFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent) * Find.Storyteller.difficulty.enemyDeathOnDownedChanceFactor; } if (Rand.Chance(chance)) { this.pawn.Kill(dinfo, null); return; } } this.forceIncap = false; this.MakeDowned(dinfo, hediff); return; } if (!this.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { if (this.pawn.carryTracker != null && this.pawn.carryTracker.CarriedThing != null && this.pawn.jobs != null && this.pawn.CurJob != null) { this.pawn.jobs.EndCurrentJob(JobCondition.InterruptForced, true); } if (this.pawn.equipment != null && this.pawn.equipment.Primary != null) { if (this.pawn.kindDef.destroyGearOnDrop) { this.pawn.equipment.DestroyEquipment(this.pawn.equipment.Primary); } else if (this.pawn.InContainerEnclosed) { this.pawn.equipment.TryTransferEquipmentToContainer(this.pawn.equipment.Primary, this.pawn.holdingOwner); } else if (this.pawn.SpawnedOrAnyParentSpawned) { ThingWithComps thingWithComps; this.pawn.equipment.TryDropEquipment(this.pawn.equipment.Primary, out thingWithComps, this.pawn.PositionHeld, true); } else { this.pawn.equipment.DestroyEquipment(this.pawn.equipment.Primary); } } } } else if (!this.ShouldBeDowned()) { this.MakeUndowned(); return; } } }
private bool <Notify_Resurrected> m__3(Hediff x) { return(x.def.everCurableByItem && x is Hediff_Injury && x.IsPermanent() && this.hediffSet.GetPartHealth(x.Part) <= 0f); }
private static bool <Notify_Resurrected> m__1(Hediff x) { return(x.def.everCurableByItem && x is Hediff_Injury && !x.IsPermanent()); }
public BattleLogEntry_StateTransition(Thing subject, RulePackDef transitionDef, Pawn initiator, Hediff culpritHediff, BodyPartRecord culpritTargetDef) { if (subject is Pawn) { subjectPawn = (subject as Pawn); } else if (subject != null) { subjectThing = subject.def; } this.transitionDef = transitionDef; this.initiator = initiator; if (culpritHediff != null) { culpritHediffDef = culpritHediff.def; if (culpritHediff.Part != null) { culpritHediffTargetPart = culpritHediff.Part; } } culpritTargetPart = culpritTargetDef; }
public static IEnumerable <StatDrawEntry> SpecialDisplayStats(HediffStage stage, Hediff instance) { if (instance != null && instance.Bleeding) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "BleedingRate".Translate(), instance.BleedRate.ToStringPercent() + "/" + "LetterDay".Translate(), 0, string.Empty)); } float painOffsetToDisplay = 0f; if (instance != null) { painOffsetToDisplay = instance.PainOffset; } else if (stage != null) { painOffsetToDisplay = stage.painOffset; } if (painOffsetToDisplay != 0f) { if (painOffsetToDisplay > 0f && painOffsetToDisplay < 0.01f) { painOffsetToDisplay = 0.01f; } if (painOffsetToDisplay < 0f && painOffsetToDisplay > -0.01f) { painOffsetToDisplay = -0.01f; } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Pain".Translate(), (painOffsetToDisplay * 100f).ToString("+###0;-###0") + "%", 0, string.Empty)); } float painFactorToDisplay = 1f; if (instance != null) { painFactorToDisplay = instance.PainFactor; } else if (stage != null) { painFactorToDisplay = stage.painFactor; } if (painFactorToDisplay != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Pain".Translate(), "x" + painFactorToDisplay.ToStringPercent(), 0, string.Empty)); } if (stage != null && stage.partEfficiencyOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PartEfficiency".Translate(), stage.partEfficiencyOffset.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Offset), 0, string.Empty)); } List <PawnCapacityModifier> capModsToDisplay = null; if (instance != null) { capModsToDisplay = instance.CapMods; } else if (stage != null) { capModsToDisplay = stage.capMods; } if (capModsToDisplay != null) { for (int i = 0; i < capModsToDisplay.Count; i++) { if (capModsToDisplay[i].offset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[i].capacity.GetLabelFor(true, true).CapitalizeFirst(), (capModsToDisplay[i].offset * 100f).ToString("+#;-#") + "%", 0, string.Empty)); } if (capModsToDisplay[i].postFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[i].capacity.GetLabelFor(true, true).CapitalizeFirst(), "x" + capModsToDisplay[i].postFactor.ToStringPercent(), 0, string.Empty)); } if (capModsToDisplay[i].SetMaxDefined) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[i].capacity.GetLabelFor(true, true).CapitalizeFirst(), "max".Translate() + " " + capModsToDisplay[i].setMax.ToStringPercent(), 0, string.Empty)); } } } if (stage != null) { if (stage.AffectsMemory || stage.AffectsSocialInteractions) { StringBuilder affectsSb = new StringBuilder(); if (stage.AffectsMemory) { if (affectsSb.Length != 0) { affectsSb.Append(", "); } affectsSb.Append("MemoryLower".Translate()); } if (stage.AffectsSocialInteractions) { if (affectsSb.Length != 0) { affectsSb.Append(", "); } affectsSb.Append("SocialInteractionsLower".Translate()); } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Affects".Translate(), affectsSb.ToString(), 0, string.Empty)); } if (stage.hungerRateFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HungerRate".Translate(), "x" + stage.hungerRateFactor.ToStringPercent(), 0, string.Empty)); } if (stage.hungerRateFactorOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HungerRate".Translate(), stage.hungerRateFactorOffset.ToStringSign() + stage.hungerRateFactorOffset.ToStringPercent(), 0, string.Empty)); } if (stage.restFallFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Tiredness".Translate(), "x" + stage.restFallFactor.ToStringPercent(), 0, string.Empty)); } if (stage.restFallFactorOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Tiredness".Translate(), stage.restFallFactorOffset.ToStringSign() + stage.restFallFactorOffset.ToStringPercent(), 0, string.Empty)); } if (stage.makeImmuneTo != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PreventsInfection".Translate(), (from im in stage.makeImmuneTo select im.label).ToCommaList(false).CapitalizeFirst(), 0, string.Empty)); } if (stage.statOffsets != null) { for (int j = 0; j < stage.statOffsets.Count; j++) { StatModifier sm = stage.statOffsets[j]; yield return(new StatDrawEntry(StatCategoryDefOf.Basics, sm.stat.LabelCap, sm.ValueToStringAsOffset, 0, string.Empty)); } } } yield break; }
private void MakeDowned(DamageInfo?dinfo, Hediff hediff) { if (Downed) { Log.Error(this.pawn + " tried to do MakeDowned while already downed."); } else { if (this.pawn.guilt != null && this.pawn.GetLord() != null && this.pawn.GetLord().LordJob != null && this.pawn.GetLord().LordJob.GuiltyOnDowned) { this.pawn.guilt.Notify_Guilty(); } healthState = PawnHealthState.Down; PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(this.pawn, dinfo, PawnDiedOrDownedThoughtsKind.Downed); if (this.pawn.InMentalState) { this.pawn.mindState.mentalStateHandler.CurState.RecoverFromState(); } if (this.pawn.Spawned) { this.pawn.DropAndForbidEverything(keepInventoryAndEquipmentIfInBed: true); this.pawn.stances.CancelBusyStanceSoft(); } this.pawn.ClearMind(ifLayingKeepLaying: true); if (Current.ProgramState == ProgramState.Playing) { this.pawn.GetLord()?.Notify_PawnLost(this.pawn, PawnLostCondition.IncappedOrKilled, dinfo); } if (this.pawn.Drafted) { this.pawn.drafter.Drafted = false; } PortraitsCache.SetDirty(this.pawn); if (this.pawn.SpawnedOrAnyParentSpawned) { GenHostility.Notify_PawnLostForTutor(this.pawn, this.pawn.MapHeld); } if (this.pawn.RaceProps.Humanlike && Current.ProgramState == ProgramState.Playing && this.pawn.SpawnedOrAnyParentSpawned) { if (this.pawn.HostileTo(Faction.OfPlayer)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.Capturing, this.pawn, OpportunityType.Important); } if (this.pawn.Faction == Faction.OfPlayer) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.Rescuing, this.pawn, OpportunityType.Critical); } } if (dinfo.HasValue && dinfo.Value.Instigator != null) { Pawn pawn = dinfo.Value.Instigator as Pawn; if (pawn != null) { RecordsUtility.Notify_PawnDowned(this.pawn, pawn); } } if (this.pawn.Spawned) { TaleRecorder.RecordTale(TaleDefOf.Downed, this.pawn, (!dinfo.HasValue) ? null : (dinfo.Value.Instigator as Pawn), (!dinfo.HasValue) ? null : dinfo.Value.Weapon); Find.BattleLog.Add(new BattleLogEntry_StateTransition(this.pawn, RulePackDefOf.Transition_Downed, (!dinfo.HasValue) ? null : (dinfo.Value.Instigator as Pawn), hediff, (!dinfo.HasValue) ? null : dinfo.Value.HitPart)); } Find.Storyteller.Notify_PawnEvent(this.pawn, AdaptationEvent.Downed, dinfo); } }
public void Notify_HediffChanged(Hediff hediff) { this.hediffSet.DirtyCache(); this.CheckForStateChange(null, hediff); }
public void ImmunityTick(Pawn pawn, bool sick, Hediff diseaseInstance) { this.immunity += this.ImmunityChangePerTick(pawn, sick, diseaseInstance); this.immunity = Mathf.Clamp01(this.immunity); }
public void HealthTick() { if (!this.Dead) { for (int num = this.hediffSet.hediffs.Count - 1; num >= 0; num--) { Hediff hediff = this.hediffSet.hediffs[num]; hediff.Tick(); hediff.PostTick(); } bool flag = false; for (int num2 = this.hediffSet.hediffs.Count - 1; num2 >= 0; num2--) { Hediff hediff2 = this.hediffSet.hediffs[num2]; if (hediff2.ShouldRemove) { this.hediffSet.hediffs.RemoveAt(num2); hediff2.PostRemoved(); flag = true; } } if (flag) { this.Notify_HediffChanged(null); } if (!this.Dead) { this.immunity.ImmunityHandlerTick(); if (this.pawn.RaceProps.IsFlesh && this.pawn.IsHashIntervalTick(600) && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { bool flag2 = false; if (this.hediffSet.HasNaturallyHealingInjury()) { float num3 = 8f; if (this.pawn.GetPosture() != 0) { num3 = (float)(num3 + 4.0); Building_Bed building_Bed = this.pawn.CurrentBed(); if (building_Bed != null) { num3 += building_Bed.def.building.bed_healPerDay; } } Hediff_Injury hediff_Injury = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealNaturally).RandomElement(); hediff_Injury.Heal((float)(num3 * this.pawn.HealthScale * 0.0099999997764825821)); flag2 = true; } if (this.hediffSet.HasTendedAndHealingInjury() && (this.pawn.needs.food == null || !this.pawn.needs.food.Starving)) { Hediff_Injury hediff_Injury2 = this.hediffSet.GetHediffs <Hediff_Injury>().Where(HediffUtility.CanHealFromTending).RandomElement(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num4 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); hediff_Injury2.Heal((float)(22.0 * num4 * this.pawn.HealthScale * 0.0099999997764825821)); flag2 = true; } if (flag2 && !this.HasHediffsNeedingTendByColony(false) && !HealthAIUtility.ShouldSeekMedicalRest(this.pawn) && !this.hediffSet.HasTendedAndHealingInjury() && PawnUtility.ShouldSendNotificationAbout(this.pawn)) { Messages.Message("MessageFullyHealed".Translate(this.pawn.LabelCap), this.pawn, MessageTypeDefOf.PositiveEvent); } } if (this.pawn.RaceProps.IsFlesh && this.hediffSet.BleedRateTotal >= 0.10000000149011612) { float num5 = this.hediffSet.BleedRateTotal * this.pawn.BodySize; num5 = (float)((this.pawn.GetPosture() != 0) ? (num5 * 0.00079999997979030013) : (num5 * 0.00800000037997961)); if (Rand.Value < num5) { this.TryDropBloodFilth(); } } List <HediffGiverSetDef> hediffGiverSets = this.pawn.RaceProps.hediffGiverSets; if (hediffGiverSets != null && this.pawn.IsHashIntervalTick(60)) { for (int i = 0; i < hediffGiverSets.Count; i++) { List <HediffGiver> hediffGivers = hediffGiverSets[i].hediffGivers; int num6 = 0; while (num6 < hediffGivers.Count) { hediffGivers[num6].OnIntervalPassed(this.pawn, null); if (!this.pawn.Dead) { num6++; continue; } return; } } } } } }
public void RemoveHediff(Hediff hediff) { this.hediffSet.hediffs.Remove(hediff); hediff.PostRemoved(); this.Notify_HediffChanged(null); }
public static IEnumerable <StatDrawEntry> SpecialDisplayStats(HediffStage stage, Hediff instance) { if (instance != null && instance.Bleeding) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "BleedingRate".Translate(), instance.BleedRate.ToStringPercent() + "/" + "LetterDay".Translate(), "Stat_Hediff_BleedingRate_Desc".Translate(), 4040)); } float num = 0f; if (instance != null) { num = instance.PainOffset; } else if (stage != null) { num = stage.painOffset; } if (num != 0f) { if (num > 0f && num < 0.01f) { num = 0.01f; } if (num < 0f && num > -0.01f) { num = -0.01f; } yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Pain".Translate(), (num * 100f).ToString("+###0;-###0") + "%", "Stat_Hediff_Pain_Desc".Translate(), 4050)); } float num2 = 1f; if (instance != null) { num2 = instance.PainFactor; } else if (stage != null) { num2 = stage.painFactor; } if (num2 != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Pain".Translate(), "x" + num2.ToStringPercent(), "Stat_Hediff_Pain_Desc".Translate(), 4050)); } if (stage != null && stage.partEfficiencyOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PartEfficiency".Translate(), stage.partEfficiencyOffset.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Offset), "Stat_Hediff_PartEfficiency_Desc".Translate(), 4050)); } List <PawnCapacityModifier> capModsToDisplay = null; if (instance != null) { capModsToDisplay = instance.CapMods; } else if (stage != null) { capModsToDisplay = stage.capMods; } if (capModsToDisplay != null) { for (int k = 0; k < capModsToDisplay.Count; k++) { PawnCapacityModifier capMod = capModsToDisplay[k]; if (instance == null || instance.pawn == null || instance.pawn.health == null || instance.pawn.health.capacities.CapableOf(capMod.capacity)) { if (capMod.offset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, capMod.capacity.GetLabelFor(isFlesh: true, isHumanlike: true).CapitalizeFirst(), (capMod.offset * 100f).ToString("+#;-#") + "%", capMod.capacity.description, 4060)); } if (capMod.postFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, capMod.capacity.GetLabelFor(isFlesh: true, isHumanlike: true).CapitalizeFirst(), "x" + capMod.postFactor.ToStringPercent(), capMod.capacity.description, 4060)); } if (capMod.SetMaxDefined && instance != null) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, capMod.capacity.GetLabelFor(isFlesh: true, isHumanlike: true).CapitalizeFirst(), "max".Translate().CapitalizeFirst() + " " + capMod.EvaluateSetMax(instance.pawn).ToStringPercent(), capMod.capacity.description, 4060)); } } } } if (stage == null) { yield break; } if (stage.AffectsMemory || stage.AffectsSocialInteractions) { StringBuilder stringBuilder = new StringBuilder(); if (stage.AffectsMemory) { if (stringBuilder.Length != 0) { stringBuilder.Append(", "); } stringBuilder.Append("MemoryLower".Translate()); } if (stage.AffectsSocialInteractions) { if (stringBuilder.Length != 0) { stringBuilder.Append(", "); } stringBuilder.Append("SocialInteractionsLower".Translate()); } yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Affects".Translate(), stringBuilder.ToString(), "Stat_Hediff_Affects_Desc".Translate(), 4080)); } if (stage.hungerRateFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "HungerRate".Translate(), "x" + stage.hungerRateFactor.ToStringPercent(), "Stat_Hediff_HungerRateFactor_Desc".Translate(), 4051)); } if (stage.hungerRateFactorOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Stat_Hediff_HungerRateOffset_Name".Translate(), stage.hungerRateFactorOffset.ToStringSign() + stage.hungerRateFactorOffset.ToStringPercent(), "Stat_Hediff_HungerRateOffset_Desc".Translate(), 4051)); } if (stage.restFallFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Tiredness".Translate(), "x" + stage.restFallFactor.ToStringPercent(), "Stat_Hediff_TirednessFactor_Desc".Translate(), 4050)); } if (stage.restFallFactorOffset != 0f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Stat_Hediff_TirednessOffset_Name".Translate(), stage.restFallFactorOffset.ToStringSign() + stage.restFallFactorOffset.ToStringPercent(), "Stat_Hediff_TirednessOffset_Desc".Translate(), 4050)); } if (stage.makeImmuneTo != null) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "PreventsInfection".Translate(), stage.makeImmuneTo.Select((HediffDef im) => im.label).ToCommaList().CapitalizeFirst(), "Stat_Hediff_PreventsInfection_Desc".Translate(), 4050)); } if (stage.totalBleedFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Stat_Hediff_TotalBleedFactor_Name".Translate(), stage.totalBleedFactor.ToStringPercent(), "Stat_Hediff_TotalBleedFactor_Desc".Translate(), 4041)); } if (stage.naturalHealingFactor != -1f) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, "Stat_Hediff_NaturalHealingFactor_Name".Translate(), stage.naturalHealingFactor.ToStringByStyle(ToStringStyle.FloatTwo, ToStringNumberSense.Factor), "Stat_Hediff_NaturalHealingFactor_Desc".Translate(), 4020)); } if (stage.foodPoisoningChanceFactor != 1f) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Stat_Hediff_FoodPoisoningChanceFactor_Name".Translate(), stage.foodPoisoningChanceFactor.ToStringByStyle(ToStringStyle.FloatTwo, ToStringNumberSense.Factor), "Stat_Hediff_FoodPoisoningChanceFactor_Desc".Translate(), 4030)); } if (stage.statOffsets != null) { for (int k = 0; k < stage.statOffsets.Count; k++) { StatModifier statModifier = stage.statOffsets[k]; if (statModifier.stat.CanShowWithLoadedMods()) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, statModifier.stat.LabelCap, statModifier.ValueToStringAsOffset, statModifier.stat.description, 4070)); } } } if (stage.statFactors == null) { yield break; } for (int k = 0; k < stage.statFactors.Count; k++) { StatModifier statModifier2 = stage.statFactors[k]; if (statModifier2.stat.CanShowWithLoadedMods()) { yield return(new StatDrawEntry(StatCategoryDefOf.CapacityEffects, statModifier2.stat.LabelCap, statModifier2.ToStringAsFactor, statModifier2.stat.description, 4070)); } } }
private void MakeDowned(DamageInfo?dinfo, Hediff hediff) { if (this.Downed) { Log.Error(this.pawn + " tried to do MakeDowned while already downed."); return; } this.healthState = PawnHealthState.Down; PawnDiedOrDownedThoughtsUtility.TryGiveThoughts(this.pawn, dinfo, PawnDiedOrDownedThoughtsKind.Downed); if (this.pawn.InMentalState) { this.pawn.mindState.mentalStateHandler.CurState.RecoverFromState(); } if (this.pawn.Spawned) { if (this.pawn.IsColonist && dinfo.HasValue && dinfo.Value.Def.externalViolence) { Find.StoryWatcher.watcherRampUp.Notify_ColonistViolentlyDownedOrKilled(this.pawn); } this.pawn.DropAndForbidEverything(true); this.pawn.stances.CancelBusyStanceSoft(); } this.pawn.ClearMind(true); if (Current.ProgramState == ProgramState.Playing) { Lord lord = this.pawn.GetLord(); if (lord != null) { lord.Notify_PawnLost(this.pawn, PawnLostCondition.IncappedOrKilled); } } if (this.pawn.Drafted) { this.pawn.drafter.Drafted = false; } PortraitsCache.SetDirty(this.pawn); if (this.pawn.SpawnedOrAnyParentSpawned) { GenHostility.Notify_PawnLostForTutor(this.pawn, this.pawn.MapHeld); } if (this.pawn.RaceProps.Humanlike && Current.ProgramState == ProgramState.Playing && this.pawn.SpawnedOrAnyParentSpawned) { if (this.pawn.HostileTo(Faction.OfPlayer)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.Capturing, this.pawn, OpportunityType.Important); } if (this.pawn.Faction == Faction.OfPlayer) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.Rescuing, this.pawn, OpportunityType.Critical); } } if (dinfo.HasValue && dinfo.Value.Instigator != null) { Pawn pawn = dinfo.Value.Instigator as Pawn; if (pawn != null) { RecordsUtility.Notify_PawnDowned(this.pawn, pawn); } } if (this.pawn.Spawned) { TaleRecorder.RecordTale(TaleDefOf.Downed, new object[] { this.pawn, (!dinfo.HasValue) ? null : (dinfo.Value.Instigator as Pawn), (!dinfo.HasValue) ? null : dinfo.Value.Weapon }); Find.BattleLog.Add(new BattleLogEntry_StateTransition(this.pawn, RulePackDefOf.Transition_Downed, (!dinfo.HasValue) ? null : (dinfo.Value.Instigator as Pawn), hediff, (!dinfo.HasValue) ? null : dinfo.Value.HitPart.def)); } }
public virtual void OnIntervalPassed(Pawn pawn, Hediff cause) { }
public override bool TryMergeWith(Hediff other) { Hediff_Injury hediff_Injury = other as Hediff_Injury; return(hediff_Injury != null && hediff_Injury.def == this.def && hediff_Injury.Part == base.Part && !hediff_Injury.IsTended() && !hediff_Injury.IsPermanent() && !this.IsTended() && !this.IsPermanent() && this.def.injuryProps.canMerge && base.TryMergeWith(other)); }
public virtual bool OnHediffAdded(Pawn pawn, Hediff hediff) { return(false); }
public virtual void CompPostMerged(Hediff other) { }
private static IEnumerable InfectionSimulatorWorker() { int trials = 2; List <Pawn> doctors = GenerateDoctorArray(); List <int> testSkill = new List <int> { 4, 10, 16 }; List <ThingDef> testMedicine = new List <ThingDef> { null, ThingDefOf.MedicineHerbal, ThingDefOf.MedicineIndustrial, ThingDefOf.MedicineUltratech }; PawnGenerationRequest pawngen = new PawnGenerationRequest(PawnKindDefOf.Colonist, Faction.OfPlayer); int originalTicks = Find.TickManager.TicksGame; List <InfectionSimRow> results = new List <InfectionSimRow>(); int totalTests = InfectionList().Count() * testMedicine.Count() * testSkill.Count() * trials; int currentTest = 0; foreach (HediffDef hediff in InfectionList()) { foreach (ThingDef meds in testMedicine) { foreach (int item in testSkill) { InfectionSimRow result = default(InfectionSimRow); result.illness = hediff; result.skill = item; result.medicine = meds; Pawn doctor = doctors[item]; int i = 0; while (i < trials) { Pawn patient = PawnGenerator.GeneratePawn(pawngen); int startTicks = Find.TickManager.TicksGame; patient.health.AddHediff(result.illness); Hediff activeHediff = patient.health.hediffSet.GetFirstHediffOfDef(result.illness); while (!patient.Dead && patient.health.hediffSet.HasHediff(result.illness)) { if (activeHediff.TendableNow()) { activeHediff.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds)); result.medicineUsed += 1f; } foreach (Hediff item2 in patient.health.hediffSet.GetHediffsTendable()) { item2.Tended(TendUtility.CalculateBaseTendQuality(doctor, patient, meds)); } Find.TickManager.DebugSetTicksGame(Find.TickManager.TicksGame + 1); patient.health.HealthTick(); if (Find.TickManager.TicksGame % 900 == 0) { yield return(null); } } if (patient.Dead) { result.deathChance += 1f; } else { result.recoveryTimeDays += (Find.TickManager.TicksGame - startTicks).TicksToDays(); } int num = currentTest + 1; currentTest = num; LongEventHandler.SetCurrentEventText($"Simulating ({currentTest}/{totalTests})"); yield return(null); num = i + 1; i = num; } result.recoveryTimeDays /= (float)trials - result.deathChance; result.deathChance /= trials; result.medicineUsed /= trials; results.Add(result); result = default(InfectionSimRow); } } } DebugTables.MakeTablesDialog(results, new TableDataGetter <InfectionSimRow>("defName", (InfectionSimRow isr) => isr.illness.defName), new TableDataGetter <InfectionSimRow>("meds", (InfectionSimRow isr) => (isr.medicine == null) ? "(none)" : isr.medicine.defName), new TableDataGetter <InfectionSimRow>("skill", (InfectionSimRow isr) => isr.skill.ToString()), new TableDataGetter <InfectionSimRow>("death chance", (InfectionSimRow isr) => isr.deathChance.ToStringPercent()), new TableDataGetter <InfectionSimRow>("recovery time (days)", (InfectionSimRow isr) => isr.recoveryTimeDays.ToString("F1")), new TableDataGetter <InfectionSimRow>("medicine used", (InfectionSimRow isr) => isr.medicineUsed.ToString())); Find.TickManager.DebugSetTicksGame(originalTicks); }