public static void RacesFoodConsumption() { Func <ThingDef, int, string> lsName = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def3 = d.race.lifeStageAges[lsIndex].def; return(def3.defName); }; Func <ThingDef, int, string> maxFood = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def2 = d.race.lifeStageAges[lsIndex].def; return((d.race.baseBodySize * def2.bodySizeFactor * def2.foodMaxFactor).ToString("F2")); }; Func <ThingDef, int, string> hungerRate = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def = d.race.lifeStageAges[lsIndex].def; return((d.race.baseHungerRate * def.hungerRateFactor).ToString("F2")); }; DebugTables.MakeTablesDialog(from d in DefDatabase <ThingDef> .AllDefs where d.race != null && d.race.EatsFood orderby d.race.baseHungerRate descending select d, new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName), new TableDataGetter <ThingDef>("Lifestage 0", (ThingDef d) => lsName(d, 0)), new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 0)), new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 0)), new TableDataGetter <ThingDef>("Lifestage 1", (ThingDef d) => lsName(d, 1)), new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 1)), new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 1)), new TableDataGetter <ThingDef>("Lifestage 2", (ThingDef d) => lsName(d, 2)), new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 2)), new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 2)), new TableDataGetter <ThingDef>("Lifestage 3", (ThingDef d) => lsName(d, 3)), new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 3)), new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 3))); }
// Token: 0x06000956 RID: 2390 RVA: 0x0004D678 File Offset: 0x0004BA78 public override bool Satisfied(Pawn pawn) { LifeStageDef stage = pawn.ageTracker.CurLifeStage; LifeStageDef targetStage = pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def; return(stage == targetStage); }
public override void PostRemoved() { if (XenomorphUtil.IsXenomorph(this.pawn)) { LifeStageDef stage = pawn.ageTracker.CurLifeStage; if (stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def) { Log.Message(string.Format("{0}", oldGraphics.nakedGraphic.path)); Log.Message(string.Format("{0}", oldGraphics.AllResolved.ToString())); } } pawn.Drawer.renderer.graphics = oldGraphics; pawn.Drawer.renderer.graphics.ResolveAllGraphics(); SetShadowGraphic(pawn.Drawer.renderer, oldShadow); Thing holding = pawn.carryTracker.CarriedThing; if (holding != null) { SetGraphicInt(holding, lastCarriedGraphic); } else if (lastCarried != null) { SetGraphicInt(lastCarried, lastCarriedGraphic); } if (!pawn.Spawned && (holding != null || lastCarried != null)) { Messages.Message("A thief has stolen " + (holding != null ? holding.LabelNoCount : lastCarried.LabelNoCount) + "!", MessageTypeDefOf.ThreatSmall); } }
public static void SetAge(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn) { ThingSettings TS = comp.ChosenItem; if (TS.IsCopier && TS.copyParent.age) { LifeStageDef LSDef = comp.Pawn.ageTracker.CurLifeStage; LifeStageAge LSAge = comp.Pawn.def.race.lifeStageAges.Where(LS => LS.def == LSDef).FirstOrFallback(); if (LSAge == null) { return; } newPawn.ageTracker.AgeBiologicalTicks = (long)(LSAge.minAge * MyDefs.OneYearTicks); newPawn.ageTracker.AgeChronologicalTicks = Math.Max(comp.Pawn.ageTracker.AgeBiologicalTicks, comp.Pawn.ageTracker.AgeChronologicalTicks); return; } /* * else if (TS.HasAgeRange) * { * if(TS.HasBiologicalAgeRange) * newPawn.ageTracker.AgeBiologicalTicks = MyDefs.OneYearTicks * TS.biologicalAgeRange.RandomInRange; * if (TS.HasChronologicalAgeRange) * newPawn.ageTracker.AgeBiologicalTicks = MyDefs.OneYearTicks * TS.chronologicalAgeRange.RandomInRange; * } */ newPawn.ageTracker.AgeBiologicalTicks = MyDefs.OneYearTicks * TS.biologicalAgeRange.RandomInRange; newPawn.ageTracker.AgeChronologicalTicks = MyDefs.OneYearTicks * TS.chronologicalAgeRange.RandomInRange + newPawn.ageTracker.AgeBiologicalTicks; }
public static bool CheckLifeStageCondition(this Pawn p, List <LifeStageDef> lsd) { LifeStageDef lifeStageDef = p.ageTracker.CurLifeStage; if (lsd.Contains(lifeStageDef)) { return(true); } return(false); }
// public static bool PawnBelongsToLifeStage(this Pawn p, List <string> parameters) { foreach (string s in parameters) { LifeStageDef LSD = DefDatabase <LifeStageDef> .GetNamed(s); if (p.ageTracker.CurLifeStage == LSD) { return(true); } } return(false); }
public static void RacesFoodConsumption() { Func <ThingDef, int, string> lsName = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def = d.race.lifeStageAges[lsIndex].def; return(def.defName); }; Func <ThingDef, int, string> maxFood = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def = d.race.lifeStageAges[lsIndex].def; return((d.race.baseBodySize * def.bodySizeFactor * def.foodMaxFactor).ToString("F2")); }; Func <ThingDef, int, string> hungerRate = delegate(ThingDef d, int lsIndex) { if (d.race.lifeStageAges.Count <= lsIndex) { return(string.Empty); } LifeStageDef def = d.race.lifeStageAges[lsIndex].def; return((d.race.baseHungerRate * def.hungerRateFactor).ToString("F2")); }; IEnumerable <ThingDef> arg_219_0 = from d in DefDatabase <ThingDef> .AllDefs where d.race != null && d.race.EatsFood orderby d.race.baseHungerRate descending select d; TableDataGetter <ThingDef>[] expr_BF = new TableDataGetter <ThingDef> [13]; expr_BF[0] = new TableDataGetter <ThingDef>("defName", (ThingDef d) => d.defName); expr_BF[1] = new TableDataGetter <ThingDef>("Lifestage 0", (ThingDef d) => lsName(d, 0)); expr_BF[2] = new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 0)); expr_BF[3] = new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 0)); expr_BF[4] = new TableDataGetter <ThingDef>("Lifestage 1", (ThingDef d) => lsName(d, 1)); expr_BF[5] = new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 1)); expr_BF[6] = new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 1)); expr_BF[7] = new TableDataGetter <ThingDef>("Lifestage 2", (ThingDef d) => lsName(d, 2)); expr_BF[8] = new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 2)); expr_BF[9] = new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 2)); expr_BF[10] = new TableDataGetter <ThingDef>("Lifestage 3", (ThingDef d) => lsName(d, 3)); expr_BF[11] = new TableDataGetter <ThingDef>("maxFood", (ThingDef d) => maxFood(d, 3)); expr_BF[12] = new TableDataGetter <ThingDef>("hungerRate", (ThingDef d) => hungerRate(d, 3)); DebugTables.MakeTablesDialog <ThingDef>(arg_219_0, expr_BF); }
public override void CompTickRare() { base.CompTickRare(); bool selected = Find.Selector.SelectedObjects.Contains(pawn); Lord lord = pawn.GetLord(); Faction xenos = Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph); if (pawn != null && pawn.Map != null && !pawn.Dead && pawn.kindDef != XenomorphDefOf.RRY_Xenomorph_FaceHugger && pawn.kindDef != XenomorphDefOf.RRY_Xenomorph_RoyaleHugger) { LifeStageDef stage = pawn.ageTracker.CurLifeStage; if (stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def) { if (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden)) { string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Matures", pawn.LabelCap); Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden); MoteMaker.ThrowText(pawn.Position.ToVector3(), pawn.Map, text, 3f); hidden = false; pawn.health.RemoveHediff(hediff); } XenoLordTick(); } else { Thing thing = GenClosest.ClosestThingReachable(this.parent.Position, this.parent.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.Touch, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 6f, x => ((Pawn)this.parent).HostileTo((Pawn)x) && !((Pawn)x).health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Cocooned), null, 0, -1, false, RegionType.Set_Passable, false); if (!((Pawn)this.parent).health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden) && thing == null) { string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Hides"); MoteMaker.ThrowText(base.parent.Position.ToVector3(), base.parent.Map, text, 3f); ((Pawn)this.parent).health.AddHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden); hidden = true; } } } }
// Token: 0x060000AF RID: 175 RVA: 0x00009DC0 File Offset: 0x00007FC0 public static GraphicPaths GetCurrentGraphicPath(this List <GraphicPaths> list, LifeStageDef lifeStageDef) { return(list.FirstOrDefault(delegate(GraphicPaths gp) { List <LifeStageDef> lifeStageDefs = gp.lifeStageDefs; return lifeStageDefs != null && lifeStageDefs.Contains(lifeStageDef); }) ?? list.First <GraphicPaths>()); }
public static GraphicPaths GetCurrentGraphicPath(this List <GraphicPaths> list, LifeStageDef lifeStageDef) => list.FirstOrDefault(predicate: gp => gp.lifeStageDefs?.Contains(item: lifeStageDef) ?? false) ?? list.First();
public override void CompTickRare() { base.CompTickRare(); Pawn pawn = (Pawn)parent; bool selected = Find.Selector.SingleSelectedThing == pawn; Lord lord = pawn.GetLord(); Faction xenos = Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph); if (pawn != null && !pawn.Dead && pawn.kindDef != XenomorphDefOf.RRY_Xenomorph_FaceHugger) { //Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph). LifeStageDef stage = pawn.ageTracker.CurLifeStage; if (stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def) { if (lord == null) { #if DEBUG if (selected) { Log.Message(string.Format("{0} has no lord, looking for lord from {1}", pawn.LabelShort, xenos.Name)); } #endif IEnumerable <Lord> lords = pawn.Map.lordManager.lords.Where(x => x.faction.def == xenos.def); if (lords.Count() != 0) { foreach (var l in lords) { if (l == null) { #if DEBUG if (selected) { Log.Message(string.Format("no lord of faction {0} for {1}", xenos.Name, pawn.LabelShort)); } #endif } else { #if DEBUG if (selected) { Log.Message(string.Format("{0}: added to Lord: {1}, Cur Duty: {2}", pawn.LabelShort, l, l.LordJob)); } #endif lord = l; lord.AddPawn(pawn); break; } } } else { #if DEBUG if (selected) { Log.Message(string.Format("{2} lords of {0} for {1}", xenos.Name, pawn.LabelShort, lords.Count())); } #endif if (pawn.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen) { CreateNewLord(pawn); } } } else { #if DEBUG if (selected) { Log.Message(string.Format("{0} has Lord: {1}, Cur Duty: {2}", pawn.LabelShort, lord, lord.LordJob)); } #endif } } else { Thing thing = GenClosest.ClosestThingReachable(this.parent.Position, this.parent.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.Touch, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 6f, x => ((Pawn)this.parent).HostileTo((Pawn)x), null, 0, -1, false, RegionType.Set_Passable, false); if (!((Pawn)this.parent).health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden) && thing == null) { string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Hides"); // Log.Message(text); MoteMaker.ThrowText(base.parent.Position.ToVector3(), base.parent.Map, text, 3f); ((Pawn)this.parent).health.AddHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden); } } /* * for (int i = 0; i < num2; i++) * { * MoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f)); * } */ } }
public override void Tick() { LifeStageDef stage = pawn.ageTracker.CurLifeStage; if (!pawn.Spawned || (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden) && stage == pawn.RaceProps.lifeStageAges[pawn.RaceProps.lifeStageAges.Count - 1].def)) { pawn.health.RemoveHediff(this); } if (pawn.Downed || pawn.Dead || (pawn.pather != null && pawn.pather.WillCollideWithPawnOnNextPathCell())) { pawn.health.RemoveHediff(this); if (pawn.pather != null) { AlertThief(pawn, pawn.pather.nextCell.GetFirstPawn(pawn.Map)); } else { AlertThief(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) { pawn.health.RemoveHediff(this); AlertThief(pawn, observer); } } else if (observer == null) { Building_Turret turret = thing as Building_Turret; if (turret != null && turret.Faction != null && turret.Faction.IsPlayer) { float thiefMoving = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving); float spotChance = 0.99f * thiefMoving; if (Rand.Value > spotChance) { pawn.health.RemoveHediff(this); AlertThief(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()); } } } }
public void UpdateHediffDependingOnLifeStage() { LifeStageDef lifeStageDef = Pawn.ageTracker.CurLifeStage; foreach (Association association in Props.associations) { // unlegitimate hediff regarding lifestage if (Pawn.HasHediff(association.hediff) && association.lifeStageDef != lifeStageDef) { Hediff destroyhediff = Pawn.health.hediffSet.GetFirstHediffOfDef(association.hediff); destroyhediff.Severity = 0; destroyhediff.PostRemoved(); } // missing hediff for cur lifestage if (!Pawn.HasHediff(association.hediff) && association.lifeStageDef == lifeStageDef) { Hediff lifeStageHediff = null; BodyPartRecord myBPR; if (HasBPSpecification) { IEnumerable <BodyPartRecord> bodyPartRecords; if (!Props.bodyPartLabel.NullOrEmpty()) { bodyPartRecords = Pawn.RaceProps.body.GetPartsWithDef(Props.bodyPartDef).Where(bp => bp.customLabel == Props.bodyPartLabel); } else { bodyPartRecords = Pawn.RaceProps.body.GetPartsWithDef(Props.bodyPartDef); } if (bodyPartRecords.EnumerableNullOrEmpty()) { if (MyDebug) { Log.Warning("Cant find BPR with def: " + Props.bodyPartDef.defName + ", skipping"); } continue; } myBPR = bodyPartRecords.FirstOrFallback(); } else { myBPR = null; } if (HasBPSpecification && myBPR == null) { if (MyDebug) { Log.Warning("Cant find BPR with def: " + Props.bodyPartDef.defName + ", skipping"); } continue; } lifeStageHediff = HediffMaker.MakeHediff(association.hediff, Pawn, myBPR); if (lifeStageHediff == null) { if (MyDebug) { Log.Warning("hediff maker null"); } } Pawn.health.AddHediff(lifeStageHediff, myBPR, null); } } }