Пример #1
0
        public static IEnumerable <Thing> TraverseBody(RecipeInfo recipeInfo, Corpse corpse, float skillChance)
        {
            BodyPartRecord        core  = corpse.InnerPawn.RaceProps.body.corePart;
            List <BodyPartRecord> queue = new List <BodyPartRecord> {
                core
            };
            HediffSet             hediffSet    = corpse.InnerPawn.health.hediffSet;
            List <Thing>          results      = new List <Thing>();
            List <BodyPartRecord> damagedParts = new List <BodyPartRecord>();

            while (queue.Count > 0)
            {
                BodyPartRecord part = queue.First();
                queue.Remove(part);
                //Drop parts and bionics that are higher on the body tree.
                if (TryGetParts(corpse, recipeInfo, part, skillChance, ref results, ref damagedParts) && core != part)
                {
                    continue;
                }
                queue.AddRange(part.parts.Where(x => !hediffSet.PartIsMissing(x)));
            }

            if (results.Count > recipeInfo.PartNumber)
            {
                Random random = new Random();
                return(results.OrderBy(i => random.Next()).Take(recipeInfo.PartNumber));
            }

            foreach (BodyPartRecord part in damagedParts)
            {
                DamageHarvested(corpse.InnerPawn, part);
            }

            return(results);
        }
Пример #2
0
 public void Check(HediffSet hediffSet)
 {
     if (!hediffSet.HasHediff(custom.First?.hediffDef))
     {
         custom = new Pair <CustomPath, Graphic>();
     }
 }
Пример #3
0
        /// <summary>gets the random selection weight.</summary>
        /// <param name="initiator">The initiator.</param>
        /// <param name="recipient">The recipient.</param>
        /// <returns></returns>
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            float weight = 0f;
            Dictionary <string, float> dicc = new Dictionary <string, float>()
            {
                { "EtherSheepEar", 0.5f },
                { "EtherSheepTail", 1f },
                { "EtherSheepSnout", 2f },
                { "EtherHoofHand", 1f },
                { "EtherDigitigradeLeg", 0.5f },
                { "EtherClovenHoofFoot", 0.5f },
                { "EtherWoolySheep", 1f },
                { "EtherSheepEye", 0.2f },
            };
            HediffSet hs = initiator.health.hediffSet;

            if (initiator.health.hediffSet.HasHediff(HediffDef.Named("EtherSheepSnout")))
            {
                foreach (KeyValuePair <string, float> pair in dicc)
                {
                    if (hs.HasHediff(HediffDef.Named(pair.Key)))
                    {
                        weight += pair.Value;
                    }
                }
                return(weight);
            }
            else
            {
                return(0f);
            }
        }
Пример #4
0
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            float num  = 0f;
            float num2 = PawnCapacityUtility.CalculateLimbEfficiency(diffSet, BodyPartTagDefOf.MovingLimbCore, BodyPartTagDefOf.MovingLimbSegment, BodyPartTagDefOf.MovingLimbDigit, 0.4f, out num, impactors);
            float result;

            if (num < 0.4999f)
            {
                result = 0f;
            }
            else
            {
                float          num3 = num2;
                BodyPartTagDef tag  = BodyPartTagDefOf.Pelvis;
                num2 = num3 * PawnCapacityUtility.CalculateTagEfficiency(diffSet, tag, float.MaxValue, default(FloatRange), impactors);
                float num4 = num2;
                tag    = BodyPartTagDefOf.Spine;
                num2   = num4 * PawnCapacityUtility.CalculateTagEfficiency(diffSet, tag, float.MaxValue, default(FloatRange), impactors);
                num2   = Mathf.Lerp(num2, num2 * base.CalculateCapacityAndRecord(diffSet, PawnCapacityDefOf.Breathing, impactors), 0.2f);
                num2   = Mathf.Lerp(num2, num2 * base.CalculateCapacityAndRecord(diffSet, PawnCapacityDefOf.BloodPumping, impactors), 0.2f);
                num2  *= Mathf.Min(base.CalculateCapacityAndRecord(diffSet, PawnCapacityDefOf.Consciousness, impactors), 1f);
                result = num2;
            }
            return(result);
        }
