Ejemplo n.º 1
0
        private void SpawnShipsInMap(Map map, string extraMessagePart = null)
        {
            this.RemoveAllPawnsFromWorldPawns();
            IntVec3 intVec;

            if (this.destinationCell.IsValid && this.destinationCell.InBounds(map))
            {
                intVec = this.destinationCell;
            }
            else if (this.arriveMode == PawnsArrivalModeDefOf.CenterDrop)
            {
                intVec = DropCellFinder.FindRaidDropCenterDistant(map);
            }
            else
            {
                if (this.arriveMode != PawnsArrivalModeDefOf.EdgeDrop)
                {
                    Log.Warning("Unsupported arrive mode " + this.arriveMode);
                }
                Log.Message("Invalid Cell");
                intVec = DropCellFinder.FindRaidDropCenterDistant(map);
            }

            string text = "MessageShipsArrived".Translate();

            if (extraMessagePart != null)
            {
                text = text + " " + extraMessagePart;
            }
            DropShipUtility.DropShipGroups(intVec, map, this.ships, this.arrivalAction, this.isSingularShip);
            Messages.Message(text, new TargetInfo(intVec, map, false), MessageTypeDefOf.NeutralEvent);
            this.RemoveAllShip();
            Find.WorldObjects.Remove(this);
        }
        public static void Enter(LandedShip caravan, Map map, Func <ShipBase, IntVec3> spawnCellGetter)
        {
            List <ShipBase> ships = caravan.ships;

            DropShipUtility.DropShipGroups(TravelingShipsUtility.CenterCell(map), map, ships, ShipArrivalAction.EnterMapFriendly);
            //caravan.RemoveAllPawns();
            if (caravan.Spawned)
            {
                Find.WorldObjects.Remove(caravan);
            }
        }
Ejemplo n.º 3
0
        private static void Enter(WorldShip worldShip, Map map, IntVec3 targetCell, ShipArrivalAction arrivalAction, PawnsArrivalModeDef pawnsArrivalMode)
        {
            List <ShipBase> ships = worldShip.WorldShipData.Select(x => x.Ship).ToList();
            IntVec3         cell  = GetCellForArrivalMode(worldShip.WorldShipData[0].Ship, targetCell, map, pawnsArrivalMode);

            DropShipUtility.DropShipGroups(cell, map, ships, arrivalAction, worldShip.WorldShipData.Count == 1);
            if (worldShip.Spawned)
            {
                Find.WorldObjects.Remove(worldShip);
            }
        }
Ejemplo n.º 4
0
 public override void GenerateIntoMap(Map map)
 {
     if (Find.TickManager.TicksGame < 1000)
     {
         ShipBase newShip = (ShipBase)ThingMaker.MakeThing(this.ShipDef);
         newShip.SetFaction(Faction.OfPlayer);
         Thing initialFuel = ThingMaker.MakeThing(ShipNamespaceDefOfs.Chemfuel);
         newShip.refuelableComp.Refuel(500);
         this.StartingShips.Add(newShip);
         DropShipUtility.LoadNewCargoIntoRandomShips(this.PlayerStartingThings().ToList(), this.StartingShips);
         DropShipUtility.DropShipGroups(map.Center, map, this.StartingShips, ShipArrivalAction.EnterMapFriendly);
     }
 }
Ejemplo n.º 5
0
        public static void Enter(LandedShip caravan, Map map)
        {
            List <ShipBase> ships               = caravan.ships;
            IntVec3         randomEdgeCell      = CellFinder.RandomEdgeCell(map);
            IntVec3         randomSpawnEdgeCell = new IntVec3();

            DropShipUtility.TryFindShipDropLocationNear(randomEdgeCell, 100, map, out randomSpawnEdgeCell, new IntVec2(4, 4));
            DropShipUtility.DropShipGroups(randomSpawnEdgeCell, map, ships, TravelingShipArrivalAction.EnterMapFriendly);
            if (caravan.Spawned)
            {
                Find.WorldObjects.Remove(caravan);
            }
        }
        public static void Enter(List <ShipBase> ships, Map map, bool centerDrop = true)
        {
            IntVec3 loc;

            if (centerDrop)
            {
                loc = TravelingShipsUtility.CenterCell(map);
            }
            else
            {
                loc = DropCellFinder.FindRaidDropCenterDistant(map);
            }
            DropShipUtility.DropShipGroups(loc, map, ships, ShipArrivalAction.EnterMapFriendly);
        }
