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); }