public static bool Prefix(TransportPodsArrivalAction_LandInSpecificCell __instance, List <ActiveDropPodInfo> pods, int tile, IntVec3 ___cell, MapParent ___mapParent)
 {
     //    Log.Message(string.Format("pods: {0}", pods.Count));
     foreach (ActiveDropPodInfo info in pods)
     {
         for (int i = 0; i < info.innerContainer.Count; i++)
         {
             Thing        dropship = info.innerContainer[i];
             CompDropship comp     = dropship.TryGetCompFast <CompDropship>();
             if (comp != null)
             {
                 //    Log.Message(string.Format("pods: {0}", info.innerContainer.ContentsString));
                 Thing    lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods);
                 Traverse tv         = Traverse.Create(__instance);
                 IntVec3  c          = ___cell;
                 Map      map        = ___mapParent.Map;
                 TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(pods);
                 for (int ii = 0; ii < pods.Count; ii++)
                 {
                     DropPodUtility.MakeDropPodAt(c, map, pods[ii]);
                 }
                 Messages.Message("AvP_USCM_Dropship_MessageArrived".Translate(), lookTarget, MessageTypeDefOf.TaskCompletion, true);
                 return(false);
             }
         }
     }
     return(true);
 }
示例#2
0
        private void DropAcquiredMats()
        {
            List <Thing> list = new List <Thing>();

            foreach (var item in ShoppingList.AcquiredMats)
            {
                int remaining = item.amount;
                while (remaining > 0)
                {
                    int   num   = UnityEngine.Mathf.Min(item.thing.stackLimit, remaining);
                    Thing thing = ThingMaker.MakeThing(item.thing);
                    thing.stackCount = num;
                    remaining       -= num;
                    list.Add(thing);
                }
            }

            foreach (var thing in list)
            {
                IntVec3 loc = DropCellFinder.TradeDropSpot();
                DropPodUtility.MakeDropPodAt(loc, new DropPodInfo
                {
                    SingleContainedThing = thing,
                    leaveSlag            = false
                });
            }
        }
示例#3
0
        // Token: 0x0600005C RID: 92 RVA: 0x00003CE8 File Offset: 0x00001EE8
        public override void OnEndReceiver(RealmData realmData)
        {
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                var singleContainedThing = realmPawn.FromRealmPawn(realmData);
                var intVec = DropCellFinder.RandomDropSpot(Find.CurrentMap);
                DropPodUtility.MakeDropPodAt(intVec, Find.CurrentMap, new ActiveDropPodInfo
                {
                    SingleContainedThing = singleContainedThing,
                    openDelay            = 110,
                    leaveSlag            = false
                });
                Find.LetterStack.ReceiveLetter(
                    $"{Enum.GetName(typeof(TransactionType), transaction)} pod",
                    $"A {Enum.GetName(typeof(TransactionType), transaction)?.ToLower()} was sent to you by {sender.name}",
                    LetterDefOf.PositiveEvent, new GlobalTargetInfo(intVec, Find.CurrentMap));
                return;
            }

            if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name,
                                 MessageTypeDefOf.RejectInput);
                return;
            }

            var unused = state;
        }
        public override bool TryExecute(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (map.Biome != Util_CaveBiome.CaveBiomeDef)
            {
                return(base.TryExecute(parms));
            }
            IntVec3 intVec = IntVec3.Invalid;

            TryFindRefugeePodSpot(map, out intVec);
            if (intVec.IsValid == false)
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer);
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            HealthUtility.DamageUntilDowned(pawn);
            string label = "LetterLabelRefugeePodCrash".Translate();
            string text  = "RefugeePodCrash".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.BadNonUrgent, new GlobalTargetInfo(intVec, map, false), null);
            DropPodUtility.MakeDropPodAt(intVec, map, new ActiveDropPodInfo
            {
                SingleContainedThing = pawn,
                openDelay            = 180,
                leaveSlag            = true
            });
            return(true);
        }
 private void DropThingGroupsAt(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool forbid = true, bool allowFogged = true)
 {
     foreach (List <Thing> thingsGroup in thingsGroups)
     {
         if (forbid)
         {
             for (int index = 0; index < thingsGroup.Count; ++index)
             {
                 thingsGroup[index].SetForbidden(true, false);
             }
         }
         if (instaDrop)
         {
             foreach (Thing thing in thingsGroup)
             {
                 GenPlace.TryPlaceThing(thing, dropCenter, map, ThingPlaceMode.Near);
             }
         }
         else
         {
             ActiveDropPodInfo info = new ActiveDropPodInfo();
             foreach (Thing thing in thingsGroup)
             {
                 info.innerContainer.TryAdd(thing);
             }
             info.openDelay = openDelay;
             info.leaveSlag = leaveSlag;
             DropPodUtility.MakeDropPodAt(dropCenter, map, info);
         }
     }
 }
        public override void OnEndReceiver(RealmData realmData)
        {
            // Nothing
            if (state == TransactionResponse.ACCEPTED)
            {
                Pawn pawn = realmPawn.FromRealmPawn(realmData);

                // We drop it
                IntVec3 position = DropCellFinder.RandomDropSpot();
                DropPodUtility.MakeDropPodAt(position, new DropPodInfo
                {
                    SingleContainedThing = pawn,
                    openDelay            = 110,
                    leaveSlag            = false
                });

                Find.LetterStack.ReceiveLetter(
                    "Colonist pod",
                    "A colonist was sent to you by " + sender.name,
                    LetterType.Good,
                    position
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageSound.RejectInput);
            }
        }