Ejemplo n.º 7
0
        public static void Enter(List <ShipBase> ships, Map map, bool centerDrop = true)
        {
            foreach (ShipBase ship in ships)
            {
                DropShipUtility.ReimbarkWorldPawnsForLandedShip(ship);
            }
            IntVec3 loc;

            if (centerDrop)
            {
                loc = TravelingShipsUtility.CenterCell(map);
            }
            else
            {
                loc = DropCellFinder.FindRaidDropCenterDistant(map);
            }
            DropShipUtility.DropShipGroups(loc, map, ships, TravelingShipArrivalAction.EnterMapFriendly);
        }
Ejemplo n.º 8
0
        private void SpawnShipsInMap(Map map, string extraMessagePart = null)
        {
            this.RemoveAllPawnsFromWorldPawns();
            IntVec3 intVec;

            Log.Message("Dest: " + this.destinationCell.ToString());
            if (this.destinationCell.IsValid && this.destinationCell.InBounds(map))
            {
                intVec = this.destinationCell;
            }
            else if (this.arriveMode == PawnsArriveMode.CenterDrop)
            {
                if (!DropCellFinder.TryFindRaidDropCenterClose(out intVec, map))
                {
                    intVec = DropCellFinder.FindRaidDropCenterDistant(map);
                }
            }
            else
            {
                if (this.arriveMode != PawnsArriveMode.EdgeDrop && this.arriveMode != PawnsArriveMode.Undecided)
                {
                    Log.Warning("Unsupported arrive mode " + this.arriveMode);
                }
                Log.Message("Invalid Cell");
                intVec = DropCellFinder.FindRaidDropCenterDistant(map);
            }

            string text = "MessageShipsArrived".Translate();

            if (extraMessagePart != null)
            {
                text = text + " " + extraMessagePart;
            }
            Log.Message("Dest2: " + intVec.ToString());
            DropShipUtility.DropShipGroups(intVec, map, this.ships, this.arrivalAction, this.isSingularShip);
            Messages.Message(text, new TargetInfo(intVec, map, false), MessageSound.Benefit);
            this.RemoveAllPods();
            Find.WorldObjects.Remove(this);
        }
Ejemplo n.º 9
0
        public override bool TryExecute(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            this.ResolveRaidPoints(parms);
            if (!this.TryResolveRaidFaction(parms))
            {
                return(false);
            }
            this.ResolveRaidStrategy(parms);
            this.ResolveRaidArriveMode(parms);
            this.ResolveRaidSpawnCenter(parms);
            IncidentParmsUtility.AdjustPointsForGroupArrivalParams(parms);
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms);
            List <Pawn>         list = PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList <Pawn>();

            if (list.Count == 0)
            {
                Log.Error("Got no pawns spawning raid from parms " + parms);
                return(false);
            }
            TargetInfo      target = TargetInfo.Invalid;
            List <ShipBase> ships  = DropShipUtility.CreateDropShips(list, parms.faction);

            DropShipUtility.DropShipGroups(parms.spawnCenter, map, ships, TravelingShipArrivalAction.EnterMapAssault);

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Points = " + parms.points.ToString("F0"));
            foreach (Pawn current2 in list)
            {
                string str = (current2.equipment == null || current2.equipment.Primary == null) ? "unarmed" : current2.equipment.Primary.LabelCap;
                stringBuilder.AppendLine(current2.KindLabel + " - " + str);
            }
            string letterLabel = this.GetLetterLabel(parms);
            string letterText  = this.GetLetterText(parms, list);

            PawnRelationUtility.Notify_PawnsSeenByPlayer(list, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true);
            Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterType(), target, stringBuilder.ToString());
            if (this.GetLetterType() == LetterType.BadUrgent)
            {
                TaleRecorder.RecordTale(TaleDefOf.RaidArrived, new object[0]);
            }
            this.ResolveRaidParmOptions(parms);
            Lord lord = LordMaker.MakeNewLord(parms.faction, new LordJob_AerialAssault(ships, parms.faction, this.Kidnappers(parms.faction), true, this.UseSappers, this.SmartGrid, this.Stealers(parms.faction)), map, list);

            AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
            if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.PersonalShields))
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Pawn pawn = list[i];
                    if (pawn.apparel.WornApparel.Any((Apparel ap) => ap is PersonalShield))
                    {
                        LessonAutoActivator.TeachOpportunity(ConceptDefOf.PersonalShields, OpportunityType.Critical);
                        break;
                    }
                }
            }
            if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer))
            {
                Log.Message(string.Concat(new object[]
                {
                    "Market value threshold to start stealing: ",
                    StealAIUtility.StartStealingMarketValueThreshold(lord),
                    " (colony wealth = ",
                    map.wealthWatcher.WealthTotal,
                    ")"
                }));
            }
            return(true);
        }