コード例 #1
0
        protected float FinalizeAndAddInjury(Pawn pawn, Hediff_Injury injury, DamageInfo dinfo, DamageWorker.DamageResult result)
        {
            this.CalculatePermanentInjuryDamageThreshold(pawn, injury);
            pawn.health.AddHediff(injury, null, new DamageInfo?(dinfo), result);
            float num = Mathf.Min(injury.Severity, pawn.health.hediffSet.GetPartHealth(injury.Part));

            result.totalDamageDealt += num;
            result.wounded           = true;
            result.AddPart(pawn, injury.Part);
            result.AddHediff(injury);
            return(num);
        }
コード例 #2
0
        protected float FinalizeAndAddInjury(Pawn pawn, Hediff_Injury injury, DamageInfo dinfo, DamageWorker.DamageResult result)
        {
            HediffComp_GetsPermanent hediffComp_GetsPermanent = injury.TryGetComp <HediffComp_GetsPermanent>();

            if (hediffComp_GetsPermanent != null)
            {
                hediffComp_GetsPermanent.PreFinalizeInjury();
            }
            pawn.health.AddHediff(injury, null, new DamageInfo?(dinfo), result);
            float num = Mathf.Min(injury.Severity, pawn.health.hediffSet.GetPartHealth(injury.Part));

            result.totalDamageDealt += num;
            result.wounded           = true;
            result.AddPart(pawn, injury.Part);
            result.AddHediff(injury);
            return(num);
        }
コード例 #3
0
ファイル: HediffSet.cs プロジェクト: potsh/RimWorld
 public void AddDirect(Hediff hediff, DamageInfo?dinfo = default(DamageInfo?), DamageWorker.DamageResult damageResult = null)
 {
     if (hediff.def == null)
     {
         Log.Error("Tried to add health diff with null def. Canceling.");
     }
     else if (hediff.Part != null && !GetNotMissingParts().Contains(hediff.Part))
     {
         Log.Error("Tried to add health diff to missing part " + hediff.Part);
     }
     else
     {
         hediff.ageTicks = 0;
         hediff.pawn     = pawn;
         bool flag = false;
         for (int i = 0; i < hediffs.Count; i++)
         {
             if (hediffs[i].TryMergeWith(hediff))
             {
                 flag = true;
             }
         }
         if (!flag)
         {
             hediffs.Add(hediff);
             hediff.PostAdd(dinfo);
             if (pawn.needs != null && pawn.needs.mood != null)
             {
                 pawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
             }
         }
         bool flag2 = hediff is Hediff_MissingPart;
         if (!(hediff is Hediff_MissingPart) && hediff.Part != null && hediff.Part != pawn.RaceProps.body.corePart && GetPartHealth(hediff.Part) == 0f && hediff.Part != pawn.RaceProps.body.corePart)
         {
             bool flag3 = HasDirectlyAddedPartFor(hediff.Part);
             Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, pawn);
             hediff_MissingPart.IsFresh    = !flag3;
             hediff_MissingPart.lastInjury = hediff.def;
             pawn.health.AddHediff(hediff_MissingPart, hediff.Part, dinfo);
             damageResult?.AddHediff(hediff_MissingPart);
             if (flag3)
             {
                 if (dinfo.HasValue)
                 {
                     hediff_MissingPart.lastInjury = HealthUtility.GetHediffDefFromDamage(dinfo.Value.Def, pawn, hediff.Part);
                 }
                 else
                 {
                     hediff_MissingPart.lastInjury = null;
                 }
             }
             flag2 = true;
         }
         DirtyCache();
         if (flag2 && pawn.apparel != null)
         {
             pawn.apparel.Notify_LostBodyPart();
         }
         if (hediff.def.causesNeed != null && !pawn.Dead)
         {
             pawn.needs.AddOrRemoveNeedsAsAppropriate();
         }
     }
 }