示例#7
0
        public void DropAcquiredMats()
        {
            List <Thing> list = new List <Thing>();

            foreach (ThingDef def in acquiredMats.Keys)
            {
                int remaining = 0;
                if (acquiredMats.TryGetValue(def, out remaining))
                {
                    remaining = (int)(remaining * 0.75);
                    while (remaining > 0)
                    {
                        int   num   = UnityEngine.Mathf.Min(def.stackLimit, remaining);
                        Thing thing = ThingMaker.MakeThing(def);
                        thing.stackCount = num;
                        remaining       -= num;
                        list.Add(thing);
                    }
                }
            }

            foreach (var thing in list)
            {
                IntVec3 loc = DropCellFinder.TradeDropSpot();
                DropPodUtility.MakeDropPodAt(loc, new DropPodInfo
                {
                    SingleContainedThing = thing,
                    leaveSlag            = false
                });
            }
        }
示例#8
0
        public static bool Prefix(
            TransportPodsArrivalAction_LandInSpecificCell __instance,
            List <ActiveDropPodInfo> pods,
            int tile)
        {
            foreach (ActiveDropPodInfo pod in pods)
            {
                for (int index = 0; index < pod.innerContainer.Count; index++)
                {
                    if (pod.innerContainer[index].TryGetComp <CompLaunchableSRTS>() != null)
                    {
                        Thing    lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods);
                        Traverse traverse   = Traverse.Create((object)__instance);
                        IntVec3  c          = traverse.Field("cell").GetValue <IntVec3>();
                        Map      map        = traverse.Field("mapParent").GetValue <MapParent>().Map;
                        TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(pods);

                        for (int i = 0; i < pods.Count; ++i)
                        {
                            pods[i].openDelay = 0;
                            DropPodUtility.MakeDropPodAt(c, map, pods[i]);
                        }
                        Messages.Message("MessageTransportPodsArrived".Translate(), (LookTargets)lookTarget, MessageTypeDefOf.TaskCompletion, true);
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#9
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // Nothing
            if (state == TransactionResponse.ACCEPTED)
            {
                Pawn pawn = realmAnimal.FromRealmAnimal(realmData);

                // We drop it
                IntVec3 position = DropCellFinder.RandomDropSpot(Find.VisibleMap);
                DropPodUtility.MakeDropPodAt(position, Find.VisibleMap, new ActiveDropPodInfo
                {
                    SingleContainedThing = pawn,
                    openDelay            = 110,
                    leaveSlag            = false
                });

                Find.LetterStack.ReceiveLetter(
                    "Animal pod",
                    "An animal was sent to you by " + sender.name,
                    LetterDefOf.PositiveEvent,
                    new RimWorld.Planet.GlobalTargetInfo(position, Find.VisibleMap)
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageTypeDefOf.RejectInput);
            }
        }
        public override bool TryExecute(IncidentParms parms)
        {
            Log.Message("IncidentWorker_RefugeePodCrashInCave:TryExecute");
            if (Find.Map.Biome != Util_CaveBiome.CaveBiomeDef)
            {
                return(base.TryExecute(parms));
            }
            IntVec3 intVec = IntVec3.Invalid;

            TryFindRefugeePodSpot(out intVec);
            if (intVec.IsValid == false)
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer);
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, false, false, false, false, true, false, 20f, false, true, true, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            HealthUtility.GiveInjuriesToForceDowned(pawn);
            string label = "LetterLabelRefugeePodCrash".Translate();
            string text  = "RefugeePodCrash".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterType.BadNonUrgent, intVec, null);
            DropPodUtility.MakeDropPodAt(intVec, new DropPodInfo
            {
                SingleContainedThing = pawn,
                openDelay            = 180,
                leaveSlag            = true
            });
            return(true);
        }
        private void CreatePod()
        {
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.openDelay = 10;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(base.Position, base.Map, activeDropPodInfo, true);
        }
 public static void DropTravelingTransportPods(List <ActiveDropPodInfo> dropPods, IntVec3 near, Map map)
 {
     RemovePawnsFromWorldPawns(dropPods);
     for (int i = 0; i < dropPods.Count; i++)
     {
         DropCellFinder.TryFindDropSpotNear(near, map, out IntVec3 result, allowFogged: false, canRoofPunch: true);
         DropPodUtility.MakeDropPodAt(result, map, dropPods[i]);
     }
 }
