public static void BestPawnToHuntForPredator(Pawn predator, bool forceScanWholeMap, ref Pawn __result) { if (predator.isNeomorph()) { Comp_Neomorph _Neomorph = predator.TryGetComp <Comp_Neomorph>(); __result = _Neomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap); } if (predator.isXenomorph()) { Comp_Xenomorph _Xenomorph = predator.TryGetComp <Comp_Xenomorph>(); __result = _Xenomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap); } }
public static bool RenderOverBodyPrefix(PawnWoundDrawer __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); bool flag_Cloaked = pawn.health.hediffSet.HasHediff(YautjaDefOf.RRY_Hediff_Cloaked, false); Comp_Xenomorph comp = null; bool flag_HiddenXeno = (pawn.isXenomorph(out comp) || !pawn.isXenomorph() && pawn.CarriedBy != null && pawn.CarriedBy.isXenomorph(out comp)) && (comp != null && (comp.Hidden || comp.hidden)); if (flag_Cloaked || flag_HiddenXeno) { return(false); } return(true); }
public static void BestPawnToHuntForPredator(Pawn predator, bool forceScanWholeMap, ref Pawn __result) { if (predator.isNeomorph()) { Comp_Neomorph _Neomorph = predator.TryGetComp <Comp_Neomorph>(); __result = _Neomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap); } if (predator.isXenomorph()) { if (predator.ageTracker.CurLifeStage == XenomorphDefOf.RRY_XenomorphFullyFormed) { Comp_Xenomorph _Xenomorph = predator.TryGetComp <Comp_Xenomorph>(); __result = _Xenomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap); } } }
public static void IgnoreCloak(Pawn __instance, ref bool __result, IAttackTargetSearcher disabledFor) { bool selected__instance = Find.Selector.SelectedObjects.Contains(__instance); Comp_Xenomorph _Xenomorph = null; if (disabledFor != null) { if (disabledFor.Thing != null) { _Xenomorph = disabledFor.Thing.TryGetComp <Comp_Xenomorph>(); if (_Xenomorph != null) { } } } 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); }
public static bool PawnRenderer_XenosColour_Prefix(PawnRenderer __instance, ref Vector3 drawLoc, ref RotDrawMode bodyDrawType, bool headStump) { Pawn value = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); bool selected = Find.Selector.SingleSelectedThing == value; PawnGraphicSet value2 = Traverse.Create(__instance).Field("graphics").GetValue <PawnGraphicSet>(); Comp_Xenomorph _Xenomorph = value.TryGetComp <Comp_Xenomorph>(); if (_Xenomorph != null) { if (_Xenomorph.host != null) { if (selected) { Log.Message(string.Format("Old value.kindDef.lifeStages[0].bodyGraphicData.color: {0}", value.kindDef.lifeStages[0].bodyGraphicData.color)); } if (selected) { Log.Message(string.Format("_Xenomorph.host.race.race.BloodDef.graphicData.color: {0}", _Xenomorph.host.race.race.BloodDef.graphicData.color)); } value.kindDef.lifeStages[0].bodyGraphicData.color = _Xenomorph.host.race.race.BloodDef.graphicData.color; if (selected) { Log.Message(string.Format("New value.kindDef.lifeStages[0].bodyGraphicData.color: {0}", value.kindDef.lifeStages[0].bodyGraphicData.color)); } } else if (selected) { Log.Message(string.Format("_Xenomorph.host: null")); } } else if (selected) { Log.Message(string.Format("_Xenomorph: null")); } return(true); }
public override void Notify_PawnDied() { IntVec3 spawnLoc = !base.Pawn.Dead ? base.parent.pawn.Position : base.parent.pawn.PositionHeld; Map spawnMap = !base.Pawn.Dead ? base.parent.pawn.Map : base.parent.pawn.MapHeld; this.Pawn.def.race.deathActionWorkerClass = typeof(DeathActionWorker_Simple); bool fullterm = this.parent.CurStageIndex > this.parent.def.stages.Count - 3; if (!fullterm) { Log.Message(string.Format("died before reaching fullterm, no spawning")); return; } else { if (spawnMap == null || spawnLoc == null) { Log.Message(string.Format("spawnMap or spawnLoc is null, no spawning")); return; } else { if (countToSpawn == 0) { countToSpawn++; } for (int i = 0; i < countToSpawn; i++) { Pawn pawn = XenomorphSpawnRequest(); // Log.Message(string.Format("Xenomorph to hatch: {0}", pawn.LabelShortCap)); pawn.ageTracker.CurKindLifeStage.bodyGraphicData.color = HostBloodColour; pawn.Notify_ColorChanged(); pawn.ageTracker.AgeBiologicalTicks = 0; pawn.ageTracker.AgeChronologicalTicks = 0; Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); if (_Xenomorph != null) { _Xenomorph.host = base.parent.pawn.kindDef; } GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0); } Vector3 vector = spawnLoc.ToVector3Shifted(); for (int i = 0; i < 101; i++) { if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 2f, 3.TicksToSeconds())) { MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z) { y = AltitudeLayer.MoteOverhead.AltitudeFor() }, spawnMap, 1.5f, new Color(HostBloodColour.r, HostBloodColour.g, HostBloodColour.b, HostBloodColour.a)); } if (i == 100) { } if (i % 10 == 0) { FilthMaker.MakeFilth(spawnLoc + GenAdj.AdjacentCellsAndInside.RandomElement(), this.Pawn.MapHeld, this.Pawn.RaceProps.BloodDef, this.Pawn.LabelIndefinite(), 1); } } ThingDef motedef = DefDatabase <ThingDef> .GetNamedSilentFail("Mote_BlastExtinguisher"); MoteMaker.ThrowExplosionCell(spawnLoc, MyMap, motedef, HostBloodColour); // GenAdj.AdjacentCellsAndInside[i]; for (int i2 = 0; i2 < GenAdj.AdjacentCellsAndInside.Length; i2++) { FilthMaker.MakeFilth(spawnLoc + GenAdj.AdjacentCellsAndInside[i2], this.Pawn.MapHeld, this.Pawn.RaceProps.BloodDef, this.Pawn.LabelIndefinite(), 1); } string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Emerge", base.parent.pawn.LabelShort, this.parent.Part.LabelShort); MoteMaker.ThrowText(spawnLoc.ToVector3(), spawnMap, text, 5f); if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Chestbursters) && MyMap != null) { LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_Chestbursters, OpportunityType.Important); } } } }
public override void Tick() { if (Hidden) { if (!hidden) { MakeInvisible(); hidden = true; } if (!pawn.Spawned) { pawn.health.RemoveHediff(this); } if (pawn.Downed || pawn.Dead || (pawn.pather != null && pawn.pather.WillCollideWithPawnOnNextPathCell())) { pawn.health.RemoveHediff(this); if (pawn.pather != null) { AlertXenomorph(pawn, pawn.pather.nextCell.GetFirstPawn(pawn.Map)); } else { AlertXenomorph(pawn, null); } } if (pawn.pather != null && GetLastCell(pawn.pather).GetDoor(pawn.Map) != null) { GetLastCell(pawn.pather).GetDoor(pawn.Map).StartManualCloseBy(pawn); } if (pawn.Map != null && lastSpottedTick < Find.TickManager.TicksGame - 125) { lastSpottedTick = Find.TickManager.TicksGame; int num = 0; while (num < 20) { IntVec3 c = pawn.Position + GenRadial.RadialPattern[num]; Room room = RegionAndRoomQuery.RoomAt(c, pawn.Map); if (c.InBounds(pawn.Map)) { if (RegionAndRoomQuery.RoomAt(c, pawn.Map) == room) { List <Thing> thingList = c.GetThingList(pawn.Map); foreach (Thing thing in thingList) { Pawn observer = thing as Pawn; if (observer != null && observer != pawn && observer.Faction != null && (observer.Faction.IsPlayer || observer.Faction.HostileTo(pawn.Faction))) { float observerSight = observer.health.capacities.GetLevel(PawnCapacityDefOf.Sight); observerSight *= 0.805f + (pawn.Map.glowGrid.GameGlowAt(pawn.Position) / 4); if (observer.RaceProps.Animal) { observerSight *= 0.9f; } observerSight = Math.Min(2f, observerSight); float thiefMoving = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving); float spotChance = 0.8f * thiefMoving / observerSight; if (Rand.Value > spotChance) { if (pawn.isXenomorph()) { Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); _Xenomorph.Hidden = false; } if (pawn.isNeomorph()) { Comp_Neomorph _Nenomorph = pawn.TryGetComp <Comp_Neomorph>(); _Nenomorph.Hidden = false; } //pawn.health.RemoveHediff(this); AlertXenomorph(pawn, observer); } } else if (observer == null) { if (thing is Building_Turret turret && turret.Faction != null && turret.Faction.IsPlayer) { float thiefMoving = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving); float spotChance = 0.99f * thiefMoving; if (Rand.Value > spotChance) { if (pawn.isXenomorph()) { Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); _Xenomorph.Hidden = false; } if (pawn.isNeomorph()) { Comp_Neomorph _Nenomorph = pawn.TryGetComp <Comp_Neomorph>(); _Nenomorph.Hidden = false; } //pawn.health.RemoveHediff(this); AlertXenomorph(pawn, turret); } } } } } } num++; } Thing holding = pawn.carryTracker.CarriedThing; if (lastCarried != holding) { if (lastCarried != null) { SetGraphicInt(lastCarried, lastCarriedGraphic); } if (holding != null) { lastCarried = holding; lastCarriedGraphic = holding.Graphic; SetGraphicInt(lastCarried, new Graphic_Invisible()); } } } } else { if (hidden) { MakeVisible(); hidden = false; } } }
public override void Notify_PawnDied() { IntVec3 spawnLoc = !base.Pawn.Dead ? base.parent.pawn.Position : base.parent.pawn.PositionHeld; Map spawnMap = !base.Pawn.Dead ? base.parent.pawn.Map : base.parent.pawn.MapHeld; bool selected = Find.Selector.SingleSelectedThing == parent.pawn; ///((Pawn)base.Pawn).def.race.deathActionWorkerClass. this.Pawn.def.race.deathActionWorkerClass = typeof(DeathActionWorker_Simple); List <PawnKindDef> pawnKindDefs = Props.pawnKindDefs; List <float> pawnKindWeights = Props.pawnKindWeights; PawnKindDef pawnKindDef = pawnKindDefs[pawnKindDefs.Count - 1]; int ind = 0; bool fullterm = this.parent.CurStageIndex > this.parent.def.stages.Count - 3; if (!fullterm) { return; } if (this.Pawn.MapHeld == null) { return; } bool QueenPresent = false; foreach (var p in base.parent.pawn.MapHeld.mapPawns.AllPawnsSpawned) { if (p.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen) { QueenPresent = true; break; } } foreach (var PKDef in pawnKindDefs) { float hostSize = base.parent.pawn.BodySize; float spawnRoll = ((Rand.Range(1, 100)) * hostSize); if (PKDef == XenomorphDefOf.RRY_Xenomorph_Queen && QueenPresent) { spawnRoll = 0; #if DEBUG if (selected) { Log.Message(string.Format("{0} :{1}", PKDef.label, QueenPresent)); } #endif } if (spawnRoll > (100 - pawnKindWeights[ind])) { pawnKindDef = PKDef; break; } ind++; } #if DEBUG Log.Message(string.Format("{0} Old pawnKindDef.lifeStages[0].bodyGraphicData.color: {1}", base.parent.pawn.Name, pawnKindDef.lifeStages[0].bodyGraphicData.color)); Log.Message(string.Format("{0} base.parent.pawn.def.race.BloodDef.graphic.color: {1}", base.parent.pawn.Name, base.parent.pawn.def.race.BloodDef.graphic.color)); #endif if (Pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja) { pawnKindDef = XenomorphDefOf.RRY_Xenomorph_Predalien; } Color color = base.parent.pawn.def.race.BloodDef.graphic.color; color.a = 1f; pawnKindDef.lifeStages[0].bodyGraphicData.color = color; #if DEBUG Log.Message(string.Format("{0} new value.kindDef.lifeStages[0].bodyGraphicData.color: {1}", base.parent.pawn.Name, pawnKindDef.lifeStages[0].bodyGraphicData.color)); #endif PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(pawnKindDef, Find.FactionManager.FirstFactionOfDef(pawnKindDef.defaultFactionType), PawnGenerationContext.NonPlayer, -1, true, false, true, false, true, true, 20f); Pawn pawn = PawnGenerator.GeneratePawn(pawnGenerationRequest); pawn.ageTracker.CurKindLifeStage.bodyGraphicData.color = color; //this this will error pawn.Graphic.data.color = color; if (pawnKindDef == XenomorphDefOf.RRY_Xenomorph_Queen) { pawn.gender = Gender.Female; } else { pawn.gender = Gender.Male; } pawn.ageTracker.AgeBiologicalTicks = 0; pawn.ageTracker.AgeChronologicalTicks = 0; Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); if (_Xenomorph != null) { _Xenomorph.host = base.parent.pawn.kindDef; } Vector3 vector = spawnLoc.ToVector3Shifted(); GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0); for (int i = 0; i < 101; i++) { // Find.TickManager.TicksGame if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 2f, 3.TicksToSeconds())) { MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z) { y = AltitudeLayer.MoteOverhead.AltitudeFor() }, spawnMap, 1.0f, new Color(color.r, color.g, color.b, 1f)); } } string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Emerge", base.parent.pawn.LabelShort, this.parent.Part.LabelShort); MoteMaker.ThrowText(spawnLoc.ToVector3(), spawnMap, text, 5f); //base.Pawn.health.RemoveHediff(this.parent); }