public void SetPlace(CaravanAI caravanAI, Caravan playerCaravan, IntVec3 mapSize)
        {
            MapSize = mapSize;

            this.caravanAI = caravanAI;
            aiFaction      = caravanAI.Faction;
            aiTarget       = caravanAI.pather.Destination;
            aiAction       = caravanAI.pather.ArrivalAction;

            this.playerCaravan = playerCaravan;
            List <Pawn> aiPawns = new List <Pawn>(caravanAI.pawns);

            caravanAI.Tile     = Tile;
            playerCaravan.Tile = Tile;

            Map map = GetOrGenerateMap(Tile, MapSize, null);

            Find.TickManager.Notify_GeneratedPotentiallyHostileMap();

            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out IntVec3 first, out IntVec3 second);

            CaravanEnterMapUtility.Enter(caravanAI, map, x => CellFinder.RandomSpawnCellForPawnNear(first, map), CaravanDropInventoryMode.DoNotDrop);
            CaravanEnterMapUtility.Enter(playerCaravan, map, x => CellFinder.RandomSpawnCellForPawnNear(second, map), CaravanDropInventoryMode.DoNotDrop);

            LordJob lordJob = new LordJob_AssaultColony(caravanAI.Faction, canKidnap: true, canTimeoutOrFlee: false);

            LordMaker.MakeNewLord(caravanAI.Faction, lordJob, map, aiPawns);

            winner = CaravanBattleWinner.None;

            Find.LetterStack.ReceiveLetter("CaravanBattlePlacePlace_BattleStarted".Translate(), "CaravanBattlePlacePlace_BattleDescription".Translate(playerCaravan.Name, caravanAI.Name), LetterDefOf.ThreatBig);
        }
 public virtual FloatMenuAcceptanceReport CanAttack(Caravan caravan, CaravanAI caravanAI)
 {
     if (caravanAI == null || !caravanAI.Spawned)
     {
         return(false);
     }
     return(true);
 }
Beispiel #3
0
        public static CaravanAI MakeCaravan(IEnumerable <Pawn> pawns, Faction faction, int startingTile, bool addToWorldPawnsIfNotAlready, Color color, bool showNeeds = false, bool showSocial = false, bool useFood = false, bool showItems = false)
        {
            if (startingTile < 0 && addToWorldPawnsIfNotAlready)
            {
                Log.Warning("Tried to create a caravan but chose not to spawn a caravan but pass pawns to world. This can cause bugs because pawns can be discarded.");
            }
            tmpPawns.Clear();
            tmpPawns.AddRange(pawns);
            CaravanAI caravan = (CaravanAI)WorldObjectMaker.MakeWorldObject(MoreEvents.Events.WorldObjectsDefOfLocal.CaravanAI);

            if (startingTile >= 0)
            {
                caravan.Tile = startingTile;
            }
            caravan.SetFaction(faction);
            if (startingTile >= 0)
            {
                Find.WorldObjects.Add(caravan);
            }
            for (int i = 0; i < tmpPawns.Count; i++)
            {
                Pawn pawn = tmpPawns[i];
                if (pawn.Dead)
                {
                    Log.Warning("Tried to form a caravan with a dead pawn " + pawn);
                    continue;
                }

                caravan.AddPawn(pawn, addToWorldPawnsIfNotAlready);
                if (addToWorldPawnsIfNotAlready && !pawn.IsWorldPawn())
                {
                    Find.WorldPawns.PassToWorld(pawn);
                }
            }
            caravan.Name = CaravanNameGenerator.GenerateCaravanName(caravan);
            tmpPawns.Clear();
            caravan.SetUniqueId(Find.UniqueIDsManager.GetNextCaravanID());

            caravan.ShowSocial = showSocial;
            caravan.ShowNeeds  = showNeeds;
            caravan.UseFood    = useFood;
            caravan.ShowItems  = showItems;

            caravan.CaravanColor = color;

            return(caravan);
        }
 public CaravanArrivalAction_AttackCaravanAI(CaravanAI caravan)
 {
     attackedCaravan = caravan;
 }
 public CaravanBattlePlacePlace(CaravanAI caravanAI, Caravan playerCaravan, IntVec3 mapSize)
 {
     this.caravanAI     = caravanAI;
     this.playerCaravan = playerCaravan;
     MapSize            = mapSize;
 }