Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private bool CanHaveSnow(int ind)
        {
            Building building = this.map.edificeGrid[ind];

            if (building != null && !SnowGrid.CanCoexistWithSnow(building.def))
            {
                return(false);
            }
            TerrainDef terrainDef = this.map.terrainGrid.TerrainAt(ind);

            return(terrainDef == null || terrainDef.holdSnow);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }