private void Payment(List <Thing> payment, bool vassalPay, bool TributePay, string factionList)
        {
            if (GenLocalDate.Year(Find.AnyPlayerHomeMap) >= year)
            {
                year = GenLocalDate.Year(Find.AnyPlayerHomeMap) + 1;
            }
            if (GenLocalDate.DayOfYear(Find.AnyPlayerHomeMap) >= dayOfMonth)
            {
                dayOfMonth = ClosestNumberOf15(GenLocalDate.DayOfYear(Find.AnyPlayerHomeMap) + 1);
            }
            if (!payment.NullOrEmpty())
            {
                string text = "";
                if (vassalPay && TributePay)
                {
                    text += "FactionVassalSilverRecivedBoth".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }
                else if (vassalPay)
                {
                    text += "FactionVassalSilverRecivedVassals".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }
                else if (TributePay)
                {
                    text += "FactionVassalSilverRecivedTrivutaries".Translate(GenThing.GetMarketValue(payment).ToStringMoney(), GenLabel.ThingsLabel(payment, string.Empty));
                }

                factionList.Remove(factionList.Count() - 1);
                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, payment, 110, false, true, true);
                Find.LetterStack.ReceiveLetter("LetterFactionVassalSilverRecived".Translate(), text + factionList, LetterDefOf.PositiveEvent, null);
            }
        }
Exemplo n.º 2
0
        private static void SendDropPod(FCEvent evt)
        {
            Map playerHomeMap = Find.World.GetComponent <FactionFC>().TaxMap;

            MakeDeliveryLetterAndMessage(evt);
            DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(playerHomeMap), playerHomeMap, evt.goods, 110, false, false, false, false);
        }
Exemplo n.º 3
0
        private void SendDrop()
        {
            Map map = Current.Game.CurrentMap;

            GenDate.DayOfYear(ticks, Find.WorldGrid.LongLatOf(map.Tile).x);
            List <Thing> thingList = new List <Thing>
            {
                ThingMaker.MakeThing(AvaliDefs.AvaliNexus)
            };

            Scribe_Values.Look(ref hasDropped, "hasDropped", false);
            Map            target      = map;
            List <Faction> newFactions = new List <Faction>();
            IntVec3        intVec3     = DropCellFinder.TradeDropSpot(target);

            if (map.IsPlayerHome)
            {
                hasDropped = true;
                foreach (Faction faction in Find.FactionManager.AllFactions.Where(x => x.def == AvaliDefs.AvaliFaction))
                {
                    faction.SetRelationDirect(Faction.OfPlayer, FactionRelationKind.Ally);
                    newFactions.Add(faction);
                }
                DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList);
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("IlluminateAirdrop".Translate(), "AirdropEventDesc".Translate(), AvaliMod.AvaliDefs.IlluminateAirdrop);
                Find.LetterStack.ReceiveLetter(choiceLetter, null);
            }
            else
            {
                SetupDrop();
            }
        }
Exemplo n.º 4
0
        private void SendCapsules(List <Thing> toDrop)
        {
            Map     map    = Find.AnyPlayerHomeMap;
            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, toDrop, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);
        }
Exemplo n.º 5
0
        public static bool BuyAndDropItem(SellableItemWithModif tradeItem, Map map, bool receiveLetter = true)
        {
            if (!TakeSilverFromPlayer(tradeItem.MarketValue, map))
            {
                return(false);
            }

            List <Thing> toTrade = new List <Thing>
            {
                tradeItem.Item
            };

            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, toTrade, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);

            if (receiveLetter)
            {
                Find.LetterStack.ReceiveLetter("BuyAndDropItem_NotifyTitle".Translate(), "BuyAndDropItem_NotifyDesc".Translate(), LetterDefOf.PositiveEvent, toTrade);
            }

            tradeItem.Item = null;

            map.resourceCounter.UpdateResourceCounts();

            return(true);
        }
