public static Thing SpawnModded(Thing newThing, IntVec3 loc, Rot4 rot) { if (!loc.InBounds()) { Log.Error(string.Concat(new object[] { "Tried to spawn ", newThing, " out of bounds at ", loc, "." })); return(null); } GenSpawn.WipeExistingThings(loc, rot, newThing.def, false); if (newThing.def.randomizeRotationOnSpawn) { newThing.Rotation = Rot4.Random; } else { newThing.Rotation = rot; } newThing.SetPositionDirect(IntVec3.Invalid); newThing.Position = loc; newThing.SpawnSetup(); if (newThing.stackCount == 0) { Log.Error("Spawned thing with 0 stackCount: " + newThing); newThing.Destroy(DestroyMode.Vanish); return(null); } if (newThing.def.GetType() != typeof(Thingdef_AlienRace)) { return(newThing); } else { AlienPawn alienpawn2 = newThing as AlienPawn; alienpawn2.SpawnSetupAlien(alienpawn2); if (alienpawn2.TryGetComp <CompImmuneToAge>() != null) { alienpawn2.health.hediffSet.Clear(); PawnTechHediffsGenerator.GeneratePartsAndImplantsFor(alienpawn2); } Log.Message(alienpawn2.kindDef.race.ToString()); return(alienpawn2); } }
public static Pawn GeneratePawn(PawnGenerationRequest request) { Log.Message("Alien Pawn generated."); request.EnsureNonNullFaction(); Pawn pawn = null; if (!request.Newborn && !request.ForceGenerateNewPawn && Rand.Value < AlienPawnGenerator.ChanceToRedressAnyWorldPawn()) { IEnumerable <Pawn> enumerable = Find.WorldPawns.GetPawnsBySituation(WorldPawnSituation.Free); if (request.KindDef.factionLeader) { enumerable = enumerable.Concat(Find.WorldPawns.GetPawnsBySituation(WorldPawnSituation.FactionLeader)); } enumerable = from x in enumerable where AlienPawnGenerator.IsValidCandidateToRedress(x, request) select x; if (enumerable.TryRandomElementByWeight((Pawn x) => AlienPawnGenerator.WorldPawnSelectionWeight(x), out pawn)) { Verse.PawnGenerator.RedressPawn(pawn, request); Find.WorldPawns.RemovePawn(pawn); } } if (pawn == null) { pawn = AlienPawnGenerator.GenerateNewNakedPawn(ref request); if (pawn == null) { return(null); } if (!request.Newborn) { AlienPawnGenerator.GenerateGearFor(pawn, request); } } if (Find.Scenario != null) { Find.Scenario.Notify_PawnGenerated(pawn, request.Context); } if (pawn.kindDef.race.ToString().Contains("Alien_")) { AlienPawn alienpawn = new AlienPawn(); return(alienpawn); } else { return(pawn); } }
private static bool RaceRestricted(Pawn pawn, Apparel app) { bool flag = app.GetComp <CompRestritctedRace>() != null; bool result; if (flag) { CompRestritctedRace comp = app.GetComp <CompRestritctedRace>(); bool flag2 = comp.Props.RestrictedToRace != null; if (flag2) { bool flag3 = pawn.kindDef.race.ToString() == comp.Props.RestrictedToRace; if (flag3) { result = false; } else { bool flag4 = pawn.GetType() == typeof(AlienPawn); if (flag4) { AlienPawn alienPawn = pawn as AlienPawn; bool flag5 = alienPawn.kindDef.race.ToString() == comp.Props.RestrictedToRace; result = !flag5; } else { result = true; } } } else { result = false; } } else { result = false; } return(result); }
public void SpawnSetupAlien(AlienPawn newguy) { this.ReadXML(); if (backstoryflag) { UpdateBackstories(newguy, newguy.kindDef); } if (fTraits != null) { UpdateForcedTraits(newguy); } DoOnMainThread.ExecuteOnMainThread.Enqueue(() => { this.nakedGraphic = GraphicGetterAlienBody.GetNakedBodyGraphicAlien(this.story.BodyType, ShaderDatabase.CutoutSkin, alienskincolor, nakedbodytexpath, DrawSize); this.rottingGraphic = GraphicGetterAlienBody.GetNakedBodyGraphicAlien(this.story.BodyType, ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor, nakedbodytexpath, DrawSize); this.headGraphic = GraphicDatabase.Get <Graphic_Multi>(headtexpath, ShaderDatabase.Cutout, DrawSize, alienskincolor); this.desiccatedGraphic = GraphicDatabase.Get <Graphic_Multi>(dessicatedgraphicpath, ShaderDatabase.Cutout, DrawSize, Color.white); this.desiccatedHeadGraphic = GraphicDatabase.Get <Graphic_Multi>(headtexpath, ShaderDatabase.Cutout, DrawSize, PawnGraphicSet.RottingColor); this.skullGraphic = GraphicDatabase.Get <Graphic_Multi>(skullgraphicpath, ShaderDatabase.Cutout, DrawSize, Color.white); this.hairGraphic = GraphicDatabase.Get <Graphic_Multi>(TexPathHair, ShaderDatabase.Cutout, DrawSize, HColor); this.UpdateGraphics(); }); }
public static Thing SpawnModded(Thing newThing, IntVec3 loc, Map map, Rot4 rot) { bool flag = map == null; Thing result; if (flag) { Log.Error("Tried to spawn " + newThing + " in a null map."); result = null; } else { bool flag2 = !loc.InBounds(map); if (flag2) { Log.Error(string.Concat(new object[] { "Tried to spawn ", newThing, " out of bounds at ", loc, "." })); result = null; } else { bool spawned = newThing.Spawned; if (spawned) { Log.Error("Tried to spawn " + newThing + " but it's already spawned."); result = newThing; } else { GenSpawn.WipeExistingThings(loc, rot, newThing.def, map, DestroyMode.Vanish); bool randomizeRotationOnSpawn = newThing.def.randomizeRotationOnSpawn; if (randomizeRotationOnSpawn) { newThing.Rotation = Rot4.Random; } else { newThing.Rotation = rot; } newThing.Position = loc; ThingUtility.UpdateRegionListers(IntVec3.Invalid, loc, map, newThing); map.thingGrid.Register(newThing); newThing.SpawnSetup(map); bool spawned2 = newThing.Spawned; if (spawned2) { bool flag3 = newThing.stackCount == 0; if (flag3) { Log.Error("Spawned thing with 0 stackCount: " + newThing); newThing.Destroy(DestroyMode.Vanish); result = null; return(result); } } else { ThingUtility.UpdateRegionListers(loc, IntVec3.Invalid, map, newThing); map.thingGrid.Deregister(newThing, true); } bool flag4 = newThing.def.GetType() != typeof(Thingdef_AlienRace); if (flag4) { result = newThing; } else { AlienPawn alienPawn = newThing as AlienPawn; alienPawn.SpawnSetupAlien(); result = alienPawn; } } } } return(result); }
public static void DoRecruitAlien(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true) { string text = recruitee.LabelIndefinite(); if (recruitee.guest != null) { recruitee.guest.SetGuestStatus(null, false); } bool flag = recruitee.Name != null; if (recruitee.Faction != recruiter.Faction) { if (recruitee.kindDef.race.ToString().Contains("Alien")) { Log.Message("RecruitingAlienPawn"); var x = recruitee.kindDef; AlienPawn temprecruitee = recruitee as AlienPawn; temprecruitee.SetFaction(recruiter.Faction, recruiter); temprecruitee.kindDef = x; Log.Message("Pawn Converted to Kind: " + recruitee.kindDef.race.ToString()); } else { recruitee.SetFaction(recruiter.Faction, recruiter); } } if (recruitee.RaceProps.Humanlike) { if (useAudiovisualEffects) { Find.LetterStack.ReceiveLetter("LetterLabelMessageRecruitSuccess".Translate(), "MessageRecruitSuccess".Translate(new object[] { recruiter, recruitee, recruitChance.ToStringPercent() }), LetterType.Good, recruitee, null); } TaleRecorder.RecordTale(TaleDefOf.Recruited, new object[] { recruiter, recruitee }); recruiter.records.Increment(RecordDefOf.PrisonersRecruited); recruitee.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.RecruitedMe, recruiter); } else { if (useAudiovisualEffects) { if (!flag) { Messages.Message("MessageTameAndNameSuccess".Translate(new object[] { recruiter.LabelShort, text, recruitChance.ToStringPercent(), recruitee.Name.ToStringFull }).AdjustedFor(recruitee), recruitee, MessageSound.Benefit); } else { Messages.Message("MessageTameSuccess".Translate(new object[] { recruiter.LabelShort, text, recruitChance.ToStringPercent() }), recruitee, MessageSound.Benefit); } MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, "TextMote_TameSuccess".Translate(new object[] { recruitChance.ToStringPercent() }), 8f); } recruiter.records.Increment(RecordDefOf.AnimalsTamed); RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.05f); float num = Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness); if (Rand.Value < num) { TaleRecorder.RecordTale(TaleDefOf.TamedAnimal, new object[] { recruiter, recruitee }); } } if (recruitee.caller != null) { recruitee.caller.DoCall(); } }
public AlienPawn(Pawn pawn) { AlienPawn alienpawn = AlienRaceUtilities.ConvertTo <AlienPawn>(pawn); }
public AlienPawn(Thing thing) { AlienPawn alienpawn = AlienRaceUtilities.ConvertTo <AlienPawn>(thing); }
public override void SetFaction(Faction newFaction, Pawn recruiter = null) { var x = this.kindDef; AlienPawn temprecruitee = this as AlienPawn; if (newFaction == base.Faction) { Log.Warning(string.Concat(new object[] { "Used ChangePawnFactionTo to change ", this, " to same faction ", newFaction })); return; } if (this.guest != null) { this.guest.SetGuestStatus(null, false); } Find.MapPawns.DeRegisterPawn(this); Find.PawnDestinationManager.RemovePawnFromSystem(this); Find.DesignationManager.RemoveAllDesignationsOn(this, false); if (newFaction == Faction.OfPlayer || base.Faction == Faction.OfPlayer) { Find.ColonistBar.MarkColonistsListDirty(); } Lord lord = this.GetLord(); if (lord != null) { lord.Notify_PawnLost(this, PawnLostCondition.ChangedFaction); } base.SetFaction(newFaction, null); PawnComponentsUtility.AddAndRemoveDynamicComponents(this, false); if (base.Faction != null && base.Faction.IsPlayer) { if (this.workSettings != null) { this.workSettings.EnableAndInitialize(); } Find.Storyteller.intenderPopulation.Notify_PopulationGained(); } if (this.Drafted) { this.drafter.Drafted = false; } Reachability.ClearCache(); this.health.surgeryBills.Clear(); if (base.Spawned) { Find.MapPawns.RegisterPawn(this); } this.GenerateNecessaryName(); if (this.playerSettings != null) { this.playerSettings.medCare = ((!this.RaceProps.Humanlike) ? (this.playerSettings.medCare = MedicalCareCategory.NoMeds) : MedicalCareCategory.Best); } this.ClearMind(true); if (!this.Dead && this.needs.mood != null) { this.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty(); } Find.AttackTargetsCache.UpdateTarget(this); Find.GameEnder.CheckGameOver(); temprecruitee.kindDef = x; }
private void UpdateForcedTraits(AlienPawn apawn) { apawn.story.traits.allTraits.Clear(); GiveRandomTraits(apawn, true); }