Пример #5
0
        /*
         * public void BodyCheck(HediffSet hediffSet)
         * {
         *  //var list = hediffSet.hediffs.FindAll(x => x.Part != null && x.Part.IsInGroup(racomp.torsoDef.linkedBodyGroup));
         *  var list = hediffSet.hediffs.FindAll(x => x.Part == null && racomp.torsoDef.linkedBodyGroup == null || x.Part != null && x.Part.IsInGroup(racomp.torsoDef.linkedBodyGroup));
         *  if (racomp.torsoDef.bodyPath.customs.FindAll(x => list.Any(y => y.def == x.hediffDef)) is var list2 && list2.Count > 0)
         *  {
         *      list2.Sort((x, y) => y.priority - x.priority);
         *      if (list2[0].hediffDef != lastBodyHediffDef)
         *      {
         *          ResolveAllGraphics.RenewalBodyGraphic(pawn.Drawer.renderer.graphics, list2[0].path, racomp.torsoDef.shaderType.Shader, racomp, (pawn.def as RaceAddonThingDef).raceAddonSettings.graphicSetting.rottingColor);
         *          lastBodyHediffDef = list2[0].hediffDef;
         *      }
         *  }
         * }
         *
         * public void HeadCheck(HediffSet hediffSet)
         * {
         *  //var list = hediffSet.hediffs.FindAll(x => x.Part != null && x.Part.IsInGroup(racomp.torsoDef.linkedHeadGroup));
         *  var list = hediffSet.hediffs.FindAll(x => x.Part == null && racomp.torsoDef.linkedHeadGroup == null || x.Part != null && x.Part.IsInGroup(racomp.torsoDef.linkedHeadGroup));
         *  if (racomp.torsoDef.headPath.customs.FindAll(x => list.Any(y => y.def == x.hediffDef)) is var list2 && list2.Count > 0)
         *  {
         *      list2.Sort((x, y) => y.priority - x.priority);
         *      if (list2[0].hediffDef != lastHeadHediffDef)
         *      {
         *          ResolveAllGraphics.RenewalHeadGraphic(pawn.Drawer.renderer.graphics, list2[0].path, racomp.torsoDef.shaderType.Shader, racomp, (pawn.def as RaceAddonThingDef).raceAddonSettings.graphicSetting.rottingColor);
         *          lastHeadHediffDef = list2[0].hediffDef;
         *      }
         *  }
         * }
         */
        public void TorsoCheck(HediffSet hediffSet)
        {
            if (racomp.torsoDef.headPath.customs.FindAll(x => hediffSet.HasHediff(x.hediffDef, null)) is var headList && headList.Count > 0)
            {
                headList.Sort((x, y) => y.priority - x.priority);
                if (headList[0].hediffDef != lastHeadHediffDef)
                {
                    ResolveAllGraphics.RenewalHeadGraphic(pawn.Drawer.renderer.graphics, headList[0].path, racomp.torsoDef.shaderType.Shader, racomp, (pawn.def as RaceAddonThingDef).raceAddonSettings.graphicSetting.rottingColor);
                    lastHeadHediffDef = headList[0].hediffDef;
                }
            }
            if (racomp.torsoDef.bodyPath.customs.FindAll(x => hediffSet.HasHediff(x.hediffDef, null)) is var bodyList && bodyList.Count > 0)
            {
                bodyList.Sort((x, y) => y.priority - x.priority);
                if (bodyList[0].hediffDef != lastBodyHediffDef)
                {
                    ResolveAllGraphics.RenewalHeadGraphic(pawn.Drawer.renderer.graphics, bodyList[0].path, racomp.torsoDef.shaderType.Shader, racomp, (pawn.def as RaceAddonThingDef).raceAddonSettings.graphicSetting.rottingColor);
                    lastBodyHediffDef = bodyList[0].hediffDef;
                }
            }
            var injuredParts = hediffSet.GetInjuredParts();

            bodyDamaged = injuredParts.Any(x => x.IsInGroup(racomp.torsoDef.linkedBodyGroup));
            headDamaged = injuredParts.Any(x => x.IsInGroup(racomp.torsoDef.linkedHeadGroup));
        }
        public static void DirtyCache_Postfix(HediffSet __instance)
        {
            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            Pawn pawn = __instance.pawn; // Traverse.Create(__instance).Field("pawn").GetValue<Pawn>();

            if (pawn == null || !pawn.Spawned || pawn.Map == null)
            {
                return;
            }

            if (!pawn.GetCompFace(out CompFace compFace))
            {
                return;
            }


            if (!compFace.Deactivated && pawn.CheckForAddedOrMissingParts())
            {
                pawn.Drawer.renderer.graphics.nakedGraphic = null;
                PortraitsCache.SetDirty(pawn);
            }

            pawn.GetCompAnim()?.PawnBodyGraphic?.Initialize();
        }