Exemplo n.º 6
0
        private void TryTransfer(Caravan caravan)
        {
            Map map = Find.AnyPlayerHomeMap;

            quest.CheckPrisoners();

            for (int i = quest.DropedPawns.Count - 1; i >= 0; i--)
            {
                Pawn p = quest.DropedPawns[i];
                if (caravan.ContainsPawn(p))
                {
                    caravan.pawns.Remove(p);
                    Find.WorldPawns.RemovePawn(p);
                    quest.DropedPawns.Remove(p);

                    IntVec3 intVec     = DropCellFinder.TradeDropSpot(map);
                    Thing   rewardCopy = ThingMaker.MakeThing(ThingDefOf.Silver);
                    rewardCopy.stackCount = quest.Rewards[0].stackCount;

                    DropPodUtility.DropThingsNear(intVec, map, new List <Thing> {
                        rewardCopy
                    }, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);

                    Find.LetterStack.ReceiveLetter("CaravanArrivalAction_TransferPrisoners_SuccessTitle".Translate(), "CaravanArrivalAction_TransferPrisoners_SuccessDesc".Translate(p.Name.ToStringFull, GssRaids.GssFaction.Name, quest.Rewards[0]), LetterDefOf.PositiveEvent, new LookTargets(intVec, map));
                }
            }

            if (quest.DropedPawns.Count == 0)
            {
                quest.Site.EndQuest(null, EndCondition.Success);
            }
        }
Exemplo n.º 7
0
        private void SendDrop()
        {
            GenDate.DayOfYear(ticks, Find.WorldGrid.LongLatOf(map.Tile).x);
            List <Thing> thingList = new List <Thing>();

            thingList.Add(ThingMaker.MakeThing(AvaliDefs.AvaliNexus));
            Scribe_Values.Look(ref hasDropped, "hasDropped", false);
            Map            target      = map;
            List <Faction> newFactions = new List <Faction>();
            IntVec3        intVec3     = DropCellFinder.TradeDropSpot(target);

            if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, AvaliDefs.RimVali) >= 5 && !hasDropped)
            {
                hasDropped = true;
                for (int a = 0; a < random.Next(2, 5); a++)
                {
                    Faction faction = FactionGenerator.NewGeneratedFaction(AvaliDefs.AvaliFaction);
                    faction.Name = "IlluminateFactionName".Translate() + ": #" + a.ToString();
                    faction.SetRelationDirect(Faction.OfPlayer, FactionRelationKind.Ally);
                    newFactions.Add(faction);
                }
                DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable <Thing>)thingList);
                ChoiceLetter choiceLetter = LetterMaker.MakeLetter("IlluminateAirdrop".Translate(), "AirdropEventDesc".Translate(), AvaliMod.AvaliDefs.IlluminateAirdrop, newFactions[random.Next(newFactions.Count)]);
                Find.LetterStack.ReceiveLetter(choiceLetter, null);
            }
        }