示例#13
0
 public static void DropTravelingTransportPods(List <ActiveDropPodInfo> dropPods, IntVec3 near, Map map)
 {
     ByakheeArrivalActionUtility.RemovePawnsFromWorldPawns(dropPods);
     for (int i = 0; i < dropPods.Count; i++)
     {
         IntVec3 c;
         DropCellFinder.TryFindDropSpotNear(near, map, out c, false, true, true, null, true);
         DropPodUtility.MakeDropPodAt(c, map, dropPods[i]);
     }
 }
示例#14
0
        private void CreatePod()
        {
            ActiveDropPodInfo info = new ActiveDropPodInfo
            {
                openDelay = 10,
                leaveSlag = true
            };

            DropPodUtility.MakeDropPodAt(base.Position, base.Map, info);
        }
示例#15
0
        public override void OnAcceptKeyPressed()
        {
            base.OnAcceptKeyPressed();
            SoundDefOf.ExecuteTrade.PlayOneShotOnCamera();

            if (daysAmount > 0 && hireData.Any(kvp => kvp.Value.First > 0))
            {
                var pawns = new List <Pawn>();

                var remainingCost = Mathf.RoundToInt(CostFinal);

                var silverList = targetMap.listerThings.ThingsOfDef(ThingDefOf.Silver)
                                 .Where(x => !x.Position.Fogged(x.Map) && (targetMap.areaManager.Home[x.Position] || x.IsInAnyStorage())).ToList();
                while (remainingCost > 0)
                {
                    var silver = silverList.First(t => t.stackCount > 0);
                    var num    = Mathf.Min(remainingCost, silver.stackCount);
                    silver.SplitOff(num).Destroy();
                    remainingCost -= num;
                }

                if (!RCellFinder.TryFindRandomPawnEntryCell(out var cell, targetMap, 1f))
                {
                    cell = CellFinder.RandomEdgeCell(targetMap);
                }

                foreach (var kvp in hireData)
                {
                    for (var i = 0; i < kvp.Value.First; i++)
                    {
                        var flag = kvp.Key.ignoreFactionApparelStuffRequirements;
                        kvp.Key.ignoreFactionApparelStuffRequirements = true;
                        var pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(kvp.Key, mustBeCapableOfViolence: true, faction: Faction.OfPlayer,
                                                                                        forbidAnyTitle: true, fixedIdeo: curFaction.referencedFaction is null
                                ? hiredIdeo ?? (hiredIdeo = IdeoGenerator.GenerateIdeo(new IdeoGenerationParms(Faction.OfPlayer.def, classic: true)))
                                : Find.World.factionManager.FirstFactionOfDef(curFaction.referencedFaction).ideos.GetRandomIdeoForNewPawn()));
                        kvp.Key.ignoreFactionApparelStuffRequirements = flag;
                        pawn.playerSettings.hostilityResponse         = HostilityResponseMode.Attack;
                        pawns.Add(pawn);
                        var loc = DropCellFinder.TryFindSafeLandingSpotCloseToColony(targetMap, IntVec2.Two);

                        var activeDropPodInfo = new ActiveDropPodInfo();
                        activeDropPodInfo.innerContainer.TryAdd(pawn, 1);
                        activeDropPodInfo.openDelay = 60;
                        activeDropPodInfo.leaveSlag = false;
                        activeDropPodInfo.despawnPodBeforeSpawningThing = true;
                        activeDropPodInfo.spawnWipeMode = WipeMode.Vanish;
                        DropPodUtility.MakeDropPodAt(loc, targetMap, activeDropPodInfo);
                    }
                }

                Find.World.GetComponent <HiringContractTracker>().SetNewContract(daysAmount, pawns, hireable, curFaction, CostFinal);
            }
        }
