public static void DropInDropPodsNearSpawnCenter(IncidentParms parms, List <Pawn> pawns)
        {
            Map  map  = (Map)parms.target;
            bool flag = parms.faction != null && parms.faction.HostileTo(Faction.OfPlayer);

            DropPodUtility.DropThingsNear(parms.spawnCenter, map, pawns.Cast <Thing>(), parms.podOpenDelay, canInstaDropDuringInit: false, leaveSlag: true, flag || parms.raidArrivalModeForQuickMilitaryAid);
        }
Ejemplo n.º 2
0
 public override void GenerateIntoMap(Map map)
 {
     if (Find.GameInitData != null)
     {
         List <List <Thing> > list = new List <List <Thing> >();
         foreach (Pawn startingAndOptionalPawn in Find.GameInitData.startingAndOptionalPawns)
         {
             List <Thing> list2 = new List <Thing>();
             list2.Add(startingAndOptionalPawn);
             list.Add(list2);
         }
         List <Thing> list3 = new List <Thing>();
         foreach (ScenPart allPart in Find.Scenario.AllParts)
         {
             list3.AddRange(allPart.PlayerStartingThings());
         }
         int num = 0;
         foreach (Thing item in list3)
         {
             if (item.def.CanHaveFaction)
             {
                 item.SetFactionDirect(Faction.OfPlayer);
             }
             list[num].Add(item);
             num++;
             if (num >= list.Count)
             {
                 num = 0;
             }
         }
         DropPodUtility.DropThingGroupsNear_NewTmp(MapGenerator.PlayerStartSpot, map, list, 110, Find.GameInitData.QuickStarted || method != PlayerPawnsArriveMethod.DropPods, leaveSlag: true, canRoofPunch: true, forbid: true, allowFogged: false);
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = ThingUtility.FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            TaggedString title = "LetterLabelRefugeePodCrash".Translate();
            TaggedString text  = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);
            SendStandardLetter(title, text, LetterDefOf.NeutralEvent, parms, new TargetInfo(intVec, map));
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
        public override void Notify_QuestSignalReceived(Signal signal)
        {
            base.Notify_QuestSignalReceived(signal);
            if (!(signal.tag == inSignal))
            {
                return;
            }
            copy = null;
            MonumentMarker arg = signal.args.GetArg <MonumentMarker>("SUBJECT");

            if (arg != null && mapParent != null && mapParent.HasMap)
            {
                Map     map        = mapParent.Map;
                IntVec3 dropCenter = DropCellFinder.RandomDropSpot(map);
                copy        = (MonumentMarker)ThingMaker.MakeThing(ThingDefOf.MonumentMarker);
                copy.sketch = arg.sketch.DeepCopy();
                if (!arg.questTags.NullOrEmpty())
                {
                    copy.questTags = new List <string>();
                    copy.questTags.AddRange(arg.questTags);
                }
                DropPodUtility.DropThingsNear(dropCenter, map, Gen.YieldSingle((Thing)copy.MakeMinified()), 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: true, forbid: false);
            }
            if (!outSignalResult.NullOrEmpty())
            {
                if (copy != null)
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult, copy.Named("SUBJECT")));
                }
                else
                {
                    Find.SignalManager.SendSignal(new Signal(outSignalResult));
                }
            }
        }
 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true, bool explode = false)
 {
     foreach (List <Thing> thingsGroup in thingsGroups)
     {
         IntVec3 intVec = default(IntVec3);
         if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch))
         {
             Log.Warning("DropThingsNear failed to find a place to drop " + thingsGroup.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead.");
             intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000);
         }
         for (int i = 0; i < thingsGroup.Count; i++)
         {
             thingsGroup[i].SetForbidden(true, false);
         }
         if (instaDrop)
         {
             foreach (Thing item in thingsGroup)
             {
                 GenPlace.TryPlaceThing(item, intVec, map, ThingPlaceMode.Near, null);
             }
         }
         else
         {
             ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
             foreach (Thing item2 in thingsGroup)
             {
                 activeDropPodInfo.innerContainer.TryAdd(item2, true);
             }
             activeDropPodInfo.openDelay = openDelay;
             activeDropPodInfo.leaveSlag = leaveSlag;
             DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, explode);
         }
     }
 }
        // Token: 0x06000EB1 RID: 3761 RVA: 0x0006D5F4 File Offset: 0x0006B9F4
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            pawn.health.AddHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation);
            string label = "LetterLabelRefugeePodCrash".Translate();
            string text  = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <TargetInfo> list        = new List <TargetInfo>();
            ThingDef          shipPartDef = def.mechClusterBuilding;
            IntVec3           intVec      = FindDropPodLocation(map, (IntVec3 spot) => CanPlaceAt(spot));

            if (intVec == IntVec3.Invalid)
            {
                return(false);
            }
            float       points = Mathf.Max(parms.points * 0.9f, 300f);
            List <Pawn> list2  = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = Faction.OfMechanoids,
                points    = points
            }).ToList();
            Thing thing = ThingMaker.MakeThing(shipPartDef);

            thing.SetFaction(Faction.OfMechanoids);
            LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                thing
            }, Faction.OfMechanoids, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2);
            DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>());
            foreach (Pawn item in list2)
            {
                item.TryGetComp <CompCanBeDormant>()?.ToSleep();
            }
            list.AddRange(list2.Select((Pawn p) => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map);
            list.Add(new TargetInfo(intVec, map));
            SendStandardLetter(parms, list);
            return(true);

            bool CanPlaceAt(IntVec3 loc)
            {
                CellRect cellRect = GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size);

                if (loc.Fogged(map) || !cellRect.InBounds(map))
                {
                    return(false);
                }
                if (!DropCellFinder.SkyfallerCanLandAt(loc, map, shipPartDef.Size))
                {
                    return(false);
                }
                foreach (IntVec3 item2 in cellRect)
                {
                    RoofDef roof = item2.GetRoof(map);
                    if (roof != null && roof.isNatural)
                    {
                        return(false);
                    }
                }
                return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North));
            }
        }