Exemplo n.º 8
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map   = (Map)parms.target;
            Thing        item  = ThingMaker.MakeThing(ThingDef.Named("Apparel_Pants"), ThingDefOf.Hyperweave);
            Thing        item2 = ThingMaker.MakeThing(ThingDef.Named("Apparel_BasicShirt"), ThingDefOf.Hyperweave);
            Thing        item3 = ThingMaker.MakeThing(ThingDef.Named("Apparel_Jacket"), ThingDefOf.Hyperweave);
            Thing        item4 = ThingMaker.MakeThing(ThingDef.Named("Apparel_Tuque"), ThingDefOf.Hyperweave);
            Thing        item5 = ThingMaker.MakeThing(ThingDef.Named("MealSurvivalPack"), null);
            Thing        item6 = ThingMaker.MakeThing(ThingDef.Named("MealSurvivalPack"), null);
            Thing        item7 = ThingMaker.MakeThing(ThingDef.Named("MealSurvivalPack"), null);
            Thing        item8 = ThingMaker.MakeThing(ThingDef.Named("MealSurvivalPack"), null);
            Thing        item9 = ThingMaker.MakeThing(ThingDef.Named("Gun_Autopistol"), null);
            List <Thing> list  = new List <Thing>();

            list.Add(item);
            list.Add(item2);
            list.Add(item3);
            list.Add(item4);
            list.Add(item5);
            list.Add(item6);
            list.Add(item7);
            list.Add(item8);
            list.Add(item9);
            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, list, 110, false, false, true);
            Find.LetterStack.ReceiveLetter("MO_SurvivalPods".Translate(), "MO_SurvivalPodsDesc".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);             //"A cluster of survival pods landed nearby, you will find some essential surviving items in there."
            return(true);
        }
        private void HostileDefeated()
        {
            // Killed all hostiles - Win outcome
            if (!GenHostility.AnyHostileActiveThreatTo(((MapParent)parent).Map, Faction.OfPlayer))
            {
                active = false;
                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, rewards, 110, false, true, true);
                parent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, +15, false, true);

                if (!Find.WorldObjects.Settlements.Where(s => s.Faction == enemy && !s.Faction.def.hidden && Find.WorldReachability.CanReach(Find.AnyPlayerHomeMap.Tile, s.Tile)).TryRandomElement(out Settlement enemySet))
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelOutpostdefensesuccess".Translate(), TranslatorFormattedStringExtensions.Translate("Outpostdefensesuccess", parent.Faction.leader, parent.Faction.def.leaderTitle, GenLabel.ThingsLabel(rewards, string.Empty)), EndGameDefOf.FE_JointRaid.letterDef, null, parent.Faction, null);
                    active = false;
                    return;
                }

                List <Thing> rewardsNew = ThingSetMakerDefOf.Reward_StandardByDropPod.root.Generate(new ThingSetMakerParams()
                {
                    totalMarketValueRange = new FloatRange?(SiteTuning.BanditCampQuestRewardMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(StorytellerUtility.DefaultSiteThreatPointsNow() + 500f))
                });

                Thing silver = ThingMaker.MakeThing(ThingDefOf.Silver);
                silver.stackCount = (int)FE_IncidentWorker_Jointraid.SilverBonusRewardCurve.Evaluate(parent.Faction.PlayerGoodwill);

                int random = new IntRange(Global.DayInTicks * 15, Global.DayInTicks * 25).RandomInRange;
                enemySet.GetComponent <WorldComp_JointRaid>().StartComp(random, parent.Faction, rewardsNew, silver);
                string text = TranslatorFormattedStringExtensions.Translate("OutpostdefensesuccessJointRaid", parent.Faction.leader, parent.Faction.def.leaderTitle, GenLabel.ThingsLabel(rewardsNew, string.Empty), random.ToStringTicksToPeriod(), GenThing.GetMarketValue(rewards).ToStringMoney(null), silver.stackCount.ToString(), GenLabel.ThingsLabel(rewards, string.Empty)).CapitalizeFirst();
                GenThing.TryAppendSingleRewardInfo(ref text, rewards);
                Find.LetterStack.ReceiveLetter(EndGameDefOf.FE_JointRaid.letterLabel, text, EndGameDefOf.FE_JointRaid.letterDef, enemySet, parent.Faction, null);
            }
        }
        public 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);
            Thing    thing  = ThingMaker.MakeThing(shipPartDef);
            Building building_CrashedShipPart = (Building)thing;
            CompPawnSpawnerOnDamaged damaged  = building_CrashedShipPart.TryGetCompFast <CompPawnSpawnerOnDamaged>();

            thing.SetFaction(faction, null);
            List <Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = faction,
                points    = points
            }).ToList();

            LordMaker.MakeNewLord(faction, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                thing
            }, faction, 28f, intVec, canAssaultColony: false, isMechCluster: false), map, list2);
            DropPodUtility.DropThingsNear(intVec, map, list2.Cast <Thing>());
            foreach (Pawn item in list2)
            {
                item.TryGetCompFast <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);
                }
                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));
            }
        }