Пример #7
0
        // Token: 0x06000066 RID: 102 RVA: 0x00006030 File Offset: 0x00004230
        internal static bool HasHediff(Pawn pawn, HediffDef def)
        {
            Pawn_HealthTracker health = pawn.health;
            HediffSet          HS     = health?.hediffSet;

            return(HS != null && HS.GetFirstHediffOfDef(def, false) != null);
        }
        public void ResolveAllGraphics(Color rottingColor, HediffSet hediffSet)
        {
            string path = data.texturePath;

            if (data.def.linkedBodyPart == "None")
            {
                foreach (var hediff in hediffSet.hediffs.FindAll(x => x.Part == null))
                {
                    if (data.def.hediffPaths.Find(x => x.hediffDef == hediff.def) is var info && info != null)
                    {
                        path = info.path;
                    }
                }
            }
            else
            {
                foreach (var hediff in hediffSet.hediffs.FindAll(x => x.Part != null && x.Part.untranslatedCustomLabel == data.def.linkedBodyPart))
                {
                    if (data.def.hediffPaths.Find(x => x.hediffDef == hediff.def) is var info && info != null)
                    {
                        path = info.path;
                    }
                }
            }
            defaultGraphic = GraphicDatabase.Get <Graphic_Multi>(path, data.def.shaderType.Shader, Vector2.one, data.color1, data.color2);
            rottingGraphic = GraphicDatabase.Get <Graphic_Multi>(path, data.def.shaderType.Shader, Vector2.one, rottingColor);
        }
 internal static void Postfix(HediffSet diffSet, ref float __result)
 {
     if (diffSet.HasHediff(RemediesDefOf.FF_EctostasisHigh))
     {
         __result = 999f;
     }
 }
        public static bool BloodStatus(Pawn pawn)
        {
            HediffSet hediffSet = pawn.health.hediffSet;
            bool      result    = false;

            bool hasbloodedM = hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(markedDef.defName));

            if (hasbloodedM)
            {
                foreach (var item in hediffSet.hediffs)
                {
                    if (item.def.defName.StartsWith(markedDef.defName))
                    {
                        result = true;
                        break;
                    }
                }
            }
            bool hasunblooded = hediffSet.HasHediff(unbloodedDef);

            if (hasunblooded)
            {
                result = false;
            }
            bool hasbloodedUM = hediffSet.HasHediff(unmarkedDef);

            if (hasbloodedUM)
            {
                result = true;
            }
            return(result);
        }
Пример #11
0
        /// <summary>gets the random selection weight.</summary>
        /// <param name="initiator">The initiator.</param>
        /// <param name="recipient">The recipient.</param>
        /// <returns></returns>
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            float weight = 0f;
            Dictionary <string, float> dicc = new Dictionary <string, float>()
            {
                { "EtherFoxEar", 0.5f },
                { "EtherFluffyTail", 1f },
                { "EtherFoxMuzzle", 2f },
                { "EtherPawHand", 1f },
                { "EtherDigitigradeLeg", 0.5f },
                { "EtherPawFoot", 0.5f },
                { "EtherFurredLimb", 0.2f },
                { "EtherFoxEye", 0.2f },
            };
            HediffSet hs = initiator.health.hediffSet;

            if (initiator.health.hediffSet.HasHediff(HediffDef.Named("EtherFoxMuzzle")))
            {
                foreach (KeyValuePair <string, float> pair in dicc)
                {
                    if (hs.HasHediff(HediffDef.Named(pair.Key)))
                    {
                        weight += pair.Value;
                    }
                }
                return(weight);
            }
            else
            {
                return(0f);
            }
        }