Ejemplo n.º 8
0
 public static void SpawnDropPod(IntVec3 dropSpot, Map map, Thing t)
 {
     DropPodUtility.MakeDropPodAt(dropSpot, map, new ActiveDropPodInfo
     {
         SingleContainedThing = t,
         leaveSlag            = false
     }, false);
 }
Ejemplo n.º 9
0
        public static void SpawnDropPod(IntVec3 dropSpot, Map map, Thing t)
        {
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.SingleContainedThing = t;
            activeDropPodInfo.leaveSlag            = false;
            DropPodUtility.MakeDropPodAt(dropSpot, map, activeDropPodInfo);
        }
Ejemplo n.º 10
0
        private void DropSupplies(ThingDef thingDef, int count)
        {
            List <Thing> list  = new List <Thing>();
            Thing        thing = ThingMaker.MakeThing(thingDef, null);

            thing.stackCount = count;
            list.Add(thing);
            DropPodUtility.DropThingsNear(this.Data.siegeCenter, base.Map, list, 110, false, false, true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.ResourcePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, things, 110, canInstaDropDuringInit: false, leaveSlag: true);
            SendStandardLetter("LetterLabelCargoPodCrash".Translate(), "CargoPodCrash".Translate(), LetterDefOf.PositiveEvent, parms, new TargetInfo(intVec, map));
            return(true);
        }
Ejemplo n.º 12
0
        public override void Arrive(List <Pawn> pawns, IncidentParms parms)
        {
            Map  map          = (Map)parms.target;
            bool canRoofPunch = parms.faction != null && parms.faction.HostileTo(Faction.OfPlayer);

            for (int i = 0; i < pawns.Count; i++)
            {
                DropPodUtility.DropThingsNear(DropCellFinder.RandomDropSpot(map), map, Gen.YieldSingle((Thing)pawns[i]), parms.podOpenDelay, canInstaDropDuringInit: false, leaveSlag: true, canRoofPunch);
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ItemCollectionGeneratorDefOf.ResourcePod.Worker.Generate(default(ItemCollectionGeneratorParams));
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, things, 110, false, true, true, true);
            Find.LetterStack.ReceiveLetter("LetterLabelCargoPodCrash".Translate(), "CargoPodCrash".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);
            return(true);
        }
Ejemplo n.º 14
0
        public override void Arrive(List <Pawn> pawns, IncidentParms parms)
        {
            Map map = (Map)parms.target;

            for (int i = 0; i < pawns.Count; i++)
            {
                IntVec3 dropCenter = DropCellFinder.RandomDropSpot(map);
                DropPodUtility.DropThingsNear(dropCenter, map, Gen.YieldSingle((Thing)pawns[i]), parms.podOpenDelay, canInstaDropDuringInit: false, leaveSlag: true);
            }
        }
Ejemplo n.º 15
0
        public override void SpawnJoiner(Map map, Pawn pawn)
        {
            IntVec3           c = DropCellFinder.RandomDropSpot(map);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddOrTransfer(pawn);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(c, map, activeDropPodInfo);
        }
Ejemplo n.º 16
0
 public static void DropThingsNear(IntVec3 dropCenter, Map map, IEnumerable <Thing> things, int openDelay = 110, bool canInstaDropDuringInit = false, bool leaveSlag = false, bool canRoofPunch = true, bool explode = false)
 {
     foreach (Thing thing in things)
     {
         List <Thing> list = new List <Thing>();
         list.Add(thing);
         DropPodUtility.tempList.Add(list);
     }
     DropPodUtility.DropThingGroupsNear(dropCenter, map, DropPodUtility.tempList, openDelay, canInstaDropDuringInit, leaveSlag, canRoofPunch, explode);
     DropPodUtility.tempList.Clear();
 }
        public override void Arrive(List <Pawn> pawns, IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <Pair <List <Pawn>, IntVec3> > list = PawnsArrivalModeWorkerUtility.SplitIntoRandomGroupsNearMapEdge(pawns, map, arriveInPods: true);

            PawnsArrivalModeWorkerUtility.SetPawnGroupsInfo(parms, list);
            for (int i = 0; i < list.Count; i++)
            {
                DropPodUtility.DropThingsNear(list[i].Second, map, list[i].First.Cast <Thing>(), parms.podOpenDelay, canInstaDropDuringInit: false, leaveSlag: true);
            }
        }
Ejemplo n.º 18
0
        public override bool Spawn(IntVec3 at, Map map, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false)
        {
            if (IsSpawningBlocked(at, map, null, wipeIfCollides))
            {
                return(false);
            }
            switch (spawnMode)
            {
            case Sketch.SpawnMode.Blueprint:
                GenConstruct.PlaceBlueprintForBuild(def, at, map, rot, faction, stuff ?? GenStuff.DefaultStuffFor(def));
                break;

            case Sketch.SpawnMode.Normal:
            {
                Thing thing2 = Instantiate();
                spawnedThings?.Add(thing2);
                if (faction != null)
                {
                    thing2.SetFactionDirect(faction);
                }
                SetDormant(thing2, dormant);
                GenSpawn.Spawn(thing2, at, map, rot, WipeMode.VanishOrMoveAside);
                break;
            }

            case Sketch.SpawnMode.TransportPod:
            {
                Thing thing = Instantiate();
                thing.Position = at;
                thing.Rotation = rot;
                spawnedThings?.Add(thing);
                if (faction != null)
                {
                    thing.SetFactionDirect(faction);
                }
                SetDormant(thing, dormant);
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                activeDropPodInfo.innerContainer.TryAdd(thing, 1);
                activeDropPodInfo.openDelay = 60;
                activeDropPodInfo.leaveSlag = false;
                activeDropPodInfo.despawnPodBeforeSpawningThing = true;
                activeDropPodInfo.spawnWipeMode = (wipeIfCollides ? new WipeMode?(WipeMode.VanishOrMoveAside) : null);
                activeDropPodInfo.moveItemsAsideBeforeSpawning = true;
                activeDropPodInfo.setRotation = rot;
                DropPodUtility.MakeDropPodAt(at, map, activeDropPodInfo);
                break;
            }

            default:
                throw new NotImplementedException("Spawn mode " + spawnMode + " not implemented!");
            }
            return(true);
        }
Ejemplo n.º 19
0
        private void Spawn()
        {
            Lord lord = CompSpawnerPawn.FindLordToJoin(parent, Props.lordJob, Props.shouldJoinParentLord, (Thing spawner) => spawner.TryGetComp <CompPawnSpawnOnWakeup>()?.spawnedPawns);

            if (lord == null)
            {
                lord = CompSpawnerPawn.CreateNewLord(parent, Props.aggressive, Props.defendRadius, Props.lordJob);
            }
            IntVec3 spawnPosition = GetSpawnPosition();

            if (!spawnPosition.IsValid)
            {
                return;
            }
            List <Thing> list = GeneratePawns();

            if (Props.dropInPods)
            {
                DropPodUtility.DropThingsNear(spawnPosition, parent.MapHeld, list);
            }
            List <IntVec3> occupiedCells = new List <IntVec3>();

            foreach (Thing item in list)
            {
                if (!Props.dropInPods)
                {
                    IntVec3 intVec = CellFinder.RandomClosewalkCellNear(spawnPosition, parent.Map, Props.pawnSpawnRadius.RandomInRange, (IntVec3 c) => !occupiedCells.Contains(c));
                    if (!intVec.IsValid)
                    {
                        intVec = CellFinder.RandomClosewalkCellNear(spawnPosition, parent.Map, Props.pawnSpawnRadius.RandomInRange);
                    }
                    GenSpawn.Spawn(item, intVec, parent.Map);
                    occupiedCells.Add(intVec);
                }
                lord.AddPawn((Pawn)item);
                spawnedPawns.Add((Pawn)item);
                item.TryGetComp <CompCanBeDormant>()?.WakeUp();
            }
            if (Props.spawnEffecter != null)
            {
                Effecter effecter = new Effecter(Props.spawnEffecter);
                effecter.Trigger(parent, TargetInfo.Invalid);
                effecter.Cleanup();
            }
            if (Props.spawnSound != null)
            {
                Props.spawnSound.PlayOneShot(parent);
            }
            if (Props.activatedMessageKey != null)
            {
                Messages.Message(Props.activatedMessageKey.Translate(), spawnedPawns, MessageTypeDefOf.ThreatBig);
            }
        }
Ejemplo n.º 20
0
        public override void DoEffect(Pawn usedBy)
        {
            base.DoEffect(usedBy);
            if (Rand.Chance(0.12f))
            {
                ResearchProjectDef shieldProj = DefDatabase <ResearchProjectDef> .GetNamed("PolarisShield", true);

                if (shieldProj != null && !shieldProj.IsFinished)
                {
                    this.FinishInstantly(shieldProj);
                }
                else if (this.TryRandomlyUnfinishedResearch(out ResearchProjectDef researchProj))
                {
                    this.FinishInstantly(researchProj);
                }
            }
            else
            {
                if (Rand.Chance(0.3f))
                {
                    Map          map    = usedBy.MapHeld;
                    List <Thing> things = ThingSetMakerDefOf.ResourcePod.root.Generate();
                    IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
                    DropPodUtility.DropThingsNear(intVec, map, things, 110, false, true, true);
                    Find.LetterStack.ReceiveLetter("LetterLabelPolarisblocConsolationPrize".Translate(), "PolarisblocConsolationPrize".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);
                    return;
                }
                if (Rand.Chance(0.01f))
                {
                    Map          map    = usedBy.MapHeld;
                    List <Thing> things = new List <Thing>();
                    Thing        thing  = ThingMaker.MakeThing(PSFDefOf.PolarisBunnyGundamSculpture, ThingDefOf.Gold);
                    things.Add(thing);
                    IntVec3 intVec = DropCellFinder.RandomDropSpot(map);
                    DropPodUtility.DropThingsNear(intVec, map, things, 110, false, true, true);
                    Find.LetterStack.ReceiveLetter("LetterLabelPolarisblocSurprised".Translate(), "PolarisblocSurprised".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);
                    return;
                }
                else
                {
                    Messages.Message("MessageFailToUnscrambleMemoryStick".Translate(new object[]
                    {
                        usedBy.LabelShort
                    }), MessageTypeDefOf.NegativeEvent);
                }
            }
        }