Exemplo n.º 11
0
        public override void OnResult(Quest quest)
        {
            var map = quest.HomeMap;
            var pos = QuestUtility.FindDropSpot(map);

            DropPodUtility.DropThingsNear(pos, map, things, canRoofPunch: false);
            Messages.Message("QuestReceived".Translate().Formatted(Label), new LookTargets(pos, map), MessageTypeDefOf.PositiveEvent);
        }
        private void GiveRewardsAndSendLetter(bool giveTech, bool newFaction)
        {
            string text  = "RD_GratefulSurvivors".Translate();
            string text2 = "RD_GratefulSurvivorsDesc".Translate();             //"The survivors of the crash are very thankful for your help, and have send some supplies as a gesture of gratitude.";

            if (giveTech)
            {
                ThingDef.Named("Gun_ChargeRifle");
                ThingDef thingDef = this.RandomHiTechReward();
                ThingDef stuff    = null;
                if (thingDef.MadeFromStuff)
                {
                    stuff = GenStuff.DefaultStuffFor(thingDef);
                }
                this.rewards.TryAdd(ThingMaker.MakeThing(thingDef, stuff), true);
                text2 = "RD_GratefulSurvivorsAmazedDesc".Translate();                 //"The survivors of the crash are amazed by your rapid and professional emergency medical response, thanks to which no-one died. In gratitude, they have included a special system removed form the wreck.";
            }
            Find.LetterStack.ReceiveLetter(text, text2, LetterDefOf.PositiveEvent, null);
            Map map = Find.AnyPlayerHomeMap ?? ((MapParent)this.parent).Map;

            QuestComp_MedicalEmergency.tmpRewards.AddRange(this.rewards);
            this.rewards.Clear();
            IntVec3 dropCenter = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(dropCenter, map, QuestComp_MedicalEmergency.tmpRewards, 110, false, false, true);
            QuestComp_MedicalEmergency.tmpRewards.Clear();
            if (newFaction)
            {
                int tile = this.parent.Tile;
                this.CloseMapImmediate();

                Faction faction = FactionGenerator.NewGeneratedFaction(FactionDefOf.Ancients);
                map.pawnDestinationReservationManager.GetPawnDestinationSetFor(faction);
                Find.FactionManager.Add(faction);
                Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement);
                settlement.SetFaction(faction);
                settlement.Tile = tile;
                settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null);
                Find.WorldObjects.Add(settlement);
                faction.leader = null;
                foreach (Pawn pawn in this.injured)
                {
                    if (!pawn.Dead && pawn.Faction != Faction.OfPlayer)
                    {
                        pawn.SetFactionDirect(faction);
                        if (faction.leader == null)
                        {
                            faction.leader = pawn;
                        }
                    }
                }
                faction.TryAffectGoodwillWith(Faction.OfPlayer, 100);
                string text3 = "RD_NewFaction".Translate();                    //New Faction!
                string text4 = "RD_NewFactionDesc".Translate() + faction.Name; //"The survivors of the crash have decided to make a life for themselves here, and have founded a new faction"
                Find.LetterStack.ReceiveLetter(text3, text4, LetterDefOf.PositiveEvent, null);
            }
        }
