Ejemplo n.º 1
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            if (this.transporters == null)
            {
                this.transporters = new List <CompTransporter>();
            }
            if (!this.transporters.Contains(this.transComp))
            {
                this.transporters.Add(this.transComp);
            }
            CompLaunchable launchable = this.transComp.Launchable;

            if (launchable != null)
            {
                Building fuelingPortSource = launchable.FuelingPortSource;
                if (fuelingPortSource != null)
                {
                    Map map = this.transComp.Map;
                    tmpFuelingPortGivers.Clear();
                    map.floodFiller.FloodFill(fuelingPortSource.Position, (IntVec3 x) => FuelingPortUtility.AnyFuelingPortGiverAt(x, map), delegate(IntVec3 x)
                    {
                        tmpFuelingPortGivers.Add(FuelingPortUtility.FuelingPortGiverAt(x, map));
                    }, int.MaxValue, false, null);
                    for (int i = 0; i < this.transporters.Count; i++)
                    {
                        Building fuelingPortSource2 = this.transporters[i].Launchable.FuelingPortSource;
                        if (fuelingPortSource2 != null && !tmpFuelingPortGivers.Contains(fuelingPortSource2))
                        {
                            Messages.Message("MessageTransportersNotAdjacent".Translate(), fuelingPortSource2, MessageTypeDefOf.RejectInput, false);
                            return;
                        }
                    }
                }
            }
            for (int j = 0; j < this.transporters.Count; j++)
            {
                if (this.transporters[j] != this.transComp)
                {
                    if (!this.transComp.Map.reachability.CanReach(this.transComp.parent.Position, this.transporters[j].parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors, Danger.Deadly, false)))
                    {
                        Messages.Message("MessageTransporterUnreachable".Translate(), this.transporters[j].parent, MessageTypeDefOf.RejectInput, false);
                        return;
                    }
                }
            }
            Find.WindowStack.Add(new Dialog_ReloadTransporters(this.transComp.Map, this.transporters));
        }
Ejemplo n.º 2
0
        public override void DeSpawn()
        {
            Map map = base.Map;

            base.DeSpawn();
            if (this.def.IsEdifice())
            {
                map.edificeGrid.DeRegister(this);
            }
            if (this.def.MakeFog)
            {
                map.fogGrid.Notify_FogBlockerRemoved(base.Position);
            }
            if (this.def.holdsRoof)
            {
                RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map);
            }
            if (this.sustainerAmbient != null)
            {
                this.sustainerAmbient.End();
            }
            CellRect cellRect = this.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3     loc         = new IntVec3(j, 0, i);
                    MapMeshFlag mapMeshFlag = MapMeshFlag.Buildings;
                    if (this.def.coversFloor)
                    {
                        mapMeshFlag |= MapMeshFlag.Terrain;
                    }
                    if (this.def.Fillage == FillCategory.Full)
                    {
                        mapMeshFlag |= MapMeshFlag.Roofs;
                        mapMeshFlag |= MapMeshFlag.Snow;
                    }
                    map.mapDrawer.MapMeshDirty(loc, mapMeshFlag);
                    map.glowGrid.MarkGlowGridDirty(loc);
                }
            }
            map.listerBuildings.Remove(this);
            map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this);
            if (this.def.leaveTerrain != null && Current.ProgramState == ProgramState.Playing)
            {
                CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator();
                while (!iterator.Done())
                {
                    map.terrainGrid.SetTerrain(iterator.Current, this.def.leaveTerrain);
                    iterator.MoveNext();
                }
            }
            map.designationManager.Notify_BuildingDespawned(this);
            if (!this.CanBeSeenOver())
            {
                map.exitMapGrid.Notify_LOSBlockerDespawned();
            }
            if (this.def.building.hasFuelingPort)
            {
                IntVec3        fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation);
                CompLaunchable compLaunchable  = FuelingPortUtility.LaunchableAt(fuelingPortCell, map);
                if (compLaunchable != null)
                {
                    compLaunchable.Notify_FuelingPortSourceDeSpawned();
                }
            }
            if (this.def.building.ai_combatDangerous)
            {
                AvoidGridMaker.Notify_CombatDangerousBuildingDespawned(this, map);
            }
        }
