public virtual void AddCell(IntVec3 c) { if (this.cells.Contains(c)) { Log.Error(string.Concat(new object[] { "Adding cell to zone which already has it. c=", c, ", zone=", this }), false); return; } List <Thing> list = this.Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (!thing.def.CanOverlapZones) { Log.Error("Added zone over zone-incompatible thing " + thing, false); return; } } this.cells.Add(c); this.zoneManager.AddZoneGridCell(this, c); this.Map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Zone); AutoHomeAreaMaker.Notify_ZoneCellAdded(c, this); this.cellsShuffled = false; }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (def.IsEdifice()) { map.edificeGrid.Register(this); if (def.Fillage == FillCategory.Full) { map.terrainGrid.Drawer.SetDirty(); } if (def.AffectsFertility) { map.fertilityGrid.Drawer.SetDirty(); } } base.SpawnSetup(map, respawningAfterLoad); base.Map.listerBuildings.Add(this); if (def.coversFloor) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Terrain, regenAdjacentCells: true, regenAdjacentSections: false); } CellRect cellRect = this.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { IntVec3 intVec = new IntVec3(j, 0, i); base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.Buildings); base.Map.glowGrid.MarkGlowGridDirty(intVec); if (!SnowGrid.CanCoexistWithSnow(def)) { base.Map.snowGrid.SetDepth(intVec, 0f); } } } if (base.Faction == Faction.OfPlayer && def.building != null && def.building.spawnedConceptLearnOpportunity != null) { LessonAutoActivator.TeachOpportunity(def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow); } AutoHomeAreaMaker.Notify_BuildingSpawned(this); if (def.building != null && !def.building.soundAmbient.NullOrUndefined()) { LongEventHandler.ExecuteWhenFinished(delegate { SoundInfo info = SoundInfo.InMap(this); sustainerAmbient = def.building.soundAmbient.TrySpawnSustainer(info); }); } base.Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); base.Map.listerArtificialBuildingsForMeditation.Notify_BuildingSpawned(this); base.Map.listerBuldingOfDefInProximity.Notify_BuildingSpawned(this); if (!this.CanBeSeenOver()) { base.Map.exitMapGrid.Notify_LOSBlockerSpawned(); } SmoothSurfaceDesignatorUtility.Notify_BuildingSpawned(this); map.avoidGrid.Notify_BuildingSpawned(this); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (this.def.IsEdifice()) { map.edificeGrid.Register(this); } base.SpawnSetup(map, respawningAfterLoad); base.Map.listerBuildings.Add(this); if (this.def.coversFloor) { base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Terrain, true, false); } CellRect cellRect = this.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { IntVec3 intVec = new IntVec3(j, 0, i); base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.Buildings); base.Map.glowGrid.MarkGlowGridDirty(intVec); if (!SnowGrid.CanCoexistWithSnow(this.def)) { base.Map.snowGrid.SetDepth(intVec, 0f); } } } if (base.Faction == Faction.OfPlayer && this.def.building != null && this.def.building.spawnedConceptLearnOpportunity != null) { LessonAutoActivator.TeachOpportunity(this.def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow); } AutoHomeAreaMaker.Notify_BuildingSpawned(this); if (this.def.building != null && !this.def.building.soundAmbient.NullOrUndefined()) { LongEventHandler.ExecuteWhenFinished(delegate { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None); this.sustainerAmbient = this.def.building.soundAmbient.TrySpawnSustainer(info); }); } base.Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); if (!this.CanBeSeenOver()) { base.Map.exitMapGrid.Notify_LOSBlockerSpawned(); } SmoothFloorDesignatorUtility.Notify_BuildingSpawned(this); }
public override void SetFaction(Faction newFaction, Pawn recruiter = null) { if (base.Spawned) { base.Map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this); base.Map.listerBuildings.Remove(this); } base.SetFaction(newFaction, recruiter); if (base.Spawned) { base.Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); base.Map.listerBuildings.Add(this); base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.PowerGrid, true, false); if (newFaction == Faction.OfPlayer) { AutoHomeAreaMaker.Notify_BuildingClaimed(this); } } }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { //Before base.SpawnSetup() so when regions are rebuilt this building can be accessed via edificeGrid if (def.IsEdifice()) { map.edificeGrid.Register(this); } base.SpawnSetup(map, respawningAfterLoad); Map.listerBuildings.Add(this); //Remake terrain meshes with new underwall under me if (def.coversFloor) { Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Terrain, true, false); } var occRect = this.OccupiedRect(); for (int z = occRect.minZ; z <= occRect.maxZ; z++) { for (int x = occRect.minX; x <= occRect.maxX; x++) { var c = new IntVec3(x, 0, z); Map.mapDrawer.MapMeshDirty(c, MapMeshFlag.Buildings); Map.glowGrid.MarkGlowGridDirty(c); if (!SnowGrid.CanCoexistWithSnow(def)) { Map.snowGrid.SetDepth(c, 0); } } } if (Faction == Faction.OfPlayer) { if (def.building != null && def.building.spawnedConceptLearnOpportunity != null) { LessonAutoActivator.TeachOpportunity(def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow); } } AutoHomeAreaMaker.Notify_BuildingSpawned(this); if (def.building != null && !def.building.soundAmbient.NullOrUndefined()) { LongEventHandler.ExecuteWhenFinished(() => { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None); sustainerAmbient = SoundStarter.TrySpawnSustainer(def.building.soundAmbient, info); }); } Map.listerBuildingsRepairable.Notify_BuildingSpawned(this); if (!this.CanBeSeenOver()) { Map.exitMapGrid.Notify_LOSBlockerSpawned(); } SmoothSurfaceDesignatorUtility.Notify_BuildingSpawned(this); //Must go after adding to buildings list map.avoidGrid.Notify_BuildingSpawned(this); }