Ejemplo n.º 21
0
        protected override void Complete(SignalArgs signalArgs)
        {
            Map map = (returnMap == null) ? Find.AnyPlayerHomeMap : returnMap.Map;

            if (map != null)
            {
                base.Complete(new SignalArgs(new LookTargets(lentColonists).Named("SUBJECT"), lentColonists.Select((Thing c) => c.LabelShort).ToCommaList(useAnd: true).Named("PAWNS")));
                if (lendColonistsToFaction == Faction.Empire)
                {
                    SkyfallerUtility.MakeDropoffShuttle(map, lentColonists, Faction.Empire);
                }
                else
                {
                    DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(map), map, lentColonists, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: true, forbid: false);
                }
            }
        }
Ejemplo n.º 22
0
 public override void Notify_PawnKilled(Pawn pawn, DamageInfo?dinfo)
 {
     if (lentColonists.Contains(pawn))
     {
         Building_Grave assignedGrave = null;
         if (pawn.ownership != null)
         {
             assignedGrave = pawn.ownership.AssignedGrave;
         }
         Corpse val = pawn.MakeCorpse(assignedGrave, inBed: false, 0f);
         lentColonists.Remove(pawn);
         Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
         if (anyPlayerHomeMap != null)
         {
             DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(anyPlayerHomeMap), anyPlayerHomeMap, Gen.YieldSingle(val), 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: true, forbid: false);
         }
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ItemCollectionGeneratorDefOf.RefugeePod.Worker.Generate(default(ItemCollectionGeneratorParams));
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);
            string       label  = "LetterLabelRefugeePodCrash".Translate();
            string       text   = "RefugeePodCrash".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, true);
            return(true);
        }
        public override void GenerateIntoMap(Map map)
        {
            if (Find.GameInitData == null)
            {
                return;
            }
            List <List <Thing> > list = new List <List <Thing> >();

            foreach (Pawn item in Find.GameInitData.startingAndOptionalPawns)
            {
                list.Add(new List <Thing>
                {
                    item
                });
            }
            List <Thing> list2 = new List <Thing>();

            foreach (ScenPart scenPart in Find.Scenario.AllParts)
            {
                list2.AddRange(scenPart.PlayerStartingThings());
            }
            int num = 0;

            foreach (Thing thing in list2)
            {
                if (thing.def.CanHaveFaction)
                {
                    thing.SetFactionDirect(Faction.OfPlayer);
                }
                list[num].Add(thing);
                num++;
                if (num >= list.Count)
                {
                    num = 0;
                }
            }
            IntVec3 playerStartSpot           = MapGenerator.PlayerStartSpot;
            List <List <Thing> > thingsGroups = list;
            bool instaDrop = Find.GameInitData.QuickStarted || this.method != PlayerPawnsArriveMethod.DropPods;

            DropPodUtility.DropThingGroupsNear(playerStartSpot, map, thingsGroups, 110, instaDrop, true, true);
        }
 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true)
 {
     foreach (List <Thing> list in thingsGroups)
     {
         IntVec3 intVec;
         if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch))
         {
             Log.Warning(string.Concat(new object[]
             {
                 "DropThingsNear failed to find a place to drop ",
                 list.FirstOrDefault <Thing>(),
                 " near ",
                 dropCenter,
                 ". Dropping on random square instead."
             }), false);
             intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000);
         }
         for (int i = 0; i < list.Count; i++)
         {
             list[i].SetForbidden(true, false);
         }
         if (instaDrop)
         {
             foreach (Thing thing in list)
             {
                 GenPlace.TryPlaceThing(thing, intVec, map, ThingPlaceMode.Near, null, null);
             }
         }
         else
         {
             ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
             foreach (Thing item in list)
             {
                 activeDropPodInfo.innerContainer.TryAdd(item, true);
             }
             activeDropPodInfo.openDelay = openDelay;
             activeDropPodInfo.leaveSlag = leaveSlag;
             DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
         }
     }
 }
        private void CallResources(IntVec3 cell)
        {
            List <Thing> list = new List <Thing>();

            for (int i = 0; i < def.royalAid.itemsToDrop.Count; i++)
            {
                Thing thing = ThingMaker.MakeThing(def.royalAid.itemsToDrop[i].thingDef);
                thing.stackCount = def.royalAid.itemsToDrop[i].count;
                list.Add(thing);
            }
            if (list.Any())
            {
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(list);
                DropPodUtility.MakeDropPodAt(cell, map, activeDropPodInfo);
                Messages.Message("MessagePermitTransportDrop".Translate(faction.Named("FACTION")), new LookTargets(cell, map), MessageTypeDefOf.NeutralEvent);
                caller.royalty.GetPermit(def, faction).Notify_Used();
                if (!free)
                {
                    caller.royalty.TryRemoveFavor(faction, def.royalAid.favorCost);
                }
            }
        }