Exemplo n.º 13
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map      = (Map)parms.target;
            Faction faction  = Find.FactionManager.RandomNonHostileFaction(true, true, true, TechLevel.Neolithic);
            Faction faction2 = Find.FactionManager.FirstFactionOfDef(FactionDefOf.PlayerColony);
            int     freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;
            bool    flag = !FactionUtility.HostileTo(faction, faction2) && map.resourceCounter.TotalHumanEdibleNutrition < 4f * (float)freeColonistsSpawnedCount;
            bool    result;

            if (flag)
            {
                Thing        thing  = ThingMaker.MakeThing(ThingDef.Named("MealSimple"), null);
                Thing        thing2 = ThingMaker.MakeThing(ThingDef.Named("MealFine"), null);
                Thing        thing3 = ThingMaker.MakeThing(ThingDef.Named("MealSimple"), null);
                Thing        thing4 = ThingMaker.MakeThing(ThingDef.Named("MealFine"), null);
                List <Thing> list   = new List <Thing>();
                int          num    = Rand.Range(20, 40);
                bool         flag2  = num > thing.def.stackLimit;
                if (flag2)
                {
                    num = thing.def.stackLimit;
                }
                bool flag3 = num == 0;
                if (flag3)
                {
                    num = 1;
                }
                int  num2  = Rand.Range(20, 40);
                bool flag4 = num2 > thing2.def.stackLimit;
                if (flag4)
                {
                    num2 = thing2.def.stackLimit;
                }
                bool flag5 = num2 == 0;
                if (flag5)
                {
                    num2 = 1;
                }
                thing.stackCount  = num;
                thing2.stackCount = num2;
                thing3.stackCount = num;
                thing4.stackCount = num2;
                list.Add(thing);
                list.Add(thing2);
                list.Add(thing3);
                list.Add(thing4);
                IntVec3 intVec = DropCellFinder.RandomDropSpot(map);
                DropPodUtility.DropThingsNear(intVec, map, list, 110, false, false, true);
                Find.LetterStack.ReceiveLetter("MO_Thanksgiving".Translate(), "MO_ThanksgivingDesc".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);                  //"One of the tribes has noticed your food stores are low. They have provided you with some food, no strings attached.\n\nThey thank you for being such good friends and they hope your friendship will be further cemented by this act."
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        private void CapsuleDelivery()
        {
            Map map = Find.AnyPlayerHomeMap;

            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, Items, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);

            Find.LetterStack.ReceiveLetter("DeliveryItems_Title".Translate(), "DeliveryItems_Desc".Translate(), LetterDefOf.PositiveEvent, new LookTargets(intVec, map));
        }
        private void DropSupplies(ThingDef thingDef, int count, IntVec3 cell)
        {
            List <Thing> list  = new List <Thing>();
            Thing        thing = ThingMaker.MakeThing(thingDef, null);

            thing.stackCount = count;
            list.Add(thing);

            //If turrets are near-empty or empty, call in ammo droppod
            DropPodUtility.DropThingsNear(cell, parent.Map, list, 110, false, false, true, true);
        }
Exemplo n.º 16
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = DefDatabase <ThingSetMakerDef> .GetNamed("RB_BeeResourcePod").root.Generate();

            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, things, 110, false, true, true, true);
            base.SendStandardLetter("RB_LetterLabelBeeCargoPodCrash".Translate(), "RB_BeeCargoPodCrash".Translate(), LetterDefOf.PositiveEvent, parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>());
            return(true);
        }
Exemplo n.º 17
0
        public override void EndVote()
        {
            Map map = Helper.AnyPlayerMap;

            Find.WindowStack.TryRemove(typeof(VoteWindow));
            Messages.Message(new Message("Chat voted for: " + VoteKeyLabel(DecideWinner()), MessageTypeDefOf.PositiveEvent), true);
            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, thingsOptions[DecideWinner()], 110, false, true, true);
            Find.LetterStack.ReceiveLetter("LetterLabelCargoPodCrash".Translate(), "CargoPodCrash".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null, null);
        }
Exemplo n.º 18
0
        private void GiveRewardsAndSendLetter()
        {
            Map map = Find.AnyPlayerHomeMap ?? ((MapParent)base.parent).Map;

            DefeatAllEnemiesQuestComp.tmpRewards.AddRange(this.rewards);
            this.rewards.Clear();
            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, DefeatAllEnemiesQuestComp.tmpRewards, 110, false, false, true, false);
            DefeatAllEnemiesQuestComp.tmpRewards.Clear();
            Find.LetterStack.ReceiveLetter("LetterLabelDefeatAllEnemiesQuestCompleted".Translate(), "LetterDefeatAllEnemiesQuestCompleted".Translate(this.requestingFaction.Name, this.relationsImprovement.ToString("F0")), LetterDefOf.PositiveEvent, new GlobalTargetInfo(intVec, map, false), null);
        }
