protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate(); IntVec3 intVec = DropCellFinder.RandomDropSpot(map); Pawn pawn = ThingUtility.FindPawn(things); pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true; TaggedString title = "LetterLabelRefugeePodCrash".Translate(); TaggedString text = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); text += "\n\n"; if (pawn.Faction == null) { text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } else if (pawn.Faction.HostileTo(Faction.OfPlayer)) { text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } else { text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn); SendStandardLetter(title, text, LetterDefOf.NeutralEvent, parms, new TargetInfo(intVec, map)); ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things); activeDropPodInfo.openDelay = 180; activeDropPodInfo.leaveSlag = true; DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo); return(true); }
// Token: 0x06000EB1 RID: 3761 RVA: 0x0006D5F4 File Offset: 0x0006B9F4 protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate(); IntVec3 intVec = DropCellFinder.RandomDropSpot(map); Pawn pawn = this.FindPawn(things); pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true; pawn.health.AddHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation); string label = "LetterLabelRefugeePodCrash".Translate(); string text = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN"); text += "\n\n"; if (pawn.Faction == null) { text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN"); } else if (pawn.Faction.HostileTo(Faction.OfPlayer)) { text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN"); } else { text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN"); } PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null); ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false); activeDropPodInfo.openDelay = 180; activeDropPodInfo.leaveSlag = true; DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo); return(true); }
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)); } } }
private TunnelHiveLikeSpawner SpawnTunnelLikeCluster(int hiveCount, Map map) { IntVec3 loc = DropCellFinder.RandomDropSpot(map); ThingDef_HiveLike tD = (ThingDef_HiveLike)this.def.shipPart; ThingDef_TunnelHiveLikeSpawner thingDef = (ThingDef_TunnelHiveLikeSpawner)tD.TunnelDef; TunnelHiveLikeSpawner hivelike = (TunnelHiveLikeSpawner)ThingMaker.MakeThing(thingDef, null); GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.def, null), loc, map); //hivelike.SetFaction(hivelike.faction, null); IncidentWorker_Hivelike.SpawnItemInstantly(hivelike); for (int i = 0; i < hiveCount - 1; i++) { TunnelHiveLikeSpawner hivelike2; CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>(); if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(true, out hivelike2)) { IncidentWorker_Hivelike.SpawnItemInstantly(hivelike2); hivelike = hivelike2; //Log.Message(string.Format("7 e")); } //Log.Message(string.Format("7 f")); } //Log.Message(string.Format("8")); return(hivelike); }
public static bool TryFindRaidDropCenterClose(out IntVec3 spot, Map map) { Faction faction = map.ParentFaction ?? Faction.OfPlayer; int num = 0; while (true) { IntVec3 root = IntVec3.Invalid; if (map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).Count <Pawn>() > 0) { root = map.mapPawns.FreeHumanlikesSpawnedOfFaction(faction).RandomElement <Pawn>().Position; } else { if (faction == Faction.OfPlayer) { List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist; for (int i = 0; i < allBuildingsColonist.Count; i++) { if (DropCellFinder.TryFindDropSpotNear(allBuildingsColonist[i].Position, map, out root, true, true)) { break; } } } else { List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial); for (int j = 0; j < list.Count; j++) { if (list[j].Faction == faction && DropCellFinder.TryFindDropSpotNear(list[j].Position, map, out root, true, true)) { break; } } } if (!root.IsValid) { root = DropCellFinder.RandomDropSpot(map); } } spot = CellFinder.RandomClosewalkCellNear(root, map, 10, null); if (DropCellFinder.CanPhysicallyDropInto(spot, map, true)) { break; } num++; if (num > 300) { goto Block_9; } } return(true); Block_9: spot = CellFinderLoose.RandomCellWith((IntVec3 c) => DropCellFinder.CanPhysicallyDropInto(c, map, true), map, 1000); return(false); }
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); }
// Token: 0x060015AA RID: 5546 RVA: 0x000A92C8 File Offset: 0x000A76C8 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); DropThroughRoofUtility.DropThingsNear(dropCenter, map, Gen.YieldSingle <Thing>(pawns[i]), parms.podOpenDelay, true, 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; 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); } }
public override void SpawnJoiner(Map map, Pawn pawn) { IntVec3 c = DropCellFinder.RandomDropSpot(map); ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAddOrTransfer(pawn); activeDropPodInfo.openDelay = 180; activeDropPodInfo.leaveSlag = true; DropPodUtility.MakeDropPodAt(c, map, activeDropPodInfo); }
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 AssignDebugData() { base.AssignDebugData(); inSignal = "DebugSignal" + Rand.Int; if (Find.AnyPlayerHomeMap != null) { Map randomPlayerHomeMap = Find.RandomPlayerHomeMap; IntVec3 center = DropCellFinder.RandomDropSpot(randomPlayerHomeMap); shuttle = ThingMaker.MakeThing(ThingDefOf.Shuttle); GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(ThingDefOf.ShuttleIncoming, shuttle), center, randomPlayerHomeMap, ThingPlaceMode.Near); } }
// Token: 0x06000E63 RID: 3683 RVA: 0x0006B874 File Offset: 0x00069C74 protected override bool CanFireNowSub(IncidentParms parms) { /* * Map map = (Map)parms.target; * IntVec3 intVec; * return base.CanFireNowSub(parms) && HiveLikeUtility.TotalSpawnedHiveLikesCount(map) < 30 && InfestationLikeCellFinder.TryFindCell(out intVec, map); */ Map map = (Map)parms.target; IntVec3 intVec = DropCellFinder.RandomDropSpot(map); return(base.CanFireNowSub(parms) && HiveLikeUtility.TotalSpawnedHiveLikesCount(map) < 100); }
private IntVec3 GetRandomDropSpot() { Map map = mapParent.Map; if (useTradeDropSpot) { return(DropCellFinder.TradeDropSpot(map)); } if (CellFinderLoose.TryGetRandomCellWith((IntVec3 x) => x.Standable(map) && !x.Roofed(map) && !x.Fogged(map) && map.reachability.CanReachColony(x), map, 1000, out var result)) { return(result); } return(DropCellFinder.RandomDropSpot(map)); }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (!(signal.tag == inSignal) || !MapParent.HasMap) { return; } IntVec3 result = IntVec3.Invalid; if (cell.IsValid) { result = cell; } else { if (tryLandInShipLandingZone && !DropCellFinder.TryFindShipLandingArea(MapParent.Map, out result, out var firstBlockingThing)) { if (firstBlockingThing != null) { Messages.Message("ShuttleBlocked".Translate("BlockedBy".Translate(firstBlockingThing).CapitalizeFirst()), firstBlockingThing, MessageTypeDefOf.NeutralEvent); } result = DropCellFinder.TryFindSafeLandingSpotCloseToColony(MapParent.Map, thing.def.Size, factionForFindingSpot); } if (!result.IsValid && tryLandNearThing != null) { DropCellFinder.FindSafeLandingSpotNearAvoidingHostiles(tryLandNearThing, MapParent.Map, out result, 35, 15, 25, thing.def.size); } if (!result.IsValid && (!lookForSafeSpot || !DropCellFinder.FindSafeLandingSpot(out result, factionForFindingSpot, MapParent.Map, 35, 15, 25, thing.def.size))) { IntVec3 intVec = DropCellFinder.RandomDropSpot(MapParent.Map); if (!DropCellFinder.TryFindDropSpotNear(intVec, MapParent.Map, out result, allowFogged: false, canRoofPunch: false, allowIndoors: false, thing.def.size)) { result = intVec; } } } GenPlace.TryPlaceThing(thing, result, MapParent.Map, ThingPlaceMode.Near); spawned = true; Skyfaller skyfaller = thing as Skyfaller; if (skyfaller != null && skyfaller.innerContainer.Count == 1) { innerSkyfallerThing = skyfaller.innerContainer.First(); } else { innerSkyfallerThing = null; } }
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 bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Thing> things = ItemCollectionGeneratorDefOf.RefugeePod.Worker.Generate(default(ItemCollectionGeneratorParams)); IntVec3 intVec = DropCellFinder.RandomDropSpot(map); Pawn pawn = this.FindPawn(things); string label = "LetterLabelRefugeePodCrash".Translate(); string text = "RefugeePodCrash".Translate(); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null); ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false); activeDropPodInfo.openDelay = 180; activeDropPodInfo.leaveSlag = true; DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, true); return(true); }
private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map) { ; IntVec3 loc = DropCellFinder.RandomDropSpot(map); ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.shipPart; HiveLike hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null); GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.OfTunnel, null), loc, map); hivelike.SetFaction(hivelike.OfFaction, null); IncidentWorker_Hivelike.SpawnItemInstantly(hivelike); for (int i = 0; i < hiveCount - 1; i++) { HiveLike hivelike2; CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>(); if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(true, out hivelike2)) { IncidentWorker_Hivelike.SpawnItemInstantly(hivelike2); hivelike = hivelike2; } } return(hivelike); }
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); }