Ejemplo n.º 27
0
        public List <Thing> ApplyRewardsForTitle(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool onlyForNewestTitle = false)
        {
            List <Thing>      list  = new List <Thing>();
            List <ThingCount> list2 = new List <ThingCount>();

            if (newTitle != null && newTitle.Awardable && pawn.IsColonist && NewHighestTitle(faction, newTitle))
            {
                int num  = ((currentTitle != null) ? faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) : 0) + 1;
                int num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle);
                if (onlyForNewestTitle)
                {
                    num = num2;
                }
                IntVec3 result  = IntVec3.Invalid;
                Map     mapHeld = pawn.MapHeld;
                if (mapHeld != null)
                {
                    if (mapHeld.IsPlayerHome)
                    {
                        result = DropCellFinder.TradeDropSpot(mapHeld);
                    }
                    else if (!DropCellFinder.TryFindDropSpotNear(pawn.Position, mapHeld, out result, allowFogged: false, canRoofPunch: false))
                    {
                        result = DropCellFinder.RandomDropSpot(mapHeld);
                    }
                }
                for (int i = num; i <= num2; i++)
                {
                    RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading[i];
                    if (royalTitleDef.rewards == null)
                    {
                        continue;
                    }
                    List <Thing> list3 = royalTitleDef.rewards.Select(delegate(ThingDefCountClass r)
                    {
                        Thing thing      = ThingMaker.MakeThing(r.thingDef);
                        thing.stackCount = r.count;
                        return(thing);
                    }).ToList();
                    for (int j = 0; j < list3.Count; j++)
                    {
                        if (list3[j].def == ThingDefOf.PsychicAmplifier)
                        {
                            Find.History.Notify_PsylinkAvailable();
                            break;
                        }
                    }
                    if (pawn.Spawned)
                    {
                        DropPodUtility.DropThingsNear(result, mapHeld, list3, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false, forbid: false);
                    }
                    else
                    {
                        foreach (Thing item in list3)
                        {
                            pawn.inventory.TryAddItemNotForSale(item);
                        }
                    }
                    for (int k = 0; k < list3.Count; k++)
                    {
                        list2.Add(new ThingCount(list3[k], list3[k].stackCount));
                    }
                    list.AddRange(list3);
                }
                if (list.Count > 0)
                {
                    TaggedString text = "LetterRewardsForNewTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE")) + "\n\n" + GenLabel.ThingsLabel(list2, "  - ", ignoreStackLimit: true) + "\n\n" + (pawn.Spawned ? "LetterRewardsForNewTitleDeliveryBase" : "LetterRewardsForNewTitleDeliveryDirect").Translate(pawn.Named("PAWN"));
                    Find.LetterStack.ReceiveLetter("LetterLabelRewardsForNewTitle".Translate(), text, LetterDefOf.PositiveEvent, list);
                }
            }
            return(list);
        }
        public static void DropInDropPodsNearSpawnCenter(IncidentParms parms, List <Pawn> pawns)
        {
            Map map = (Map)parms.target;

            DropPodUtility.DropThingsNear(parms.spawnCenter, map, pawns.Cast <Thing>(), parms.podOpenDelay, false, true, true, false);
        }