示例#16
0
        public static void Enter(Pawn pawn, StringBuilder message)
        {
            var map = Find.CurrentMap;

            if (pawn.Map == map)
            {
                message.Append("You're already on the current map");
                return;
            }

            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            LetterDef textLetterDef = LetterDefOf.NeutralEvent;
            string    label         = "LetterLabelRefugeePodCrash".Translate();
            string    text          = "RefugeePodCrash".Translate().AdjustedFor(pawn, "PAWN");

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");

                textLetterDef = LetterDefOf.ThreatSmall;
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);

            Find.LetterStack.ReceiveLetter(label, text, textLetterDef, new TargetInfo(intVec, map, false), null, null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(new[] { pawn }, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);

            message.Append(text);
        }
示例#17
0
        static bool Prefix(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true)
        {
            IntVec3 intVec3;

            foreach (List <Thing> thingsGroup in thingsGroups)
            {
                if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec3, true, canRoofPunch))
                {
                    Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", thingsGroup.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." }));
                    intVec3 = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000);
                }
                for (int i = 0; i < thingsGroup.Count; i++)
                {
                    thingsGroup[i].SetForbidden(true, false);
                }
                if (!instaDrop)
                {
                    ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                    foreach (Thing thing in thingsGroup)
                    {
                        activeDropPodInfo.innerContainer.TryAdd(thing, true);
                    }
                    if (Controller.Settings.podTrees.Equals(true))
                    {
                        float woodCheck = map.Biome.plantDensity;
                        if (woodCheck > 1)
                        {
                            woodCheck = 1;
                        }
                        if (Rand.Value < (woodCheck * 4))
                        {
                            Thing wood  = ThingMaker.MakeThing(ThingDefOf.WoodLog, null);
                            float count = Rand.Gaussian(80, 10);
                            count           = count * woodCheck;
                            wood.stackCount = (int)count;
                            activeDropPodInfo.innerContainer.TryAdd(wood, true);
                        }
                    }
                    activeDropPodInfo.openDelay = openDelay;
                    activeDropPodInfo.leaveSlag = leaveSlag;
                    DropPodUtility.MakeDropPodAt(intVec3, map, activeDropPodInfo);
                }
                else
                {
                    foreach (Thing thing1 in thingsGroup)
                    {
                        GenPlace.TryPlaceThing(thing1, intVec3, map, ThingPlaceMode.Near, null);
                    }
                }
            }
            return(false);
        }
