public static void IgnoreCloak(Pawn __instance, ref bool __result, IAttackTargetSearcher disabledFor)
        {
            bool            selected__instance = Find.Selector.SelectedObjects.Contains(__instance);
            Comp_Facehugger _Xenomorph         = null;

            if (disabledFor != null)
            {
                if (disabledFor.Thing != null)
                {
                    _Xenomorph = disabledFor.Thing.TryGetComp <Comp_Facehugger>();
                    if (_Xenomorph != null)
                    {
                        __result = __result || !XenomorphUtil.isInfectablePawn(__instance);
                        //    Log.Message(string.Format("__instance: {0}, __result: {1}, _Xenomorph: {2}, Infectable?: {3}", __instance, __result, _Xenomorph, XenomorphUtil.isInfectablePawn(__instance)));
                    }
                }
            }
            if (__instance != null)
            {
                if (__instance != null)
                {
                }
            } // XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden
            __result = __result || ((__instance.health.hediffSet.HasHediff(YautjaDefOf.RRY_Hediff_Cloaked) || __instance.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden)) && _Xenomorph == null);
        }
Beispiel #2
0
        public override void CompPostPostRemoved()
        {
            Thing   hostThing = Pawn;
            Pawn    hostPawn  = Pawn;
            IntVec3 spawnLoc  = !Pawn.Dead ? Pawn.Position.RandomAdjacentCell8Way() : Pawn.PositionHeld.RandomAdjacentCell8Way();
            Map     spawnMap  = !Pawn.Dead ? Pawn.Map : Pawn.MapHeld;
            bool    spawnLive = this.spawnLive;

            hostPawn.health.AddHediff(XenomorphDefOf.RRY_Hediff_Anesthetic);
            //    if ((hostPawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_XenomorphImpregnation) && !hasImpregnated))
            if (!hasImpregnated)
            {
                spawnLive = true;
            }
            PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(pawnKindDef, null, PawnGenerationContext.NonPlayer, -1, true, false, true, false, true, true, 0f);
            Pawn pawn = PawnGenerator.GeneratePawn(pawnGenerationRequest);

            if (Instigator != null)
            {
                pawn = instigator;
            }
            if (spawnLive == true)
            {
                Comp_Facehugger _Facehugger = pawn.TryGetComp <Comp_Facehugger>();
                if (_Facehugger != null)
                {
                    _Facehugger.Impregnations = previousImpregnations;
                }
                GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0);
                pawn.jobs.ClearQueuedJobs();
                //    pawn.jobs.curJob = new Verse.AI.Job(JobDefOf.FleeAndCower, hostPawn);
                if (killhugger)
                {
                    pawn.Kill(null);
                }
            }
            else
            {
                GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0);
                Comp_Facehugger _Facehugger = pawn.TryGetComp <Comp_Facehugger>();
                //    pawn.jobs.ClearQueuedJobs();
                //    pawn.jobs.curJob = new Verse.AI.Job(JobDefOf.FleeAndCower, hostPawn);
                _Facehugger.Impregnations = previousImpregnations;
                if (killhugger)
                {
                    pawn.Kill(null);
                }
                // pawn.Kill(null);
            }
            string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Detach", base.parent.pawn.LabelShort);

            if (!base.Pawn.Dead)
            {
                MoteMaker.ThrowText(spawnLoc.ToVector3(), spawnMap, text, 5f);
            }
        }
        public static void IgnoreCloak(Pawn __instance, ref bool __result, IAttackTargetSearcher disabledFor)
        {
            bool            selected__instance = Find.Selector.SelectedObjects.Contains(__instance);
            Comp_Facehugger _Xenomorph         = null;
            Pawn            pawn = null;

            if (disabledFor != null)
            {
                if (disabledFor.Thing != null)
                {
                    if (disabledFor.Thing.GetType() == typeof(Pawn))
                    {
                        pawn = (Pawn)disabledFor.Thing;
                        if (pawn != null)
                        {
                            if (pawn.equipment != null)
                            {
                                if (pawn.equipment.Primary != null)
                                {
                                    CompSmartgunSystem smartgunSystem = pawn.equipment.Primary.TryGetComp <CompSmartgunSystem>();
                                    if (smartgunSystem != null)
                                    {
                                        if (smartgunSystem.hasTargheter && smartgunSystem.hasHarness)
                                        {
                                            //    Log.Message(string.Format("{0} IgnoreCloak {1}: {2}", pawn.LabelShortCap, __instance, __result));
                                            return;
                                        }
                                    }
                                }
                            }
                            _Xenomorph = pawn.TryGetComp <Comp_Facehugger>();
                            if (_Xenomorph != null)
                            {
                                __result = __result || !__instance.isPotentialHost();
                                //    Log.Message(string.Format("__instance: {0}, __result: {1}, _Xenomorph: {2}, Infectable?: {3}", __instance, __result, _Xenomorph, __instance.isPotentialHost()));
                            }
                        }
                    }
                }
            }

            if (__instance != null)
            {
                if (__instance != null)
                {
                    bool cloaked = __instance.health.hediffSet.HasHediff(YautjaDefOf.RRY_Hediff_Cloaked);
                    bool hidden  = __instance.isXenomorph(out Comp_Xenomorph comp) && comp.hidden;
                    bool Stealth = cloaked || hidden;
                    __result = __result || Stealth;
                }
            } // XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden
        }
        // 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 override void CompPostPostRemoved()
        {
            Thing   hostThing = Pawn;
            Pawn    hostPawn  = Pawn;
            Map     spawnMap  = !Pawn.Dead ? Pawn.Map : Pawn.MapHeld;
            IntVec3 spawnLoc  = !Pawn.Dead ? Pawn.Position : Pawn.PositionHeld;

            foreach (IntVec3 loc in GenRadial.RadialCellsAround(spawnLoc, 1, false))
            {
                if (loc.Standable(spawnMap))
                {
                    spawnLoc = loc;
                    Rand.Chance(0.5f);
                    break;
                }
            }
            bool spawnLive = this.spawnLive;

            hostPawn.health.AddHediff(XenomorphDefOf.RRY_Hediff_Anesthetic);
            //    if ((hostPawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_XenomorphImpregnation) && !hasImpregnated))
            if (!hasImpregnated)
            {
                spawnLive = true;
            }
            Pawn pawn;

            if (Instigator != null)
            {
                //    Log.Message("using instigator");
                pawn = instigator;
            }
            else
            {
                if (this.innerContainer.Any(x => x is Pawn))
                {
                    //    Log.Message("using innerContainer");
                    pawn = (Pawn)this.innerContainer.First(x => x is Pawn);
                }
                else
                {
                    //    Log.Message("using PawnGenerator");
                    PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(pawnKindDef, null, PawnGenerationContext.NonPlayer, -1, true, false, true, false, true, true, 0f);
                    pawn = PawnGenerator.GeneratePawn(pawnGenerationRequest);
                }
            }
            if (spawnLive == true)
            {
                //    Log.Message("using spawnLive");
                Comp_Facehugger _Facehugger = pawn.TryGetComp <Comp_Facehugger>();
                if (_Facehugger != null)
                {
                    _Facehugger.Impregnations = previousImpregnations;
                }
                if (!pawn.Spawned)
                {
                    GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0);
                }
                pawn.jobs.ClearQueuedJobs();
                //    pawn.jobs.curJob = new Verse.AI.Job(JobDefOf.FleeAndCower, hostPawn);
                if (killhugger)
                {
                    pawn.Kill(null);
                }
            }
            else
            {
                //    Log.Message("using spawnDead");
                if (!pawn.Spawned)
                {
                    GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0);
                }
                Comp_Facehugger _Facehugger = pawn.TryGetComp <Comp_Facehugger>();
                //    pawn.jobs.ClearQueuedJobs();
                //    pawn.jobs.curJob = new Verse.AI.Job(JobDefOf.FleeAndCower, hostPawn);
                _Facehugger.Impregnations = previousImpregnations;
                if (killhugger)
                {
                    pawn.Kill(null);
                }
                // pawn.Kill(null);
            }
            string text = TranslatorFormattedStringExtensions.Translate("Xeno_Facehugger_Detach", base.parent.pawn.LabelShort);

            if (!base.Pawn.Dead)
            {
                MoteMaker.ThrowText(spawnLoc.ToVector3(), spawnMap, text, 5f);
            }
        }
        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);
                        }
                    }
                }
            }
        }