Ejemplo n.º 29
0
        public static List <Thing> SpawnCluster(IntVec3 center, Map map, MechClusterSketch sketch, bool dropInPods = true, bool canAssaultColony = false, string questTag = null)
        {
            List <Thing> spawnedThings = new List <Thing>();

            Sketch.SpawnMode spawnMode = (!dropInPods) ? Sketch.SpawnMode.Normal : Sketch.SpawnMode.TransportPod;
            sketch.buildingsSketch.Spawn(map, center, Faction.OfMechanoids, Sketch.SpawnPosType.Unchanged, spawnMode, wipeIfCollides : false, clearEdificeWhereFloor : false, spawnedThings, sketch.startDormant, buildRoofsInstantly : false, null, delegate(IntVec3 spot, SketchEntity entity)
            {
                SketchThing sketchThing;
                if ((sketchThing = (entity as SketchThing)) != null && sketchThing.def != ThingDefOf.Wall && sketchThing.def != ThingDefOf.Barricade)
                {
                    entity.SpawnNear(spot, map, 12f, Faction.OfMechanoids, spawnMode, wipeIfCollides: false, spawnedThings, sketch.startDormant);
                }
            });
            float defendRadius = Mathf.Sqrt(sketch.buildingsSketch.OccupiedSize.x * sketch.buildingsSketch.OccupiedSize.x + sketch.buildingsSketch.OccupiedSize.z * sketch.buildingsSketch.OccupiedSize.z) / 2f + 6f;
            LordJob_MechanoidDefendBase lordJob_MechanoidDefendBase = null;

            lordJob_MechanoidDefendBase = ((!sketch.startDormant) ? ((LordJob_MechanoidDefendBase) new LordJob_MechanoidsDefend(spawnedThings, Faction.OfMechanoids, defendRadius, center, canAssaultColony, isMechCluster: true)) : ((LordJob_MechanoidDefendBase) new LordJob_SleepThenMechanoidsDefend(spawnedThings, Faction.OfMechanoids, defendRadius, center, canAssaultColony, isMechCluster: true)));
            Lord lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob_MechanoidDefendBase, map);

            QuestUtility.AddQuestTag(lord, questTag);
            bool  flag          = Rand.Chance(0.6f);
            float randomInRange = InitiationDelay.RandomInRange;
            int   num           = (int)(MechAssemblerInitialDelayDays.RandomInRange * 60000f);

            for (int i = 0; i < spawnedThings.Count; i++)
            {
                Thing thing = spawnedThings[i];
                thing.TryGetComp <CompSpawnerPawn>()?.CalculateNextPawnSpawnTick(num);
                if (thing.TryGetComp <CompProjectileInterceptor>() != null)
                {
                    lordJob_MechanoidDefendBase.AddThingToNotifyOnDefeat(thing);
                }
                if (flag)
                {
                    CompInitiatable compInitiatable = thing.TryGetComp <CompInitiatable>();
                    if (compInitiatable != null)
                    {
                        compInitiatable.initiationDelayTicksOverride = (int)(60000f * randomInRange);
                    }
                }
                Building b;
                if ((b = (thing as Building)) != null && IsBuildingThreat(b))
                {
                    lord.AddBuilding(b);
                }
                thing.SetFaction(Faction.OfMechanoids);
            }
            if (!sketch.pawns.NullOrEmpty())
            {
                foreach (MechClusterSketch.Mech pawn2 in sketch.pawns)
                {
                    IntVec3 result = pawn2.position + center;
                    if (result.Standable(map) || CellFinder.TryFindRandomCellNear(result, map, 12, (IntVec3 x) => x.Standable(map), out result))
                    {
                        Pawn             pawn             = PawnGenerator.GeneratePawn(pawn2.kindDef, Faction.OfMechanoids);
                        CompCanBeDormant compCanBeDormant = pawn.TryGetComp <CompCanBeDormant>();
                        if (compCanBeDormant != null)
                        {
                            if (sketch.startDormant)
                            {
                                compCanBeDormant.ToSleep();
                            }
                            else
                            {
                                compCanBeDormant.WakeUp();
                            }
                        }
                        lord.AddPawn(pawn);
                        spawnedThings.Add(pawn);
                        if (dropInPods)
                        {
                            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                            activeDropPodInfo.innerContainer.TryAdd(pawn, 1);
                            activeDropPodInfo.openDelay = 60;
                            activeDropPodInfo.leaveSlag = false;
                            activeDropPodInfo.despawnPodBeforeSpawningThing = true;
                            activeDropPodInfo.spawnWipeMode = WipeMode.Vanish;
                            DropPodUtility.MakeDropPodAt(result, map, activeDropPodInfo);
                        }
                        else
                        {
                            GenSpawn.Spawn(pawn, result, map);
                        }
                    }
                }
            }
            foreach (Thing item in spawnedThings)
            {
                if (!sketch.startDormant)
                {
                    item.TryGetComp <CompWakeUpDormant>()?.Activate(sendSignal: true, silent: true);
                }
            }
            return(spawnedThings);
        }