示例#18
0
        public override void Arrived(List <ActiveDropPodInfo> pods, int tile)
        {
            // drop pods on trade drop spots

            Map     map        = this.shipment.destination.map;
            IntVec3 dropCenter = DropCellFinder.TradeDropSpot(map);

            foreach (var pod in pods)
            {
                if (DropCellFinder.TryFindDropSpotNear(dropCenter, shipment.destination.map, out IntVec3 spot, false, false, false, null))
                {
                    DropPodUtility.MakeDropPodAt(spot, map, pod);
                }
示例#19
0
        private void DropProducts()
        {
            IEnumerable <Thing> products = Config.Recipe.MakeProducts(this, completedCycles);

            foreach (var c in products)
            {
                //Log.Message(c.Label + c.stackCount.ToString());
                IntVec3 loc = DropCellFinder.TradeDropSpot();
                DropPodUtility.MakeDropPodAt(loc, new DropPodInfo
                {
                    SingleContainedThing = c,
                    leaveSlag            = false
                });
            }
            completedCycles = 0;
        }
    public override bool TryExecute(IncidentParms parms)
    {
        IntVec3 dropSpot = GenSquareFinder.RandomSquareWith((sq) => sq.Standable() && !sq.IsFogged());

        Find.LetterStack.ReceiveLetter(new UI.Letter("RefugeePodCrash".Translate(), UI.LetterType.BadNonUrgent, dropSpot));

        Faction fac = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Spacer"));

        Pawn refugee = PawnGenerator.GeneratePawn(PawnKindDef.Named("SpaceRefugee"), fac);

        refugee.healthTracker.ForceIncap();

        DropPodInfo contents = new DropPodInfo(refugee, 180);

        DropPodUtility.MakeDropPodAt(dropSpot, contents);

        Find.Storyteller.intenderPopulation.Notify_PopulationGainIncident();
        return(true);
    }
示例#21
0
 public static bool DropSRTSExactSpot(List<ActiveDropPodInfo> dropPods, IntVec3 near, Map map)
 {
   foreach (ActiveDropPodInfo pod in dropPods)
   {
     foreach (Thing t in pod.innerContainer)
     {
       if (DefDatabase<ThingDef>.GetNamedSilentFail(t.def.defName.Split('_')[0])?.GetCompProperties<CompProperties_LaunchableSRTS>() != null)
       {
         TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(dropPods);
         foreach (ActiveDropPodInfo pod2 in dropPods)
         {
           DropPodUtility.MakeDropPodAt(near, map, pod2);
         }
         return false;
       }
     }
   }
   return true;
 }
示例#22
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveAnimals)
            {
                realmData.NotifyPacketToServer(new ConfirmServerTransactionPacket
                {
                    transaction = this,
                    response    = TransactionResponse.DECLINED
                });
                return;
            }

            // Nothing
            if (state == TransactionResponse.ACCEPTED)
            {
                Pawn pawn = realmAnimal.FromRealmAnimal(realmData);

                // We drop it
                IntVec3 position = DropCellFinder.RandomDropSpot(Find.VisibleMap);
                DropPodUtility.MakeDropPodAt(position, Find.VisibleMap, new ActiveDropPodInfo
                {
                    SingleContainedThing = pawn,
                    openDelay            = 110,
                    leaveSlag            = false
                });

                Find.LetterStack.ReceiveLetter(
                    "Animal pod",
                    "An animal was sent to you by " + sender.name,
                    LetterDefOf.PositiveEvent,
                    new RimWorld.Planet.GlobalTargetInfo(position, Find.VisibleMap)
                    );
            }
            else if (state == TransactionResponse.INTERRUPTED)
            {
                Messages.Message("Unexpected interruption during item transaction with " + sender.name, MessageTypeDefOf.RejectInput);
            }
            else if (state == TransactionResponse.TOOFAST)
            {
                // This should never happen as the server rejects intercepted packets.
            }
        }
        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;
            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);

            if (Quote != null)
            {
                text += "\n\n";
                text += Quote;
            }

            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);
        }
