internal void _SpawnSetup() { if (this.Destroyed) { Log.Error(string.Concat(new object[] { "Spawning destroyed thing ", this, " at ", this.Position, ". Correcting." })); SetThingStateInt(this, ThingState.Unspawned); if (this.HitPoints <= 0 && this.def.useHitPoints) { this.HitPoints = 1; } } if (this.Spawned) { Log.Error(string.Concat(new object[] { "Tried to spawn already-spawned thing ", this, " at ", this.Position })); return; } this.holder = null; SetThingStateInt(this, ThingState.Spawned); Find.Map.listerThings.Add(this); if (Find.TickManager != null) { Find.TickManager.RegisterAllTickabilityFor(this); } if (this.def.drawerType != DrawerType.RealtimeOnly) { CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator(); while (!iterator.Done()) { Find.Map.mapDrawer.MapMeshDirty(iterator.Current, MapMeshFlag.Things); iterator.MoveNext(); } } if (this.def.drawerType != DrawerType.MapMeshOnly) { Find.DynamicDrawManager.RegisterDrawable(this); } if (this.def.hasTooltip) { Find.TooltipGiverList.RegisterTooltipGiver(this); } if (this.def.graphicData != null && this.def.graphicData.Linked) { LinkGrid.Notify_LinkerCreatedOrDestroyed(this); Find.MapDrawer.MapMeshDirty(this.Position, MapMeshFlag.Things, true, false); } if (!this.def.CanOverlapZones) { rNotify_NoZoneOverlapThingSpawned(this); } if (this.def.regionBarrier) { rNotify_BarrierSpawned(this); } if (this.def.pathCost != 0 || this.def.passability == Traversability.Impassable) { Find.PathGrid.RecalculatePerceivedPathCostUnderThing(this); } if (this.def.passability == Traversability.Impassable) { Reachability.ClearCache(); } Find.CoverGrid.Register(this); if (this.def.category == ThingCategory.Item) { ListerHaulables.Notify_Spawned(this); } Find.AttackTargetsCache.Notify_ThingSpawned(this); Region validRegionAt_NoRebuild = Find.RegionGrid.GetValidRegionAt_NoRebuild(this.Position); Room room = (validRegionAt_NoRebuild != null) ? validRegionAt_NoRebuild.Room : null; if (room != null) { room.Notify_ContainedThingSpawnedOrDespawned(this); } if (this.def.category == ThingCategory.Item) { Building_Door building_Door = this.Position.GetEdifice() as Building_Door; if (building_Door != null) { building_Door.Notify_ItemSpawnedOrDespawnedOnTop(this); } } StealAIDebugDrawer.Notify_ThingChanged(this); }
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; }