Ejemplo n.º 30
0
        public override void Init()
        {
            base.Init();
            LordToilData_Siege data = this.Data;

            data.baseRadius = Mathf.InverseLerp(14f, 25f, (float)this.lord.ownedPawns.Count / 50f);
            data.baseRadius = Mathf.Clamp(data.baseRadius, 14f, 25f);
            List <Thing> list = new List <Thing>();

            foreach (Blueprint_Build current in SiegeBlueprintPlacer.PlaceBlueprints(data.siegeCenter, base.Map, this.lord.faction, data.blueprintPoints))
            {
                data.blueprints.Add(current);
                foreach (ThingDefCountClass cost in current.MaterialsNeeded())
                {
                    Thing thing = list.FirstOrDefault((Thing t) => t.def == cost.thingDef);
                    if (thing != null)
                    {
                        thing.stackCount += cost.count;
                    }
                    else
                    {
                        Thing thing2 = ThingMaker.MakeThing(cost.thingDef, null);
                        thing2.stackCount = cost.count;
                        list.Add(thing2);
                    }
                }
                ThingDef thingDef = current.def.entityDefToBuild as ThingDef;
                if (thingDef != null)
                {
                    ThingDef  turret    = thingDef;
                    bool      allowEMP  = false;
                    TechLevel techLevel = this.lord.faction.def.techLevel;
                    ThingDef  thingDef2 = TurretGunUtility.TryFindRandomShellDef(turret, allowEMP, true, techLevel, false, 250f);
                    if (thingDef2 != null)
                    {
                        Thing thing3 = ThingMaker.MakeThing(thingDef2, null);
                        thing3.stackCount = 5;
                        list.Add(thing3);
                    }
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                list[i].stackCount = Mathf.CeilToInt((float)list[i].stackCount * Rand.Range(1f, 1.2f));
            }
            List <List <Thing> > list2 = new List <List <Thing> >();

            for (int j = 0; j < list.Count; j++)
            {
                while (list[j].stackCount > list[j].def.stackLimit)
                {
                    int   num    = Mathf.CeilToInt((float)list[j].def.stackLimit * Rand.Range(0.9f, 0.999f));
                    Thing thing4 = ThingMaker.MakeThing(list[j].def, null);
                    thing4.stackCount   = num;
                    list[j].stackCount -= num;
                    list.Add(thing4);
                }
            }
            List <Thing> list3 = new List <Thing>();

            for (int k = 0; k < list.Count; k++)
            {
                list3.Add(list[k]);
                if (k % 2 == 1 || k == list.Count - 1)
                {
                    list2.Add(list3);
                    list3 = new List <Thing>();
                }
            }
            List <Thing> list4 = new List <Thing>();
            int          num2  = Mathf.RoundToInt(LordToil_Siege.MealCountRangePerRaider.RandomInRange * (float)this.lord.ownedPawns.Count);

            for (int l = 0; l < num2; l++)
            {
                Thing item = ThingMaker.MakeThing(ThingDefOf.MealSurvivalPack, null);
                list4.Add(item);
            }
            list2.Add(list4);
            DropPodUtility.DropThingGroupsNear(data.siegeCenter, base.Map, list2, 110, false, false, true);
            data.desiredBuilderFraction = LordToil_Siege.BuilderCountFraction.RandomInRange;
        }