public static Command SettleCommand(Caravan caravan)
        {
            Command_Settle command_Settle = new Command_Settle();

            command_Settle.defaultLabel = "CommandSettle".Translate();
            command_Settle.defaultDesc  = "CommandSettleDesc".Translate();
            command_Settle.icon         = SettleUtility.SettleCommandTex;
            command_Settle.action       = delegate
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                SettlementProximityGoodwillUtility.CheckConfirmSettle(caravan.Tile, delegate
                {
                    SettleInEmptyTileUtility.Settle(caravan);
                });
            };
            SettleInEmptyTileUtility.tmpSettleFailReason.Length = 0;
            if (!TileFinder.IsValidTileForNewSettlement(caravan.Tile, SettleInEmptyTileUtility.tmpSettleFailReason))
            {
                command_Settle.Disable(SettleInEmptyTileUtility.tmpSettleFailReason.ToString());
            }
            else if (SettleUtility.PlayerSettlementsCountLimitReached)
            {
                if (Prefs.MaxNumberOfPlayerSettlements > 1)
                {
                    command_Settle.Disable("CommandSettleFailReachedMaximumNumberOfBases".Translate());
                }
                else
                {
                    command_Settle.Disable("CommandSettleFailAlreadyHaveBase".Translate());
                }
            }
            return(command_Settle);
        }
        public static Command SettleCommand(Map map, bool requiresNoEnemies)
        {
            Command_Settle command_Settle = new Command_Settle();

            command_Settle.defaultLabel = "CommandSettle".Translate();
            command_Settle.defaultDesc  = "CommandSettleDesc".Translate();
            command_Settle.icon         = SettleUtility.SettleCommandTex;
            command_Settle.action       = delegate
            {
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
                SettlementProximityGoodwillUtility.CheckConfirmSettle(map.Tile, delegate
                {
                    Settle(map);
                });
            };
            if (SettleUtility.PlayerSettlementsCountLimitReached)
            {
                if (Prefs.MaxNumberOfPlayerSettlements > 1)
                {
                    command_Settle.Disable("CommandSettleFailReachedMaximumNumberOfBases".Translate());
                }
                else
                {
                    command_Settle.Disable("CommandSettleFailAlreadyHaveBase".Translate());
                }
            }
            if (!command_Settle.disabled)
            {
                if (map.mapPawns.FreeColonistsCount == 0)
                {
                    command_Settle.Disable("CommandSettleFailNoColonists".Translate());
                }
                else if (requiresNoEnemies)
                {
                    foreach (IAttackTarget item in map.attackTargetsCache.TargetsHostileToColony)
                    {
                        if (GenHostility.IsActiveThreatToPlayer(item))
                        {
                            command_Settle.Disable("CommandSettleFailEnemies".Translate());
                            return(command_Settle);
                        }
                    }
                    return(command_Settle);
                }
            }
            return(command_Settle);
        }
Beispiel #3
0
        public static Command ShipTouchdownCommand(LandedShip landedShip, bool settlePermanent = false)
        {
            string         comtitle       = settlePermanent ? "CommandSettle".Translate() : "CommandShipTouchdown".Translate();
            string         comdesc        = settlePermanent ? "CommandSettleDesc".Translate() : "CommandShipTouchdownDesc".Translate();
            Command_Settle command_Settle = new Command_Settle();

            command_Settle.defaultLabel = comtitle;
            command_Settle.defaultDesc  = comdesc;
            command_Settle.icon         = settlePermanent ? SettleUtility.SettleCommandTex : DropShipUtility.TouchDownCommandTex;
            command_Settle.action       = delegate
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
                TravelingShipsUtility.Settle(landedShip, settlePermanent);
            };
            bool flag = false;
            List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects;

            for (int i = 0; i < allWorldObjects.Count; i++)
            {
                WorldObject worldObject = allWorldObjects[i];
                if (worldObject.Tile == landedShip.Tile && worldObject != landedShip)
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                command_Settle.Disable("CommandSettleFailOtherWorldObjectsHere".Translate());
            }
            else if (settlePermanent && SettleUtility.PlayerHomesCountLimitReached)
            {
                if (Prefs.MaxNumberOfPlayerHomes > 1)
                {
                    command_Settle.Disable("CommandSettleFailReachedMaximumNumberOfBases".Translate());
                }
                else
                {
                    command_Settle.Disable("CommandSettleFailAlreadyHaveBase".Translate());
                }
            }
            return(command_Settle);
        }