Пример #12
0
        public static void RandomlyDamagePawn(Pawn pawn, int injuriesNumber, int damageAmount)
        {
            HediffSet hediffSet     = pawn.health.hediffSet;
            int       injuriesIndex = 0;

            while ((pawn.Dead == false) &&
                   (injuriesIndex < injuriesNumber) &&
                   HittablePartsViolence(hediffSet).Any <BodyPartRecord>())
            {
                injuriesIndex++;
                BodyPartRecord bodyPartRecord = HittablePartsViolence(hediffSet).RandomElementByWeight((BodyPartRecord x) => x.coverageAbs);
                DamageDef      def;
                if (bodyPartRecord.depth == BodyPartDepth.Outside)
                {
                    def = HealthUtility.RandomViolenceDamageType();
                }
                else
                {
                    def = DamageDefOf.Blunt;
                }
                BodyPartRecord forceHitPart = bodyPartRecord;
                DamageInfo     dinfo        = new DamageInfo(def, damageAmount, -1f, null, forceHitPart, null, DamageInfo.SourceCategory.ThingOrUnknown);
                pawn.TakeDamage(dinfo);
            }
        }
 private static void Postfix(HediffSet __instance, ref float __result)
 {
     if (__instance.pawn.def is RaceAddonThingDef thingDef)
     {
         __result *= thingDef.raceAddonSettings.healthSetting.painFactor;
     }
 }
        public static bool Patch_CalculateLimbEfficiency(ref float __result, HediffSet diffSet, BodyPartTagDef limbCoreTag, BodyPartTagDef limbSegmentTag,
                                                         BodyPartTagDef limbDigitTag, float appendageWeight, out float functionalPercentage, List <CapacityImpactor> impactors)
        {
            functionalPercentage = 0f;

            if (limbCoreTag != BodyPartTagDefOf.MovingLimbCore)
            {
                return(true);
            }

            var hediff = diffSet.GetFirstHediffOfDef(LifeSupportDefOf.QE_LifeSupport);

            if (hediff is null)
            {
                return(true);
            }

            if (hediff.Severity < 1f)
            {
                return(true);
            }

            __result = 0f;

            if (!(impactors is null))
            {
                var capacityImpactor = new CapacityImpactorHediff();
                capacityImpactor.hediff = hediff;
                impactors.Add(capacityImpactor);
            }

            return(false);
        }
Пример #15
0
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            //return 1.0f;
            //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called0");
            //return 1f;
            Pawn p = diffSet.pawn;

            if (p == null)
            {
                return(0f);
            }
            if (xxx.is_animal(p))
            {
                return(1f);
            }
            else if (xxx.is_human(p))
            {
                if (p.ageTracker.AgeBiologicalYears > 50 || p.ageTracker.AgeBiologicalYears < 14)
                {
                    return(0f);
                }
                float result = PawnCapacityUtility.CalculateTagEfficiency(diffSet, "RJW_FertilitySource", 1f, impactors); //This should be a value ranged in [0,1]. It seems always to be 1.
                //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called1 - result is "+ result);
                result *= GenMath.FlatHill(14f, 20f, 30f, 50f, p.ageTracker.AgeBiologicalYearsFloat);                     //This adds an aging factor to Fertility
                //--Log.Message("[RJW]PawnCapacityWorker_Fertility::CalculateCapacityLevel is called2 - result is " + result);
                return(result);
            }
            else
            {
                return(0f);
            }
        }