Exemplo n.º 19
0
        public override void OnResult(Quest quest)
        {
            var map = quest.HomeMap;
            var pos = QuestUtility.FindDropSpot(map);

            DropPodUtility.DropThingsNear(pos, map, things, canRoofPunch: false);
            Find.LetterStack.ReceiveLetter(
                "QuestReceivedLabel".Translate(),
                "QuestReceived".Translate().Formatted(Label),
                LetterDefOf.NeutralEvent,
                new LookTargets(pos, map));
        }
Exemplo n.º 20
0
        public virtual void GiveRewards(Caravan caravan)
        {
            if (Rewards == null || Rewards.Count == 0)
            {
                return;
            }

            Map     map    = Find.AnyPlayerHomeMap;
            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(intVec, map, Rewards, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);
        }
Exemplo n.º 21
0
        private void DropItems(List <Thing> items, Map map)
        {
            IntVec3 dropCell = DropCellFinder.TradeDropSpot(map);

            DropPodUtility.DropThingsNear(dropCell, map, items, 110, canInstaDropDuringInit: false, leaveSlag: false, canRoofPunch: false);

            Letter letter = LetterGetter();

            letter.lookTargets = new LookTargets(dropCell, map);

            Find.LetterStack.ReceiveLetter(LetterGetter());
        }