Ejemplo n.º 3
0
        public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
        {
            Map map = base.Map;

            base.DeSpawn(mode);
            if (def.IsEdifice())
            {
                map.edificeGrid.DeRegister(this);
                if (def.Fillage == FillCategory.Full)
                {
                    map.terrainGrid.Drawer.SetDirty();
                }
                if (def.AffectsFertility)
                {
                    map.fertilityGrid.Drawer.SetDirty();
                }
            }
            if (mode != DestroyMode.WillReplace)
            {
                if (def.MakeFog)
                {
                    map.fogGrid.Notify_FogBlockerRemoved(base.Position);
                }
                if (def.holdsRoof)
                {
                    RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map);
                }
                if (def.IsSmoothable)
                {
                    SmoothSurfaceDesignatorUtility.Notify_BuildingDespawned(this, map);
                }
            }
            if (sustainerAmbient != null)
            {
                sustainerAmbient.End();
            }
            CellRect cellRect = this.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3     loc         = new IntVec3(j, 0, i);
                    MapMeshFlag mapMeshFlag = MapMeshFlag.Buildings;
                    if (def.coversFloor)
                    {
                        mapMeshFlag |= MapMeshFlag.Terrain;
                    }
                    if (def.Fillage == FillCategory.Full)
                    {
                        mapMeshFlag |= MapMeshFlag.Roofs;
                        mapMeshFlag |= MapMeshFlag.Snow;
                    }
                    map.mapDrawer.MapMeshDirty(loc, mapMeshFlag);
                    map.glowGrid.MarkGlowGridDirty(loc);
                }
            }
            map.listerBuildings.Remove(this);
            map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this);
            map.listerArtificialBuildingsForMeditation.Notify_BuildingDeSpawned(this);
            if (def.building.leaveTerrain != null && Current.ProgramState == ProgramState.Playing && canChangeTerrainOnDestroyed)
            {
                foreach (IntVec3 item in this.OccupiedRect())
                {
                    map.terrainGrid.SetTerrain(item, def.building.leaveTerrain);
                }
            }
            map.designationManager.Notify_BuildingDespawned(this);
            if (!this.CanBeSeenOver())
            {
                map.exitMapGrid.Notify_LOSBlockerDespawned();
            }
            if (def.building.hasFuelingPort)
            {
                FuelingPortUtility.LaunchableAt(FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation), map)?.Notify_FuelingPortSourceDeSpawned();
            }
            map.avoidGrid.Notify_BuildingDespawned(this);
        }
Ejemplo n.º 4
0
        public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
        {
            var map = Map;     // before DeSpawn!

            base.DeSpawn(mode);

            if (def.IsEdifice())
            {
                map.edificeGrid.DeRegister(this);
            }

            if (mode != DestroyMode.WillReplace)
            {
                if (def.MakeFog)
                {
                    map.fogGrid.Notify_FogBlockerRemoved(Position);
                }

                if (def.holdsRoof)
                {
                    RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map);
                }

                if (def.IsSmoothable)
                {
                    SmoothSurfaceDesignatorUtility.Notify_BuildingDespawned(this, map);
                }
            }

            if (sustainerAmbient != null)
            {
                sustainerAmbient.End();
            }

            CellRect occRect = GenAdj.OccupiedRect(this);

            for (int z = occRect.minZ; z <= occRect.maxZ; z++)
            {
                for (int x = occRect.minX; x <= occRect.maxX; x++)
                {
                    IntVec3 c = new IntVec3(x, 0, z);

                    MapMeshFlag changeType = MapMeshFlag.Buildings;

                    if (def.coversFloor)
                    {
                        changeType |= MapMeshFlag.Terrain;
                    }

                    if (def.Fillage == FillCategory.Full)
                    {
                        changeType |= MapMeshFlag.Roofs;
                        changeType |= MapMeshFlag.Snow;
                    }

                    map.mapDrawer.MapMeshDirty(c, changeType);

                    map.glowGrid.MarkGlowGridDirty(c);
                }
            }

            map.listerBuildings.Remove(this);
            map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this);

            if (def.building.leaveTerrain != null && Current.ProgramState == ProgramState.Playing && canChangeTerrainOnDestroyed)
            {
                for (var cri = GenAdj.OccupiedRect(this).GetIterator(); !cri.Done(); cri.MoveNext())
                {
                    map.terrainGrid.SetTerrain(cri.Current, def.building.leaveTerrain);
                }
            }

            //Mining, planning, etc
            map.designationManager.Notify_BuildingDespawned(this);

            if (!this.CanBeSeenOver())
            {
                map.exitMapGrid.Notify_LOSBlockerDespawned();
            }

            if (def.building.hasFuelingPort)
            {
                var fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(Position, Rotation);
                var launchable      = FuelingPortUtility.LaunchableAt(fuelingPortCell, map);

                if (launchable != null)
                {
                    launchable.Notify_FuelingPortSourceDeSpawned();
                }
            }

            //Must go after removing from buildings list
            map.avoidGrid.Notify_BuildingDespawned(this);
        }