示例#24
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var map    = (Map)parms.target;
            var things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            var intVec = DropCellFinder.RandomDropSpot(map);
            var pawn   = FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            var label = "LetterLabelRefugeePodCrash".Translate();
            var 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 label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map));
            var activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);

            //Give the pawn the Scuttlebug Infection
            var torso  = pawn.health.hediffSet.GetNotMissingParts().First(bpr => bpr.def == BodyPartDefOf.Torso);
            var unused = pawn.health.hediffSet.GetNotMissingParts().First(bpr => bpr.def == BodyPartDefOf.Head);

            pawn.health.AddHediff(HediffDef.Named("ScuttlebugInfection"), torso);

            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map    = (Map)parms.target;
            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);
            Building_Overgrown_DropPod overgrown_DropPod = (Building_Overgrown_DropPod)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("AA_Overgrown_DropPod", true));

            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
            List <Thing>      things            = new List <Thing>();

            things.Add(overgrown_DropPod);
            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            LookTargets lookie = new LookTargets(intVec, map);

            Find.LetterStack.ReceiveLetter("LetterLabelCactipinePod".Translate(), "CactipineDropPod".Translate(), LetterDefOf.NeutralEvent, lookie, null, null);
            //GenSpawn.Spawn(overgrown_DropPod, intVec, map);
            return(true);
        }
        private void SpawnDropPodsInMap(Map map, string extraMessagePart = null)
        {
            this.RemoveAllPawnsFromWorldPawns();
            IntVec3 intVec;

            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);
                }
                intVec = DropCellFinder.FindRaidDropCenterDistant(map);
            }
            for (int i = 0; i < this.pods.Count; i++)
            {
                IntVec3 c;
                DropCellFinder.TryFindDropSpotNear(intVec, map, out c, false, true);
                this.pods[i].parent = null;
                DropPodUtility.MakeDropPodAt(c, map, this.pods[i], false);
            }
            this.RemoveAllPods();
            Find.WorldObjects.Remove(this);
            string text = "MessageTransportPodsArrived".Translate();

            if (extraMessagePart != null)
            {
                text = text + " " + extraMessagePart;
            }
            Messages.Message(text, new TargetInfo(intVec, map, false), MessageTypeDefOf.TaskCompletion);
        }
