Пример #1
0
        public static bool CreateAndDropSingleShip(Map map, Faction faction, ThingDef shipDef, List <Pawn> pawns, bool dropPawns, out ShipBase newShip)
        {
            List <ShipBase> ships = CreateDropShips(pawns, faction, new List <ThingDef> {
                shipDef
            });

            if (!ships.NullOrEmpty())
            {
                ShipBase    ship    = ships[0];
                List <Zone> runways = map.zoneManager.AllZones.FindAll(x => x is Zone_Runway);

                bool    wipeBuildings;
                bool    doesntFit;
                IntVec3 dropCell = IntVec3.Zero;
                Rot4?   rot      = ship.Rotation;
                foreach (var runway in runways)
                {
                    List <IntVec3> cells  = runway.Cells;
                    int            x      = cells.Min(c => c.x);
                    int            z      = cells.Min(c => c.z);
                    int            width  = cells.Max(c => c.x) - x;
                    int            height = cells.Max(c => c.z) - z;

                    CellRect rect = new CellRect(x, z, width, height);


                    dropCell = (RunwayUtility.FindShipDropPoint(map, rect, ship.def, ref rot, out wipeBuildings, out doesntFit));
                    if (doesntFit == true)
                    {
                        newShip = null;
                        return(false);
                    }
                    if (wipeBuildings == true)
                    {
                        Messages.Message("LandingZoneBlocked".Translate(), MessageTypeDefOf.RejectInput);
                        newShip = null;
                        return(false);
                    }
                }
                newShip = ship;
                DropShipUtility.DropSingleShip(map, dropCell, ship, ShipArrivalAction.EnterMapFriendly, dropPawns);
                return(true);
            }
            newShip = null;
            return(false);
        }