Пример #16
0
 // Verse.HediffSet
 static bool CalculatePain_PreFix(HediffSet __instance, ref float __result)
 {
     if (__instance?.pawn is CosmicHorrorPawn p)
     {
         if (p?.Dead ?? false)
         {
             __result = 0f;
             return(false);
         }
         float num  = 0f;
         float num2 = 0f;
         if (__instance.hediffs != null && __instance.hediffs.Count > 0)
         {
             foreach (Hediff hediff in __instance.hediffs)
             {
                 num += hediff?.PainOffset ?? 0;
             }
             num2  = num / p?.HealthScale ?? 1;
             num2 *= p?.PawnExtension?.painFactor ?? 1;
             foreach (Hediff hedifft in __instance.hediffs)
             {
                 num2 *= hedifft?.PainFactor ?? 1;
             }
         }
         __result = Mathf.Clamp(num2, 0f, 1f);
         return(false);
     }
     return(true);
 }
Пример #17
0
        public static float GetThirstRateFactor(this HediffSet hediffSet)
        {
            float rate = 1f;

            foreach (var hediff in hediffSet.hediffs)
            {
                var hediffStageIndex = hediff.CurStageIndex;
                var ext = hediff.def.GetModExtension <DefExtension_ThirstRate>();
                if (ext == null || ext.thirstRateFactors == null)
                {
                    continue;
                }

                if (hediffStageIndex < ext.thirstRateFactors.Count)
                {
                    rate *= ext.thirstRateFactors[hediffStageIndex];
                }
            }

            foreach (var hediff in hediffSet.hediffs)
            {
                var hediffStageIndex = hediff.CurStageIndex;
                var ext = hediff.def.GetModExtension <DefExtension_ThirstRate>();
                if (ext == null || ext.thirstRateFactorOffsets == null)
                {
                    continue;
                }

                if (hediffStageIndex < ext.thirstRateFactorOffsets.Count)
                {
                    rate += ext.thirstRateFactorOffsets[hediffStageIndex];
                }
            }
            return(rate);
        }
Пример #18
0
        /// <summary>
        /// Returns the actual max HP of this BodyPartRecord instance under the effects of EBF-enabled hediffs.
        /// </summary>
        /// <param name="record">The BodyPartRecord instance in question.</param>
        /// <param name="pawn">The pawn who is the owner of that BodyPartRecord instance.</param>
        /// <returns>The appropriate max HP of the BodyPartRecord under the effects of EBF-enabled hediffs</returns>
        public static float GetMaxHealthWithEBF(BodyPartRecord record, Pawn pawn)
        {
            float     baseMaxHP             = GetMaxHealthUnmodified(record.def, pawn);
            HediffSet hediffSet             = pawn.health.hediffSet;
            float     totalLinearAdjustment = 0;
            float     totalScaledAdjustment = 1;

            foreach (Hediff hediff in hediffSet.hediffs)
            {
                if (hediff.Part == record)
                {
                    HediffCompProperties_MaxHPAdjust adjustorComp = hediff.def.CompProps <HediffCompProperties_MaxHPAdjust>();
                    if (adjustorComp != null)
                    {
                        totalLinearAdjustment += adjustorComp.linearAdjustment;
                        if (adjustorComp.scaleAdjustment + 1 > 0)
                        {
                            // Only allow positive scaling values.
                            totalScaledAdjustment *= (adjustorComp.scaleAdjustment + 1);
                        }
                    }
                }
            }

            float realMaxHP = Mathf.RoundToInt(baseMaxHP * totalScaledAdjustment) + totalLinearAdjustment;

            // must be at least 1
            return(Mathf.Max(realMaxHP, 1));
        }
        /// <summary>
        /// find the original offset without setMax
        /// </summary>
        /// <param name="hSet"></param>
        /// <param name="capacity"></param>
        /// <returns></returns>
        static float GetTotalCapacityOffset(HediffSet hSet, PawnCapacityDef capacity)
        {
            float num  = capacity.Worker.CalculateCapacityLevel(hSet);
            float num3 = 1f;

            for (int i = 0; i < hSet.hediffs.Count; i++)
            {
                Hediff hediff = hSet.hediffs[i];
                List <PawnCapacityModifier> capMods = hediff.CapMods;
                if (capMods != null)
                {
                    for (int j = 0; j < capMods.Count; j++)
                    {
                        PawnCapacityModifier pawnCapacityModifier = capMods[j];
                        if (pawnCapacityModifier.capacity == capacity)
                        {
                            num  += pawnCapacityModifier.offset;
                            num3 *= pawnCapacityModifier.postFactor;
                        }
                    }
                }
            }
            num *= num3;
            return(num);
        }