示例#27
0
 public static bool Prefix(TransportPodsArrivalAction_LandInSpecificCell __instance, List <ActiveDropPodInfo> pods, int tile)
 {
     foreach (ActiveDropPodInfo info in pods)
     {
         if (info.innerContainer.Contains(ThingDef.Named("Building_Helicopter")))
         {
             Thing    lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods);
             Traverse tv         = Traverse.Create(__instance);
             IntVec3  c          = tv.Field("cell").GetValue <IntVec3>();
             Map      map        = tv.Field("mapParent").GetValue <MapParent>().Map;
             TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(pods);
             for (int i = 0; i < pods.Count; i++)
             {
                 DropPodUtility.MakeDropPodAt(c, map, pods[i]);
             }
             Messages.Message("MessageTransportPodsArrived".Translate(), lookTarget, MessageTypeDefOf.TaskCompletion, true);
             return(false);
         }
     }
     return(true);
 }
        public override bool TryExecute(IncidentParms parms)
        {
            IntVec3 intVec = DropCellFinder.RandomDropSpot();

            Find.LetterStack.ReceiveLetter("LetterLabelRefugeePodCrash".Translate(), "RefugeePodCrash".Translate(),
                                           LetterType.BadNonUrgent, intVec);
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer);
            Pawn    pawn    = PawnGenerator.GeneratePawn(Verse.PawnKindDef.Named("MechanoidCovert"), faction);

            pawn.gender = Gender.Female;
            FixBackstory(pawn);
            FixHair(pawn);

            pawn.Name = NameGenerator.GenerateName(pawn);
            HealthUtility.GiveInjuriesToForceDowned(pawn);
            DropPodUtility.MakeDropPodAt(intVec,
                                         new DropPodInfo {
                SingleContainedThing = pawn, openDelay = 180, leaveSlag = true
            });
            return(true);
        }
示例#29
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map     = (Map)parms.target;
            IntVec3 intVec  = DropCellFinder.RandomDropSpot(map);
            Faction faction = Find.FactionManager.RandomNonHostileFaction(true, true, true, TechLevel.Neolithic);
            PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(PawnKindDefOf.Villager, faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, false, 1f, true, true, true, false, false, false, false, false, 0f,
                                                                                    null, 1f, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(pawnGenerationRequest);

            HealthUtility.DamageUntilDowned(pawn);
            string text  = "MO_TribalAid".Translate();
            string text2 = "MO_TribalAidDesc".Translate();             //"One of the tribes has send you a message.\n\nWhile the language of the tribals was unfamiliar, the intention was clear: The tribal party didn't have the ability to treat the injuries of one of their friends and they pleaded that you heal their friend..\n\nYou can help the injured tribal to improve relations with the corresponding faction, or capture them for slavery or recruitment purposes.";

            Find.LetterStack.ReceiveLetter(text, text2, LetterDefOf.NewQuest, new TargetInfo(intVec, map, false), null);
            DropPodUtility.MakeDropPodAt(intVec, map, new ActiveDropPodInfo
            {
                SingleContainedThing = pawn,
                openDelay            = 180,
                leaveSlag            = true
            });
            return(true);
        }
示例#30
0
        void LaunchSecurityDropPods(int dropPodsNumber, PawnKindDef securityForcesDef, bool assaultColony)
        {
            IntVec3     dropPodSpot;
            List <Pawn> securityForcesList = new List <Pawn>();

            if ((dropPodsNumber == 0) || (securityForcesDef == null))
            {
                return;
            }
            OG_Inhabitants.InitializeUniformColorAccordingToBiome(); // Necessary in case of small outpost (no inhabitants were generated).
            for (int soldierIndex = 0; soldierIndex < dropPodsNumber; soldierIndex++)
            {
                bool validDropPodCellIsFound = DropCellFinder.TryFindDropSpotNear(this.dropZoneCenter, out dropPodSpot, true, false);
                if (validDropPodCellIsFound)
                {
                    Pawn soldier = OG_Inhabitants.GeneratePawn(securityForcesDef);
                    securityForcesList.Add(soldier);
                    DropPodUtility.MakeDropPodAt(dropPodSpot, new DropPodInfo
                    {
                        SingleContainedThing = soldier,
                        openDelay            = 240,
                        leaveSlag            = false
                    });
                }
            }

            LordJob lordJob;

            if (assaultColony)
            {
                lordJob = new LordJob_AssaultColony(OG_Util.FactionOfMAndCo, true, true, false);
            }
            else
            {
                lordJob = new LordJob_DefendPoint(this.dropZoneCenter);
            }
            Lord lord = LordMaker.MakeNewLord(OG_Util.FactionOfMAndCo, lordJob, securityForcesList);
        }