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); }
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)); } } }
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)); } }
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 = 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); }
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); } }
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); } }
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); }
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); } }
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); } }
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); } } }
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); } } }
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); } } }
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); }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (!(signal.tag == inSignal)) { return; } pawns.RemoveAll((Pawn x) => x.Destroyed); items.RemoveAll((Thing x) => x.Destroyed); Thing thing = Things.Where((Thing x) => x is Pawn).MaxByWithFallback((Thing x) => x.MarketValue); Thing thing2 = Things.MaxByWithFallback((Thing x) => x.MarketValue * (float)x.stackCount); if (mapParent != null && mapParent.HasMap && Things.Any()) { Map map = mapParent.Map; IntVec3 intVec = (dropSpot.IsValid ? dropSpot : GetRandomDropSpot()); if (sendStandardLetter) { TaggedString title; TaggedString text; if (joinPlayer && pawns.Count == 1 && pawns[0].RaceProps.Humanlike) { text = "LetterRefugeeJoins".Translate(pawns[0].Named("PAWN")); title = "LetterLabelRefugeeJoins".Translate(pawns[0].Named("PAWN")); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawns[0]); } else { text = "LetterQuestDropPodsArrived".Translate(GenLabel.ThingsLabel(Things)); title = "LetterLabelQuestDropPodsArrived".Translate(); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref title, ref text, "LetterRelatedPawnsNeutralGroup".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); } title = (customLetterLabel.NullOrEmpty() ? title : customLetterLabel.Formatted(title.Named("BASELABEL"))); text = (customLetterText.NullOrEmpty() ? text : customLetterText.Formatted(text.Named("BASETEXT"))); Find.LetterStack.ReceiveLetter(title, text, customLetterDef ?? LetterDefOf.PositiveEvent, new TargetInfo(intVec, map), null, quest); } if (joinPlayer) { for (int i = 0; i < pawns.Count; i++) { if (pawns[i].Faction != Faction.OfPlayer) { pawns[i].SetFaction(Faction.OfPlayer); } } } else if (makePrisoners) { for (int j = 0; j < pawns.Count; j++) { if (pawns[j].RaceProps.Humanlike) { if (!pawns[j].IsPrisonerOfColony) { pawns[j].guest.SetGuestStatus(Faction.OfPlayer, prisoner: true); } HealthUtility.TryAnesthetize(pawns[j]); } } } for (int k = 0; k < pawns.Count; k++) { pawns[k].needs.SetInitialLevels(); } DropPodUtility.DropThingsNear(intVec, map, Things, 110, canInstaDropDuringInit: false, leaveSlag: false, !useTradeDropSpot, forbid: false); importantLookTarget = items.Find((Thing x) => x.GetInnerIfMinified() is MonumentMarker).GetInnerIfMinified(); items.Clear(); } if (!outSignalResult.NullOrEmpty()) { if (thing != null) { Find.SignalManager.SendSignal(new Signal(outSignalResult, thing.Named("SUBJECT"))); } else if (thing2 != null) { Find.SignalManager.SendSignal(new Signal(outSignalResult, thing2.Named("SUBJECT"))); } else { Find.SignalManager.SendSignal(new Signal(outSignalResult)); } } }
public static void DropInDropPodsNearSpawnCenter(IncidentParms parms, List <Pawn> pawns) { Map map = (Map)parms.target; DropPodUtility.DropThingsNear(parms.spawnCenter, map, pawns.Cast <Thing>(), parms.podOpenDelay, canInstaDropDuringInit: false, leaveSlag: true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; this.ResolveRaidPoints(parms); if (!this.TryResolveRaidFaction(parms)) { return(false); } this.ResolveRaidStrategy(parms); this.ResolveRaidArriveMode(parms); if (!this.ResolveRaidSpawnCenter(parms)) { return(false); } IncidentParmsUtility.AdjustPointsForGroupArrivalParams(parms); PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(parms, false); List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(PawnGroupKindDefOf.Normal, defaultPawnGroupMakerParms, true).ToList(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); return(false); } TargetInfo target = TargetInfo.Invalid; if (parms.raidArrivalMode == PawnsArriveMode.CenterDrop || parms.raidArrivalMode == PawnsArriveMode.EdgeDrop) { DropPodUtility.DropThingsNear(parms.spawnCenter, map, list.Cast <Thing>(), parms.raidPodOpenDelay, false, true, true, false); target = new TargetInfo(parms.spawnCenter, map, false); } else { foreach (Pawn item in list) { IntVec3 loc = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, map, 8, null); GenSpawn.Spawn(item, loc, map, parms.spawnRotation, false); target = item; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Points = " + parms.points.ToString("F0")); foreach (Pawn item2 in list) { string str = (item2.equipment == null || item2.equipment.Primary == null) ? "unarmed" : item2.equipment.Primary.LabelCap; stringBuilder.AppendLine(item2.KindLabel + " - " + str); } string letterLabel = this.GetLetterLabel(parms); string letterText = this.GetLetterText(parms, list); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, this.GetRelatedPawnsInfoLetterText(parms), true, true); Find.LetterStack.ReceiveLetter(letterLabel, letterText, this.GetLetterDef(), target, stringBuilder.ToString()); if (this.GetLetterDef() == LetterDefOf.ThreatBig) { TaleRecorder.RecordTale(TaleDefOf.RaidArrived); } Lord lord = LordMaker.MakeNewLord(parms.faction, parms.raidStrategy.Worker.MakeLordJob(parms, map), map, list); AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction, map); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts)) { for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; if (pawn.apparel.WornApparel.Any((Apparel ap) => ap is ShieldBelt)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical); break; } } } if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer)) { Log.Message("Market value threshold to start stealing: " + StealAIUtility.StartStealingMarketValueThreshold(lord) + " (colony wealth = " + map.wealthWatcher.WealthTotal + ")"); } return(true); }