Exemplo n.º 22
0
        public override void OnEndReceiver(RealmData realmData)
        {
            // Double check to ensure it wasn't bypassed by the sender
            if (!receiver.preferences.receiveItems)
            {
                state = TransactionResponse.DECLINED;
            }

            if (state == TransactionResponse.ACCEPTED)
            {
                // We spawn the new items !
                List <Thing> thingsToSpawn = new List <Thing>();
                foreach (KeyValuePair <RealmThing, int> entry in realmThings)
                {
                    RealmThing realmThing  = entry.Key;
                    Thing      thing       = realmData.FromRealmThing(realmThing);
                    int        leftToSpawn = entry.Value;
                    // We make new things until we create everything
                    // For example, if 180 granites blocks are sent (can be stacked by 75), we
                    // will create 3 Thing (2 full and 1 semi-full)
                    while (leftToSpawn > 0)
                    {
                        realmThing.stackCount = Math.Min(leftToSpawn, thing.def.stackLimit);

                        thingsToSpawn.Add(realmData.FromRealmThing(realmThing));

                        leftToSpawn -= realmThing.stackCount;
                    }
                }

                // We spawn the said item
                IntVec3 position = DropCellFinder.RandomDropSpot(Find.VisibleMap);
                DropPodUtility.DropThingsNear(position, Find.VisibleMap, thingsToSpawn);

                Find.LetterStack.ReceiveLetter(
                    "Ship pod",
                    "A pod was sent from " + sender.name + " containing items",
                    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
            }
        }
Exemplo n.º 23
0
 protected override bool TryExecuteWorker(IncidentParms parms)
 {
     List<Thing> thingList = new List<Thing>();
     thingList.Add(ThingMaker.MakeThing(AvaliDefs.AvaliNanoForge));
     Map target = (Map)parms.target;
     IntVec3 intVec3 = DropCellFinder.TradeDropSpot(target);
     if (RimValiUtility.PawnOfRaceCount(Faction.OfPlayer, AvaliDefs.RimVali) >= 5 && !hasDropped)
     {
         hasDropped = true;
         DropPodUtility.DropThingsNear(intVec3, target, (IEnumerable<Thing>)thingList);
         this.SendStandardLetter("Illuminate Airdrop", "Illuminate Airdrop", AvaliDefs.IlluminateAirdrop,parms, (LookTargets)new TargetInfo(intVec3, target, false), (NamedArgument[])Array.Empty<NamedArgument>());
     }
     return true;
 }
        public static void createDropOfThings(List <Thing> things, string title, string desc, bool showMessage = true)
        {
            if (things.Count > 0)
            {
                var     currentMap = Find.CurrentMap;
                IntVec3 dropVector = DropCellFinder.TradeDropSpot(Find.CurrentMap);
                DropPodUtility.DropThingsNear(dropVector, currentMap, things);

                if (showMessage)
                {
                    string messageString = "RimConnectionPositiveDroppodMailBody".Translate("", title, desc);
                    AlertManager.ResourceDropNotification(messageString, dropVector);
                }
            }
        }
Exemplo n.º 25
0
 public void Notify_EatenPumkinPetes()
 {
     eatenPumkinPetesCounter += 1;
     if (eatenPumkinPetesCounter == 50)
     {
         eatenPumkinPetesCounter = 0;
         List <Thing>   things         = new List <Thing>();
         ThingWithComps thingWithComps = (ThingWithComps)ThingMaker.MakeThing(RWBYDefOf.Apparel_PumpkinPetes, GenStuff.RandomStuffFor(RWBYDefOf.Apparel_PumpkinPetes));
         thingWithComps.TryGetComp <CompQuality>().SetQuality((QualityCategory)Rand.RangeInclusive(0, 6), ArtGenerationContext.Colony);
         things.Add(thingWithComps);
         IntVec3 intVec = DropCellFinder.RandomDropSpot(AbilityUser.Map);
         DropPodUtility.DropThingsNear(intVec, AbilityUser.Map, things, 110, false, false, false);
         Find.LetterStack.ReceiveLetter("LetterLabelPumpkinPetePodCrash".Translate(), "LetterTextPumpkinPetePodCrash".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec, AbilityUser.Map, false), null, null);
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Tries to execute the worker.
        /// </summary>
        /// <param name="parms">The parms.</param>
        /// <returns></returns>
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var      map             = (Map)parms.target;
            var      targetInfoList  = new List <TargetInfo>();
            ThingDef shipPartDef     = def.mechClusterBuilding;
            IntVec3  dropPodLocation = MechClusterUtility.FindDropPodLocation(map, spot =>
            {
                if (!spot.Fogged(map) && GenConstruct.CanBuildOnTerrain(shipPartDef, spot, map, Rot4.North))
                {
                    return(GenConstruct.CanBuildOnTerrain(shipPartDef,
                                                          new IntVec3(spot.x - Mathf.CeilToInt(shipPartDef.size.x / 2f), spot.y,
                                                                      spot.z), map, Rot4.North));
                }
                return(false);
            });

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

            innerThing.SetFaction(Faction.OfMechanoids);
            LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                innerThing
            }, Faction.OfMechanoids, 28f, dropPodLocation, false, false), map, list);
            DropPodUtility.DropThingsNear(dropPodLocation, map, list);
            foreach (Thing thing in list)
            {
                thing.TryGetComp <CompCanBeDormant>()?.ToSleep();
            }
            targetInfoList.AddRange(list.Select(p => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(PMThingDefOf.CrashedMutagenicShipPartIncoming, innerThing), dropPodLocation, map);
            targetInfoList.Add(new TargetInfo(dropPodLocation, map));
            SendStandardLetter(parms, targetInfoList, Array.Empty <NamedArgument>());
            return(true);
        }