Пример #20
0
        public static void Postfix(ref float __result, HediffSet diffSet, PawnCapacityDef capacity, List <CapacityImpactor> impactors = null, bool forTradePrice = false)
        {
            if (diffSet.pawn?.apparel != null)
            {
                var minLevels = new List <float>();
                foreach (var apparel in diffSet.pawn.apparel.WornApparel)
                {
                    var extension = apparel.def.GetModExtension <ApparelExtension>();
                    if (extension?.pawnCapacityMinLevels != null)
                    {
                        var minCapacity = extension.pawnCapacityMinLevels.FirstOrDefault(x => x.capacity == capacity);
                        if (minCapacity != null)
                        {
                            minLevels.Add(minCapacity.minLevel);
                        }
                    }
                }

                if (minLevels.Any())
                {
                    var maxLevel = minLevels.Max();
                    __result = Mathf.Max(__result, maxLevel);
                }
            }
        }
Пример #21
0
        private bool CanHarvest(Corpse corpse)
        {
            int maxage = Mathf.Max(Mod.BasicAutopsyCorpseAge.Value, Mod.AdvancedAutopsyCorpseAge.Value,
                                   Mod.GlitterAutopsyCorpseAge.Value);
            float decay = Mathf.Min(Mod.BasicAutopsyFrozenDecay.Value, Mod.AdvancedAutopsyFrozenDecay.Value,
                                    Mod.GlitterAutopsyFrozenDecay.Value);
            CompRottable rot       = corpse.TryGetComp <CompRottable>();
            bool         notRotten = rot == null
                ? corpse.Age <= maxage * 2500
                : rot.RotProgress + (corpse.Age - rot.RotProgress) * decay <=
                                     maxage * 2500;

            Pawn                  pawn  = corpse.InnerPawn;
            BodyPartRecord        core  = pawn.RaceProps.body.corePart;
            List <BodyPartRecord> queue = new List <BodyPartRecord> {
                core
            };
            HediffSet hediffSet = pawn.health.hediffSet;

            while (queue.Count > 0)
            {
                BodyPartRecord part = queue.First();
                queue.Remove(part);
                if (CanGetPart(pawn, part, notRotten) && core != part)
                {
                    return(true);
                }
                queue.AddRange(part.parts.Where(x => !hediffSet.PartIsMissing(x)));
            }

            return(false);
        }
Пример #22
0
        public static void RandomlyDamagePawn(Pawn pawn, int injuriesNumber, int damageAmount)
        {
            if (pawn.story.traits.HasTrait(TraitDef.Named("Wimp")))
            {
                // Do not hurt wimp pawns as they could be spawned as dead and break the lord behavior.
                return;
            }
            HediffSet hediffSet     = pawn.health.hediffSet;
            int       injuriesIndex = 0;

            while ((pawn.Dead == false) &&
                   (injuriesIndex < injuriesNumber) &&
                   HittablePartsViolence(hediffSet).Any <BodyPartRecord>())
            {
                injuriesIndex++;
                BodyPartRecord bodyPartRecord = HittablePartsViolence(hediffSet).RandomElementByWeight((BodyPartRecord x) => x.coverageAbs);
                DamageDef      def;
                if (bodyPartRecord.depth == BodyPartDepth.Outside)
                {
                    def = HealthUtility.RandomViolenceDamageType();
                }
                else
                {
                    def = DamageDefOf.Blunt;
                }
                BodyPartRecord forceHitPart = bodyPartRecord;
                DamageInfo     dinfo        = new DamageInfo(def, damageAmount, 0f, -1f, null, forceHitPart, null, DamageInfo.SourceCategory.ThingOrUnknown);
                pawn.TakeDamage(dinfo);
            }
        }
