public Material ImplantMaterial(Pawn pawn, Rot4 bodyFacing)
        {
            string path;
            HediffComp_XenoFacehugger _XenoFacehugger = parent.TryGetComp <HediffComp_XenoFacehugger>();

            if (_XenoFacehugger != null)
            {
                if (this.implantDrawProps.implantDrawerType == ImplantDrawerType.Head)
                {
                    path = _XenoFacehugger.TexPath;
                }
                else
                {
                    path = _XenoFacehugger.TexPath + "_" + pawn.story.bodyType.ToString();
                }
            }
            else // if (!implantDrawProps.implantGraphicPath.NullOrEmpty())
            {
                if (this.implantDrawProps.implantDrawerType == ImplantDrawerType.Head)
                {
                    path = implantDrawProps.implantGraphicPath;
                }
                else
                {
                    path = implantDrawProps.implantGraphicPath + "_" + pawn.story.bodyType.ToString();
                }
            }
            return(GraphicDatabase.Get <Graphic_Multi>(path, ShaderDatabase.Cutout, Vector2.one, Color.white).MatAt(bodyFacing));
        }
Example #2
0
        // Token: 0x060039DF RID: 14815 RVA: 0x001B80A4 File Offset: 0x001B64A4
        protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target)
        {
            Pawn hitPawn = (Pawn)target;

            DamageWorker.DamageResult result = new DamageWorker.DamageResult();
            foreach (DamageInfo dinfo in this.DamageInfosToApply(target))
            {
                if (target.ThingDestroyed)
                {
                    break;
                }
                result = target.Thing.TakeDamage(dinfo);
            }
            if (infect)
            {
                foreach (var part in hitPawn.RaceProps.body.AllParts.Where(x => x.def.defName == "Head"))
                {
                    Hediff hediff = HediffMaker.MakeHediff(XenomorphDefOf.RRY_FaceHuggerInfection, hitPawn, null);
                    HediffComp_XenoFacehugger comp = hediff.TryGetComp <HediffComp_XenoFacehugger>();
                    comp.Props.Instigator = CasterPawn;
                    hitPawn.health.AddHediff(hediff, part, null);
                    string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Attach", hitPawn.LabelShort, part.LabelShortCap);
                    MoteMaker.ThrowText(hitPawn.Position.ToVector3(), hitPawn.Map, text, 5f);
                    caster.DeSpawn();
                }
            }
            return(result);
        }
        // Token: 0x060039DF RID: 14815 RVA: 0x001B80A4 File Offset: 0x001B64A4
        protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target)
        {
            DamageWorker.DamageResult result = new DamageWorker.DamageResult();
            Pawn hitPawn = (Pawn)target;

            if (infect && !XenomorphUtil.IsInfectedPawn(hitPawn) && !hitPawn.Dead && hitPawn.RaceProps.body.AllParts.Any(x => x.def.defName.Contains("Head")))
            {
                foreach (var part in hitPawn.RaceProps.body.AllParts.Where(x => x.def.defName.Contains("Head")))
                {
                    Hediff                    hediff      = HediffMaker.MakeHediff(XenomorphDefOf.RRY_FaceHuggerInfection, hitPawn, null);
                    Comp_Facehugger           _Facehugger = CasterPawn.TryGetComp <Comp_Facehugger>();
                    HediffComp_XenoFacehugger comp        = hediff.TryGetComp <HediffComp_XenoFacehugger>();
                    comp.instigator            = CasterPawn;
                    comp.instigatorKindDef     = CasterPawn.kindDef;
                    comp.royaleHugger          = _Facehugger.RoyaleHugger;
                    comp.previousImpregnations = _Facehugger.Impregnations;
                    hitPawn.health.AddHediff(hediff, part, null);
                    string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Attach", hitPawn.LabelShort, part.LabelShortCap);
                    MoteMaker.ThrowText(hitPawn.Position.ToVector3(), hitPawn.Map, text, 5f);
                    comp.GetDirectlyHeldThings();
                    caster.DeSpawn();
                    infect = false;
                }
            }
            else
            {
                foreach (DamageInfo dinfo in this.DamageInfosToApply(target))
                {
                    if (target.ThingDestroyed)
                    {
                        break;
                    }
                    result = target.Thing.TakeDamage(dinfo);
                }
            }
            return(result);
        }
        public static void DamageInfosToApply_ForceWeapon_Postfix(ref Verb_MeleeAttackDamage __instance, LocalTargetInfo target, ref IEnumerable <DamageInfo> __result)
        {
            if (__instance != null)
            {
                if (target == null)
                {
                    return;
                }
                if (!target.HasThing)
                {
                    return;
                }
                if (target.Pawn == null)
                {
                    return;
                }
                if (__instance.CasterIsPawn)
                {
                    Pawn Attacker = __instance.CasterPawn;
                    Pawn hitPawn  = target.Pawn;
                    if (__instance.CasterPawn.isXenomorph())
                    {
                        if (Attacker.def == XenomorphRacesDefOf.RRY_Xenomorph_FaceHugger)
                        {
                            if (!hitPawn.isPotentialHost() || Head(hitPawn) == null)
                            {
                                return;
                            }
                            DamageWorker.DamageResult result = new DamageWorker.DamageResult();
                            DamageDef def      = __instance.verbProps.meleeDamageDef;
                            float     tgtmelee = 0f;
                            float     tgtdodge = 0f;
                            float     armour   = 0f;
                            if (hitPawn.RaceProps.Humanlike)
                            {
                                tgtmelee = hitPawn.skills.GetSkill(SkillDefOf.Melee).Level;
                            }
                            if (hitPawn.RaceProps.Humanlike)
                            {
                                tgtdodge = hitPawn.GetStatValue(StatDefOf.MeleeDodgeChance);
                            }
                            if (hitPawn.RaceProps.Humanlike)
                            {
                                if (hitPawn.apparel.WornApparel.Count > 0 && hitPawn.apparel.WornApparel is List <Apparel> wornApparel)
                                {
                                    for (int i = 0; i < wornApparel.Count; i++)
                                    {
                                        bool flag2 = wornApparel[i].def.apparel.CoversBodyPart(Head(hitPawn)) || wornApparel[i].def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.FullHead);
                                        if (flag2)
                                        {
                                            armour += wornApparel[i].def.statBases.GetStatOffsetFromList(def.armorCategory.armorRatingStat);
                                        }
                                    }
                                }
                            }
                            float InfectionDefence = 50 + tgtmelee + (armour * 10);
                            float InfecterRoll     = (Rand.Value * 100) * (1 - tgtdodge);

                            if ((InfecterRoll > InfectionDefence || (hitPawn.Downed || !hitPawn.Awake())) && !hitPawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Anesthetic))
                            {
                                Hediff                    hediff      = HediffMaker.MakeHediff(XenomorphDefOf.RRY_FaceHuggerInfection, hitPawn, null);
                                Comp_Facehugger           _Facehugger = Attacker.TryGetComp <Comp_Facehugger>();
                                HediffComp_XenoFacehugger comp        = hediff.TryGetComp <HediffComp_XenoFacehugger>();
                                comp.instigator            = Attacker;
                                comp.instigatorKindDef     = Attacker.kindDef;
                                comp.royaleHugger          = _Facehugger.RoyaleHugger;
                                comp.previousImpregnations = _Facehugger.Impregnations;
                                hitPawn.health.AddHediff(hediff, Head(hitPawn), null);
                                string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Attach", hitPawn.LabelShort, Head(hitPawn).LabelShortCap);
                                MoteMaker.ThrowText(hitPawn.Position.ToVector3(), hitPawn.Map, text, 5f);
                                if (Attacker.Spawned)
                                {
                                    Attacker.DeSpawn();
                                }
                                comp.TryAcceptThing(Attacker);
                                //    comp.GetDirectlyHeldThings().TryAdd(CasterPawn);
                            }
                        }
                        else
                        {
                            if (!hitPawn.isPotentialHost() || hitPawn.Awake())
                            {
                                return;
                            }

                            HealthUtility.DamageUntilDowned(hitPawn, false);
                        }
                    }
                }
            }
        }