Exemplo n.º 27
0
        public override void CompTick()
        {
            if (!active)
            {
                return;
            }

            if (!((MapParent)parent).HasMap)
            {
                if (timer <= Find.TickManager.TicksGame)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelJointRaidFail".Translate(), TranslatorFormattedStringExtensions.Translate("JointRaidFail", ally.leader, parent, parent.Faction, ally.def.leaderTitle)
                                                   , LetterDefOf.NegativeEvent, null, ally);
                    active = false;
                }
                if (parent.GetComponent <EnterCooldownComp>().Active)
                {
                    active = false;
                    if (Bonus.stackCount > 0)
                    {
                        ally.TryAffectGoodwillWith(Faction.OfPlayer, -25);
                        Find.LetterStack.ReceiveLetter("LetterLabelJointRaidAbandoned".Translate(), TranslatorFormattedStringExtensions.Translate("JointRaidAbandoned", ally.def.leaderTitle, ally.leader), LetterDefOf.NegativeEvent);
                    }
                }
                return;
            }
            else
            {
                if (FriendliesDefeated)
                {
                    Bonus.stackCount = 0;
                }
                if (!EnemiesDefeated)
                {
                    return;
                }
                if (Bonus.stackCount > 0)
                {
                    rewards.Add(Bonus);
                }

                DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(Find.AnyPlayerHomeMap), Find.AnyPlayerHomeMap, rewards, 110, false, true, true);

                Find.LetterStack.ReceiveLetter("LetterLabelJointRaidSuccess".Translate(), TranslatorFormattedStringExtensions.Translate("JointRaidSuccess", ally.leader) + GenLabel.ThingsLabel(rewards, string.Empty) + (Bonus.stackCount > 0 ? "\n\n" + TranslatorFormattedStringExtensions.Translate("JointRaidSuccessBonus", ally.leader) : "")
                                               , LetterDefOf.PositiveEvent, null, ally, null);
                active = false;
            }
        }
Exemplo n.º 28
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map target = (Map)parms.target;

            if (!TryFindFactions(out Faction faction) || !TryFindStravingPawns(out IEnumerable <Pawn> enumerableFood, target) || !TryFindInjuredPawns(out IEnumerable <Pawn> enumerableInjured, target))
            {
                return(false);
            }

            List <Thing> thingList = GenerateRewards(faction, enumerableFood.Count(), enumerableInjured.Count(), parms);

            DropPodUtility.DropThingsNear(DropCellFinder.TradeDropSpot(target), target, thingList, 110, false, true, true);
            Find.LetterStack.ReceiveLetter("FFE_LetterLabelAid".Translate(), "FFE_Aid".Translate(faction.leader, faction.def.leaderTitle, faction, GenLabel.ThingsLabel(thingList, string.Empty))
                                           , LetterDefOf.PositiveEvent, new TargetInfo(DropCellFinder.TradeDropSpot(target), target, false), faction, null);
            return(true);
        }
Exemplo n.º 29
0
        protected override bool TryCastShot()
        {
            if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map)
            {
                return(false);
            }
            Map     target  = caster.Map;
            IntVec3 intVec3 = currentTarget.Cell;

            DropPodUtility.DropThingsNear(intVec3, target, _emergencyResourcesList, 110, false, true);
            if (EquipmentSource != null && !EquipmentSource.Destroyed)
            {
                EquipmentSource.Destroy();
            }
            return(true);
        }
        /// <summary>
        ///     Tries to execute the worker.
        /// </summary>
        /// <param name="parms">The parms.</param>
        /// <returns></returns>
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var      map         = (Map)parms.target;
            var      list        = new List <TargetInfo>();
            ThingDef shipPartDef = def.mechClusterBuilding;
            IntVec3  intVec      = FindDropPodLocation(map, CanPlaceAt);

            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, false, false), map, list2);
            DropPodUtility.DropThingsNear(intVec, map, list2);
            foreach (Pawn item in list2)
            {
                item.TryGetComp <CompCanBeDormant>()?.ToSleep();
            }
            list.AddRange(list2.Select(p => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(PMThingDefOf.CrashedMutagenicShipPartIncoming, thing), intVec, map);
            list.Add(new TargetInfo(intVec, map));
            SendStandardLetter(parms, list);
            return(true);

            bool CanPlaceAt(IntVec3 loc)
            {
                if (loc.Fogged(map) || !GenAdj.OccupiedRect(loc, Rot4.North, shipPartDef.Size).InBounds(map))
                {
                    return(false);
                }
                return(GenConstruct.CanBuildOnTerrain(shipPartDef, loc, map, Rot4.North));
            }
        }