Пример #23
0
        private static void AddHackedPawnGizmos(Pawn __instance, ref List <Gizmo> gizmoList, ExtendedDataStorage store)
        {
            ExtendedPawnData pawnData = store.GetExtendedDataFor(__instance);

            gizmoList.Add(CreateGizmo_SearchAndDestroy(__instance, pawnData));
            gizmoList.Add(CreateGizmo_AutoRecharge(__instance, pawnData));
            HediffSet hediffSet = __instance.health.hediffSet;

            if (!__instance.IsColonistPlayerControlled)
            {
                if (__instance.apparel != null)
                {
                    foreach (Gizmo apparelGizmo in __instance.apparel.GetGizmos())
                    {
                        gizmoList.Add(apparelGizmo);
                    }
                }
            }
            if (hediffSet.HasHediff(WTH_DefOf.WTH_SelfDestruct))
            {
                gizmoList.Add(CreateGizmo_SelfDestruct(__instance, pawnData));
            }
            if (hediffSet.HasHediff(WTH_DefOf.WTH_RepairModule))
            {
                gizmoList.Add(CreateGizmo_SelfRepair(__instance, pawnData));
            }
            if (hediffSet.HasHediff(WTH_DefOf.WTH_RepairModule) && hediffSet.HasHediff(WTH_DefOf.WTH_RepairArm))
            {
                gizmoList.Add(CreateGizmo_Repair(__instance, pawnData));
            }
            if (hediffSet.HasHediff(WTH_DefOf.WTH_BeltModule))
            {
                gizmoList.Add(CreateGizmo_EquipBelt(__instance, pawnData));
            }
        }
        /// <summary>gets the random selection weight.</summary>
        /// <param name="initiator">The initiator.</param>
        /// <param name="recipient">The recipient.</param>
        /// <returns></returns>
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            float weight = 0f;
            Dictionary <string, float> dicc = new Dictionary <string, float>()
            {
                { "EtherCowEar", 0.5f },
                { "EtherCowTail", 1f },
                { "EtherUdder", 2f },
                { "EtherHoofHand", 1f },
                { "EtherClovenHoofFoot", 0.5f },
                { "EtherHorns", 0.5f },
            };
            HediffSet hs = initiator.health.hediffSet;

            if (initiator.health.hediffSet.HasHediff(HediffDef.Named("EtherCowSnout")))
            {
                foreach (KeyValuePair <string, float> pair in dicc)
                {
                    if (hs.HasHediff(HediffDef.Named(pair.Key)))
                    {
                        weight += pair.Value;
                    }
                }
                if (hs.HasHediff(HediffDef.Named("EtherUdder")))
                {
                    weight += hs.hediffs.Find(x => x.def.defName == "EtherUdder").Severity * 3;
                }
                return(weight);
            }
            else
            {
                return(0f);
            }
        }
Пример #25
0
        protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target)
        {
            DamageWorker.DamageResult damageResult = new DamageWorker.DamageResult();
            if (tool == null)
            {
                Log.ErrorOnce("Attempted to apply melee hediff without a tool", 38381735);
                return(damageResult);
            }
            Pawn pawn = target.Thing as Pawn;

            if (pawn == null)
            {
                Log.ErrorOnce("Attempted to apply melee hediff without pawn target", 78330053);
                return(damageResult);
            }
            HediffSet      hediffSet         = pawn.health.hediffSet;
            BodyPartTagDef bodypartTagTarget = verbProps.bodypartTagTarget;

            foreach (BodyPartRecord notMissingPart in hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, bodypartTagTarget))
            {
                damageResult.AddHediff(pawn.health.AddHediff(tool.hediff, notMissingPart));
                damageResult.AddPart(pawn, notMissingPart);
                damageResult.wounded = true;
            }
            return(damageResult);
        }
