public override IEnumerable <Gizmo> CompGetGizmosExtra() { // Log.Message("Comp_Necron CompGetGizmosExtra"); /* * foreach (Gizmo item in base.CompGetGizmosExtra()) * { * yield return item; * } */ bool selected = (Find.Selector.SingleSelectedThing == Pawn || Find.Selector.SingleSelectedThing == Pawn.Corpse) && Prefs.DevMode && DebugSettings.godMode; bool missing = Pawn.health.hediffSet.hediffs.Any(x => x.def.hediffClass == typeof(Hediff_MissingPart) && x.def.isBad); if (selected) { if (Pawn.Dead) { Command_Action command_Action = new Command_Action { defaultLabel = "Activate Reanimation Protocols", defaultDesc = parent.def.label, // command_Action.hotKey = KeyBindingDefOf.Misc2; icon = ContentFinder <Texture2D> .Get("Icons/Icon_Necron", true), action = DoTryRevive }; yield return(command_Action); } else if (!HealableHediffs.NullOrEmpty()) { Command_Action command_Action = new Command_Action { defaultLabel = "Activate Necrodermis repair", defaultDesc = parent.def.label, // command_Action.hotKey = KeyBindingDefOf.Misc2; icon = ContentFinder <Texture2D> .Get("Icons/Icon_Necron", true), action = DoTryHeal }; yield return(command_Action); } if (missing) { Command_Action command_Action = new Command_Action { defaultLabel = "Activate Necrodermis regeneration", defaultDesc = parent.def.label, // command_Action.hotKey = KeyBindingDefOf.Misc2; icon = ContentFinder <Texture2D> .Get("Icons/Icon_Necron", true), action = DoTryRegrowBodyparts }; yield return(command_Action); } } yield break; }
public void TryRegrowBodyparts(bool Forced = false) { using IEnumerator <BodyPartRecord> enumerator = this.Pawn.GetFirstMatchingBodyparts(this.Pawn.RaceProps.body.corePart, HediffDefOf.MissingBodyPart, AdeptusHediffDefOf.OG_Regenerating, (Hediff hediff) => hediff is Hediff_AddedPart).GetEnumerator(); while (enumerator.MoveNext()) { BodyPartRecord part = enumerator.Current; bool any = this.Pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.Part == part && hediff.def == HediffDefOf.MissingBodyPart && (HealableHediffs.Contains(hediff) || Forced)); if (any) { Hediff hediff2 = this.Pawn.health.hediffSet.hediffs.First((Hediff hediff) => hediff.Part == part && hediff.def == HediffDefOf.MissingBodyPart && (HealableHediffs.Contains(hediff) || Forced)); bool flag = hediff2 != null; if (flag) { this.Pawn.health.RemoveHediff(hediff2); this.Pawn.health.AddHediff(AdeptusHediffDefOf.OG_Regenerating, part, null, null); this.Pawn.health.hediffSet.DirtyCache(); } } } }
public void TryRemoveHediff(bool Forced = false) { bool any = this.Pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def != HediffDefOf.MissingBodyPart && (Forced || HealableHediffs.Contains(hediff))); if (any) { Hediff hediff2 = this.Pawn.health.hediffSet.hediffs.First((Hediff hediff) => hediff.def != HediffDefOf.MissingBodyPart && (Forced || HealableHediffs.Contains(hediff))); bool flag = hediff2 != null; if (flag) { this.Pawn.health.RemoveHediff(hediff2); this.Pawn.health.hediffSet.DirtyCache(); } } }
public void TryHeal(bool Forced = false) { bool flag2 = HealableHediffs.Any(x => !Pawn.health.hediffSet.PartIsMissing(x.Part) && x is Hediff_Injury); bool flag3 = HealableHediffs.Any(x => Pawn.health.hediffSet.PartIsMissing(x.Part)); bool flag4 = HealableHediffs.Any(x => x.def == AdeptusHediffDefOf.OG_Regenerating); Rand.PushState(); float num = Rand.RangeInclusive(1, 100); Rand.PopState(); Hediff hediff; if (flag2) { if (logging == true) { Log.Message(string.Format("flag2")); } hediff = GenCollection.RandomElement <Hediff_Injury>(from x in Pawn.health.hediffSet.GetHediffs <Hediff_Injury>() where HediffUtility.CanHealNaturally(x) && (HealableHediffs.Contains(x) || Forced) select x); num = num * Pawn.HealthScale * 0.1f; hediff.Heal(num); string text = string.Format("flag2 the {1} on {0}'s {2} healed by {3}.", Pawn.LabelCap, hediff.Label, hediff.Part.customLabel, num); if (hediff.Severity == 0f) { text += " and was removed"; Pawn.health.RemoveHediff(hediff); } if (logging == true) { Log.Message(string.Format(text)); } } else if (flag4) { if (logging == true) { Log.Message(string.Format("flag4")); } #pragma warning disable CS0436 // Type conflicts with imported type hediff = Pawn.health.hediffSet.GetHediffs <Hediff_RegeneratingPart>().RandomElement(); #pragma warning restore CS0436 // Type conflicts with imported type num = num * Pawn.HealthScale * 0.001f; hediff.Heal(num); string text = string.Format("flag5 the {1} on {0}'s {2} regenerated by {3}.", Pawn.LabelCap, hediff.Label, hediff.Part.customLabel, num); if (hediff.Severity == 0f) { text += " and was removed"; Pawn.health.RemoveHediff(hediff); } if (logging == true) { Log.Message(string.Format(text)); } } else if (flag3) { if (logging == true) { Log.Message(string.Format("flag3")); } bool flag3B = Pawn.health.hediffSet.hediffs.Any(x => Pawn.health.hediffSet.PartIsMissing(x.Part) && HealableHediffs.Contains(x)); if (flag3B) { if (logging == true) { Log.Message(string.Format("flag3B")); } TryRegrowBodyparts(); } else { if (logging == true) { Log.Message(string.Format("flag3 {0}'s hediff_Injury flag3B: {1}", Pawn.Label, flag3B)); } } } else { hediff = null; } }