// Use this for initialization void Awake() { AbilitiesCtrl = GetComponent <AbilitiesController>(); if (gameObject.tag == "Player") { HpHelper = GetComponent <HealHelper>(); ExpList = new int[11] { 0, 100, 250, 450, 800, 1250, 1700, 2300, 2900, 3500, 9999999 }; } if (gameObject.tag == "Player") { if (Connection.IsServer) { PlayerInfo.RequestHP(); } else { if (PlayerPrefs.HasKey("PlayerHp")) { Hp = PlayerPrefs.GetInt("PlayerHp"); } else { Hp = 100; } } } }
private void TryFillQuota() { BodyParts = new List <BodyPartRecord>(); if (Surgery?.Worker == null || Surgery.addsHediff == null) { return; } Pawn_HealthTracker pHealth = Patient.health; foreach (BodyPartRecord part in Surgery.Worker.GetPartsToApplyOn(Patient, Surgery)) { if (pHealth.surgeryBills.Bills.Any(b => b is Bill_Medical bill && bill.Part == part && bill.recipe == Surgery)) { continue; } if (pHealth.hediffSet.hediffs.Where(h => h.def.defName == Surgery.addsHediff.defName).Any(h => h.Part == part)) { continue; } BodyParts.Add(part); } BodyParts.SortBy(part => HealHelper.GetAverageHealthOfPart(Patient, part)); BodyParts = BodyParts.Take(Quantity).ToList(); }
public override bool CanHappen(string msg, Viewer viewer) { foreach (Pawn pawn in Find.ColonistBar.GetColonistsInOrder().Where(p => !p.Dead)) { if (IncidentSettings.HealAll.FairFights && pawn.mindState.lastAttackTargetTick > 0 && Find.TickManager.TicksGame < pawn.mindState.lastAttackTargetTick + 1800) { continue; } object result = HealHelper.GetPawnHealable(pawn); switch (result) { case Hediff hediff: _healQueue.Add(hediff); break; case BodyPartRecord record: _restoreQueue.Add(new Pair <Pawn, BodyPartRecord>(pawn, record)); break; } } return(_healQueue.Any(i => i != null) || _restoreQueue.Any(i => i.Second != null)); }
private static bool TryProcessColonist([NotNull] Pawn pawn) { if (pawn.Dead) { pawn.TryResurrect(); return(true); } if (!(HealHelper.GetPawnHealable(pawn) is { } injury)) { return(false); } switch (injury) { case Hediff hediff: pawn.health.RemoveHediff(hediff); return(true); case BodyPartRecord record: pawn.health.RestorePart(record); return(true); } return(false); }
public override EntityController Buff(EntityController entity) { if (0.0f == StartTime) { StartTime = Time.time; HealHelper healHelper = Target.Entity.AddComponent <HealHelper>(); healHelper.Heal(this, Target); } return(entity); }
public override void Execute() { foreach (Hediff hediff in _healQueue) { HealHelper.Cure(hediff); } foreach (Pair <Pawn, BodyPartRecord> part in _restoreQueue) { part.First.health.RestorePart(part.Second); } Viewer.Charge(storeIncident); MessageHelper.SendConfirmation(Viewer.username, "TKUtils.MassHealLetter.Description".Localize()); Find.LetterStack.ReceiveLetter("TKUtils.MassHealLetter.Title".Localize(), "TKUtils.MassHealLetter.Description".Localize(), LetterDefOf.PositiveEvent); }
public override void Execute() { if (_toHeal != null) { HealHelper.Cure(_toHeal); NotifySuccess(_toHeal.LabelCap); } if (_toRestore == null) { return; } _target.health.RestorePart(_toRestore); NotifySuccess(_toRestore.Label); }
public override void Execute() { if (_toHeal != null) { HealHelper.Cure(_toHeal); Viewer.Charge(storeIncident); NotifySuccess(_toHeal.LabelCap); } if (_toRestore == null) { return; } _pawn.health.RestorePart(_toRestore); Viewer.Charge(storeIncident); NotifySuccess(_toRestore.Label); }
public override void Execute() { var healed = 0; var iterations = 0; while (true) { if (!Viewer.CanAfford(storeIncident.cost)) { break; } object healable = HealHelper.GetPawnHealable(_pawn); if (healable == null) { break; } healed = Heal(healable, healed); iterations += 1; if (iterations < 500) { continue; } TkUtils.Logger.Warn("Exceeded the maximum number of iterations during full heal."); break; } MessageHelper.SendConfirmation( Viewer.username, healed > 1 ? "TKUtils.FullHeal.CompletePlural".LocalizeKeyed(healed.ToString("N0")) : "TKUtils.FullHeal.Complete".Localize() ); Current.Game.letterStack.ReceiveLetter( "TKUtils.FullHealLetter.Title".Localize(), "TKUtils.FullHealLetter.Description".LocalizeKeyed(Viewer.username), LetterDefOf.PositiveEvent, _pawn ); }
private static bool TryProcessAnimal([NotNull] Pawn pawn) { if (pawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.Manhunter) { pawn.ClearMind(); return(true); } if (pawn.mindState.mentalStateHandler.CurStateDef == MentalStateDefOf.ManhunterPermanent) { pawn.Kill(new DamageInfo(DamageDefOf.Burn, 100000, 1f, category: DamageInfo.SourceCategory.ThingOrUnknown)); return(true); } if (pawn.Dead) { pawn.TryResurrect(); return(true); } if (!(HealHelper.GetPawnHealable(pawn) is { } injury)) { return(false); } switch (injury) { case Hediff hediff: pawn.health.RemoveHediff(hediff); return(true); case BodyPartRecord record: pawn.health.RestorePart(record); return(true); } return(false); }
private int Heal(object injury, int healed) { switch (injury) { case Hediff hediff: HealHelper.Cure(hediff); healed += 1; Viewer.Charge(storeIncident, healed); break; case BodyPartRecord record: _pawn.health.RestorePart(record); healed += 1; Viewer.Charge(storeIncident, healed); break; } return(healed); }
public override bool CanHappen(string msg, Viewer viewer) { List <Pawn> pawns = Find.ColonistBar.GetColonistsInOrder() .Where(p => !p.Dead) .Where( pawn => !IncidentSettings.HealRandom.FairFights || (pawn.mindState.lastAttackTargetTick > 0 && Find.TickManager.TicksGame <= pawn.mindState.lastAttackTargetTick + 1800) ) .ToList(); if (!pawns.Select(p => new Pair <Pawn, object>(p, HealHelper.GetPawnHealable(p))).Where(r => r.Second != null).TryRandomElement(out Pair <Pawn, object> random)) { return(false); } if (random.First == null || random.Second == null) { return(false); } _target = random.First; switch (random.Second) { case Hediff hediff: _toHeal = hediff; break; case BodyPartRecord record: _toRestore = record; break; } return(_target != null && (_toHeal != null || _toRestore != null)); }