Пример #26
0
        public static void RemoveCommUnit(X2_AIRobot pawn)
        {
            // Do not remove, if one of the following work types:
            if (pawn.workSettings.GetPriority(WorkTypeDefOf.Doctor) > 0 ||
                pawn.workSettings.GetPriority(WorkTypeDefOf.Handling) > 0 ||
                pawn.workSettings.GetPriority(WorkTypeDefOf.Warden) > 0)
            {
                return;
            }

            PawnCapacityDef activity = PawnCapacityDefOf.Talking;

            if (pawn.health.capacities.CapableOf(activity))
            {
                HediffSet hediffSet = pawn.health.hediffSet;
                IEnumerable <BodyPartRecord> notMissingParts = hediffSet.GetNotMissingParts();

                BodyPartRecord bodyPart = notMissingParts.Where(p => p.def.defName == "AIRobot_CommUnit").FirstOrDefault();

                if (bodyPart != null)
                {
                    DamageInfo damageInfo = new DamageInfo(DamageDefOf.EMP, Mathf.RoundToInt(hediffSet.GetPartHealth(bodyPart)), 0f, -1f, null, bodyPart, null, DamageInfo.SourceCategory.ThingOrUnknown, null);
                    //pawn.TakeDamage(damageInfo);


                    Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, pawn, null);
                    hediff_MissingPart.IsFresh    = false;
                    hediff_MissingPart.lastInjury = null;
                    pawn.health.AddHediff(hediff_MissingPart, bodyPart, damageInfo);
                    pawn.health.Notify_HediffChanged(hediff_MissingPart);

                    pawn.apparel.Notify_LostBodyPart();
                }
            }
        }
Пример #27
0
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            float num  = 0f;
            float num2 = PawnCapacityUtility.CalculateLimbEfficiency(diffSet, "ManipulationLimbCore", "ManipulationLimbSegment", "ManipulationLimbDigit", 0.8f, out num, impactors);

            return(num2 * base.CalculateCapacityAndRecord(diffSet, PawnCapacityDefOf.Consciousness, impactors));
        }
 private static IEnumerable <BodyPartRecord> HittablePartsViolence(HediffSet bodyModel)
 {
     return(bodyModel.GetNotMissingParts()
            .Where(x => x.depth == BodyPartDepth.Outside ||
                   x.depth == BodyPartDepth.Inside &&
                   x.def.IsSolid(x, bodyModel.hediffs)));
 }
Пример #29
0
            public static void Listener(HediffSet __instance, ref Hediff __result, HediffDef def, bool mustBeVisible = false)
            {
                try
                {
                    if (!Utils.PSYCHOLOGY_LOADED)
                    {
                        return;
                    }


                    if (!__instance.pawn.IsAndroidTier() || !Utils.BlacklistedHediffsForAndroids.Contains(def.defName))
                    {
                        return;
                    }

                    var find = __instance.hediffs.FirstOrDefault(hediff => hediff.def == def && (!mustBeVisible || hediff.Visible)) ??
                               __instance.pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamed("ATPP_DummyHediff"));


                    __result = find;
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] HediffSet.GetFirstHediffOfDef" + e.Message + " - " + e.StackTrace);
                }
            }
        public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            float functionalPercentage = 0f;
            float num = PawnCapacityUtility.CalculateLimbEfficiency(diffSet, BodyPartTagDefOf.ManipulationLimbCore, BodyPartTagDefOf.ManipulationLimbSegment, BodyPartTagDefOf.ManipulationLimbDigit, 0.8f, out functionalPercentage, impactors);

            return(num * CalculateCapacityAndRecord(diffSet, PawnCapacityDefOf.Consciousness, impactors));
        }
Пример #31
0
 private static IEnumerable<BodyPartRecord> HittablePartsViolence(HediffSet bodyModel)
 {
     return
         from x in bodyModel.GetNotMissingParts(null, null)
         where x.depth == BodyPartDepth.Outside || (x.depth == BodyPartDepth.Inside && x.def.IsSolid(x, bodyModel.hediffs))
         select x;
 }