private void Ressurect() { if (resurrectSet && !ally.defeated) { Settlement resurrect = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); Faction faction = ally; resurrect.SetFaction(faction); resurrect.Tile = parent.Tile; resurrect.creationGameTicks = parent.creationGameTicks; resurrect.Name = SettlementNameGenerator.GenerateSettlementName(resurrect); Find.WorldObjects.AllWorldObjects.Add(resurrect); Utilities.FactionsWar().GetByFaction(resurrect.Faction).resources += FE_WorldComp_FactionsWar.SETTLEMENT_RESOURCE_VALUE; } }
public void DoAction(Caravan caravan) { RandomPlaceWorldObject obj = (RandomPlaceWorldObject)WorldObjectMaker.MakeWorldObject(WorldObjectsDefOfLocal.RandomPlace); obj.Tile = caravan.Tile; obj.SetFaction(Faction); obj.RandomPlaceDef = RandomPlaceDef; Find.WorldObjects.Add(obj); LongEventHandler.QueueLongEvent(delegate { DoEnter(caravan, obj); }, "GeneratingMapForNewEncounter", doAsynchronously: false, null); }
public override void PreMapGenerate() { var defaultSettlement = Find.WorldObjects.MapParentAt(Find.GameInitData.startingTile); Find.WorldObjects.Remove(defaultSettlement); var city = (City)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed(GetObjectDefName())); city.SetFaction(Find.GameInitData.playerFaction); city.inhabitantFaction = GenCity.RandomCityFaction(IsValidFaction); city.Tile = Find.GameInitData.startingTile; city.Name = city.ChooseName(); Find.WorldObjects.Add(city); }
private void GroupLeftMap() { if (this.destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile); this.Destroy(DestroyMode.Vanish); return; } TravelingShips travelingShips = (TravelingShips)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.TravelingSuborbitalShip); travelingShips.Tile = base.Map.Tile; travelingShips.SetFaction(this.Faction); travelingShips.destinationTile = this.destinationTile; travelingShips.destinationCell = this.destinationCell; travelingShips.arriveMode = this.pawnArriveMode; travelingShips.arrivalAction = this.arrivalAction; Find.WorldObjects.Add(travelingShips); Predicate <Thing> predicate = delegate(Thing t) { if (t != this) { if (t is ShipBase_Traveling) { ShipBase_Traveling ship = (ShipBase_Traveling)t; if (ship.containingShip.shipState == ShipState.Outgoing) { return(true); } } } return(false); }; List <Thing> tmpleavingShips = base.Map.listerThings.AllThings.FindAll(x => predicate(x)); for (int i = 0; i < tmpleavingShips.Count; i++) { ShipBase_Traveling dropPodLeaving = tmpleavingShips[i] as ShipBase_Traveling; if (dropPodLeaving != null && dropPodLeaving.fleetID == this.fleetID) { dropPodLeaving.alreadyLeft = true; travelingShips.AddShip(dropPodLeaving.containingShip, true); dropPodLeaving.Destroy(DestroyMode.Vanish); } } travelingShips.AddShip(this.containingShip, true); travelingShips.SetFaction(this.containingShip.Faction); this.Destroy(DestroyMode.Vanish); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!settings.Active) { return(false); } Faction faction = GetFaction(); List <Settlement> factionBases = Find.WorldObjects.Settlements.Where(x => x.Faction == faction && CaravanArrivalTimeEstimator.EstimatedTicksToArrive(Find.AnyPlayerHomeMap.Tile, x.Tile, null).TicksToDays() < 7).ToList(); if (factionBases.Count == 0) { return(false); } Settlement factionBase = factionBases.RandomElement(); if (Find.WorldObjects.WorldObjectAt(factionBase.Tile, QuestRim.WorldObjectDefOfLocal.QuestPlace) != null) { return(false); } Quest_ThingsHelp quest = new Quest_ThingsHelp { id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(), Faction = faction }; float marketValue = GenerateRequestItems(quest, Find.AnyPlayerHomeMap); quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(marketValue * 1.3f, marketValue * 1.7f), new IntRange(3, 6), null, null); LookTargets target = new LookTargets(factionBase.Tile); quest.Target = target; quest.TicksToPass = Rand.Range(12, 25) * 60000; QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace); questPlace.Tile = factionBase.Tile; questPlace.SetFaction(faction); questPlace.Init(quest); quest.Site = questPlace; Find.WorldObjects.Add(questPlace); QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: def.description, lookTarget: target)); return(true); }
protected override void RunInt() { Slate slate = QuestGen.slate; WorldObject worldObject = WorldObjectMaker.MakeWorldObject(def.GetValue(slate)); worldObject.Tile = tile.GetValue(slate); if (faction.GetValue(slate) != null) { worldObject.SetFaction(faction.GetValue(slate)); } if (storeAs.GetValue(slate) != null) { QuestGen.slate.Set(storeAs.GetValue(slate), worldObject); } }
private static void SpawnRandomFactionBase() { if (Find.FactionManager.AllFactions.Where((Faction x) => !x.IsPlayer && !x.def.hidden).TryRandomElement(out Faction result)) { int num = GenWorld.MouseTile(); if (!Find.WorldGrid[num].biome.impassable) { Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(result); settlement.Tile = num; settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement); Find.WorldObjects.Add(settlement); } } }
protected override bool TryExecuteWorker(IncidentParms parms) { bool result; Faction faction; if ((from wo in Find.WorldObjects.AllWorldObjects where wo.def == SiteDefOfReconAndDiscovery.RD_AdventurePeaceTalks select wo).Count <WorldObject>() > 0) { result = false; } else if (!this.TryFindFaction(out faction, (Faction f) => f != Faction.OfPlayer && f.PlayerGoodwill < 0f && f.def.CanEverBeNonHostile && f.def.humanlikeFaction)) { result = false; } else { int tile; if (TileFinder.TryFindNewSiteTile(out tile)) { Site site = (Site)WorldObjectMaker.MakeWorldObject(SiteDefOfReconAndDiscovery.RD_AdventurePeaceTalks); site.Tile = tile; site.SetFaction(faction); site.AddPart(new SitePart(site, SiteDefOfReconAndDiscovery.RD_PeaceTalks, SiteDefOfReconAndDiscovery.RD_PeaceTalks.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, faction))); SitePart peaceTalksFaction = new SitePart(site, SiteDefOfReconAndDiscovery.RD_PeaceTalksFaction, SiteDefOfReconAndDiscovery.RD_PeaceTalksFaction.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, faction)); peaceTalksFaction.hidden = true; site.parts.Add(peaceTalksFaction); site.GetComponent <QuestComp_PeaceTalks>().StartQuest(faction); int num = 5; site.GetComponent <TimeoutComp>().StartTimeout(num * 60000); base.SendStandardLetter(parms, site, new NamedArgument[] { faction.leader.Label, faction.Name, num.ToString() }); Find.WorldObjects.Add(site); result = true; } else { result = false; } } return(result); }
private void GroupLeftMap() { if (this.groupID < 0) { Log.Error("Drop pod left the map, but its group ID is " + this.groupID); this.Destroy(DestroyMode.Vanish); return; } if (this.destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile); this.Destroy(DestroyMode.Vanish); return; } Lord lord = FindLord(this.groupID, base.Map); if (lord != null) { base.Map.lordManager.RemoveLord(lord); } PawnFlyersTraveling PawnFlyersTraveling = (PawnFlyersTraveling)WorldObjectMaker.MakeWorldObject(PawnFlyerDef.travelingDef); PawnFlyersTraveling.pawnFlyer = this.pawnFlyer; PawnFlyersTraveling.Tile = base.Map.Tile; PawnFlyersTraveling.destinationTile = this.destinationTile; PawnFlyersTraveling.destinationCell = this.destinationCell; PawnFlyersTraveling.arriveMode = this.arriveMode; PawnFlyersTraveling.attackOnArrival = this.attackOnArrival; Find.WorldObjects.Add(PawnFlyersTraveling); PawnFlyersLeaving.tmpActiveDropPods.Clear(); PawnFlyersLeaving.tmpActiveDropPods.AddRange(base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod)); for (int i = 0; i < PawnFlyersLeaving.tmpActiveDropPods.Count; i++) { PawnFlyersLeaving pawnFlyerLeaving = PawnFlyersLeaving.tmpActiveDropPods[i] as PawnFlyersLeaving; if (pawnFlyerLeaving != null && pawnFlyerLeaving.groupID == this.groupID) { Cthulhu.Utility.DebugReport("Transport Already Left"); pawnFlyerLeaving.alreadyLeft = true; PawnFlyersTraveling.AddPod(pawnFlyerLeaving.contents, true); pawnFlyerLeaving.contents = null; pawnFlyerLeaving.Destroy(DestroyMode.Vanish); } } }
protected override void LeaveMap() { if (this.alreadyLeft) { base.LeaveMap(); return; } if (this.groupID < 0) { Log.Error("Drop pod left the map, but its group ID is " + this.groupID); this.Destroy(DestroyMode.Vanish); return; } if (this.destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile); this.Destroy(DestroyMode.Vanish); return; } Lord lord = TransporterUtility.FindLord(this.groupID, base.Map); if (lord != null) { base.Map.lordManager.RemoveLord(lord); } TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.TravelingTransportPods); travelingTransportPods.Tile = base.Map.Tile; travelingTransportPods.SetFaction(Faction.OfPlayer); travelingTransportPods.destinationTile = this.destinationTile; travelingTransportPods.destinationCell = this.destinationCell; travelingTransportPods.arriveMode = this.arriveMode; travelingTransportPods.attackOnArrival = this.attackOnArrival; Find.WorldObjects.Add(travelingTransportPods); DropPodLeaving.tmpActiveDropPods.Clear(); DropPodLeaving.tmpActiveDropPods.AddRange(base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod)); for (int i = 0; i < DropPodLeaving.tmpActiveDropPods.Count; i++) { DropPodLeaving dropPodLeaving = DropPodLeaving.tmpActiveDropPods[i] as DropPodLeaving; if (dropPodLeaving != null && dropPodLeaving.groupID == this.groupID) { dropPodLeaving.alreadyLeft = true; travelingTransportPods.AddPod(dropPodLeaving.Contents, true); dropPodLeaving.Contents = null; dropPodLeaving.Destroy(DestroyMode.Vanish); } } }
// Verse.AI.ToilEffects public static CaravanToil WithProgressBar(this CaravanToil CaravanToil, TargetIndex ind, Func <float> progressGetter, bool interpolateBetweenActorAndTarget = false, float offsetZ = -0.5f) { WorldObject_ProgressBar progressBar = null; CaravanToil.AddPreTickAction(delegate { if (CaravanToil.actor.Faction != Faction.OfPlayer) { return; } var curProgress = Mathf.Clamp01(progressGetter()); //Log.Message(curProgress.ToString()); //WorldProgressBarDrawer.DrawProgressBarOnGUIFor(target, curProgress); if (progressBar == null) { progressBar = (WorldObject_ProgressBar)WorldObjectMaker.MakeWorldObject( DefDatabase <WorldObjectDef> .GetNamed("WorldObject_ProgressBar")); progressBar.Tile = Find.World.GetComponent <CaravanJobGiver>().CurJob(CaravanToil.actor) .GetTarget(ind).Tile; progressBar.offset = offsetZ; Find.WorldObjects.Add(progressBar); } else { progressBar.curProgress = Mathf.Clamp01(progressGetter()); if (CaravanToil.actor == null || !CaravanToil.actor.Spawned || CaravanToil.actor.Tile != Find.World.GetComponent <CaravanJobGiver>().CurJob(CaravanToil.actor) .GetTarget(ind).Tile) { if (progressBar.Spawned) { Find.WorldObjects.Remove(progressBar); } } } }); CaravanToil.AddFinishAction(delegate { if (progressBar != null && progressBar.Spawned) { Find.WorldObjects.Remove(progressBar); progressBar = null; } }); return(CaravanToil); }
public static void SpawnNewFactionBasesIntoWorld(Faction newFaction, int numOfBases) { if (newFaction == null) { return; } for (int k = 0; k < numOfBases; k++) { Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(newFaction); settlement.Tile = TileFinder.RandomSettlementTileFor(newFaction); settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement); Find.WorldObjects.Add(settlement); } }
private static void UpgradeSiteToSettlement(Site toUpgrade) { var factionBase = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); factionBase.SetFaction(toUpgrade.Faction); factionBase.Tile = toUpgrade.Tile; factionBase.Name = SettlementNameGenerator.GenerateSettlementName(factionBase); Find.WorldObjects.Remove(toUpgrade); Find.WorldObjects.Add(factionBase); Find.LetterStack.ReceiveLetter( "MFI_LetterLabelBanditOutpostUpgraded".Translate(), "MFI_LetterBanditOutpostUpgraded".Translate(factionBase.Faction.Name), LetterDefOf.NeutralEvent, factionBase, toUpgrade.Faction); }
private static void UpgradeSiteToSettlement(Site toUpgrade) { Settlement factionBase = (Settlement)WorldObjectMaker.MakeWorldObject(def: WorldObjectDefOf.Settlement); factionBase.SetFaction(newFaction: toUpgrade.Faction); factionBase.Tile = toUpgrade.Tile; factionBase.Name = SettlementNameGenerator.GenerateSettlementName(factionBase: factionBase); Find.WorldObjects.Remove(o: toUpgrade); Find.WorldObjects.Add(o: factionBase); Find.LetterStack.ReceiveLetter( label: "MFI_LetterLabelBanditOutpostUpgraded".Translate(), text: "MFI_LetterBanditOutpostUpgraded".Translate(factionBase.Faction.Name), textLetterDef: LetterDefOf.NeutralEvent, lookTargets: factionBase, relatedFaction: toUpgrade.Faction); }
static RealRuinsPOIWorldObject TryCreateWorldObject(int tile, Faction siteFaction) { Debug.Log("Creating site at tile: {0}", tile); if (Find.WorldObjects.AnyWorldObjectAt(tile)) { return(null); } RealRuinsPOIWorldObject site = (RealRuinsPOIWorldObject)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("RealRuinsPOI")); site.Tile = tile; site.SetFaction(siteFaction); Find.WorldObjects.Add(site); return(site); }
public void FixedUpdate() => beacons.ForEach(delegate(Building_BombardmentBeacon2 beacon) { if (beacon.Map == null && beacon.map != null) { if (beacon.check) { DestroyedSettlement destroyed = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement); destroyed.Tile = beacon.map.Tile; Find.WorldObjects.Add(destroyed); Settlement factionBase = (Settlement)beacon.map.info.parent; beacon.map.info.parent = destroyed; Find.WorldObjects.Remove(factionBase); beacon.map = null; } } });
public static Faction NewGeneratedFaction(FactionDef facDef) { Faction faction = new Faction(); faction.def = facDef; faction.loadID = Find.UniqueIDsManager.GetNextFactionID(); faction.colorFromSpectrum = NewRandomColorFromSpectrum(faction); if (!facDef.isPlayer) { if (facDef.fixedName != null) { faction.Name = facDef.fixedName; } else { string text = ""; for (int i = 0; i < 10; i++) { string text2 = NameGenerator.GenerateName(facDef.factionNameMaker, Find.FactionManager.AllFactionsVisible.Select((Faction fac) => fac.Name)); if (text2.Length <= 20) { text = text2; } } if (text.NullOrEmpty()) { text = NameGenerator.GenerateName(facDef.factionNameMaker, Find.FactionManager.AllFactionsVisible.Select((Faction fac) => fac.Name)); } faction.Name = text; } } faction.centralMelanin = Rand.Value; foreach (Faction item in Find.FactionManager.AllFactionsListForReading) { faction.TryMakeInitialRelationsWith(item); } if (!faction.Hidden && !facDef.isPlayer) { Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(faction); settlement.Tile = TileFinder.RandomSettlementTileFor(faction); settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement); Find.WorldObjects.Add(settlement); } faction.TryGenerateNewLeader(); return(faction); }
public static CaravanAI MakeCaravan(IEnumerable <Pawn> pawns, Faction faction, int startingTile, bool addToWorldPawnsIfNotAlready, Color color, bool showNeeds = false, bool showSocial = false, bool useFood = false, bool showItems = false) { if (startingTile < 0 && addToWorldPawnsIfNotAlready) { Log.Warning("Tried to create a caravan but chose not to spawn a caravan but pass pawns to world. This can cause bugs because pawns can be discarded."); } tmpPawns.Clear(); tmpPawns.AddRange(pawns); CaravanAI caravan = (CaravanAI)WorldObjectMaker.MakeWorldObject(MoreEvents.Events.WorldObjectsDefOfLocal.CaravanAI); if (startingTile >= 0) { caravan.Tile = startingTile; } caravan.SetFaction(faction); if (startingTile >= 0) { Find.WorldObjects.Add(caravan); } for (int i = 0; i < tmpPawns.Count; i++) { Pawn pawn = tmpPawns[i]; if (pawn.Dead) { Log.Warning("Tried to form a caravan with a dead pawn " + pawn); continue; } caravan.AddPawn(pawn, addToWorldPawnsIfNotAlready); if (addToWorldPawnsIfNotAlready && !pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } } caravan.Name = CaravanNameGenerator.GenerateCaravanName(caravan); tmpPawns.Clear(); caravan.SetUniqueId(Find.UniqueIDsManager.GetNextCaravanID()); caravan.ShowSocial = showSocial; caravan.ShowNeeds = showNeeds; caravan.UseFood = useFood; caravan.ShowItems = showItems; caravan.CaravanColor = color; return(caravan); }
protected override bool TryExecuteWorker(IncidentParms parms) { if (!settings.Active) { return(false); } Faction faction = GetFaction(); Map map = Find.AnyPlayerHomeMap; if (!TryGetNewTile(map.Tile, out int newTile)) { return(false); } int days = Rand.Range(11, 20); int passedDays = Rand.Range(days + 3, days + 7); Quest_MissingPeople quest = new Quest_MissingPeople(Rand.Range(3, 9), days, passedDays); quest.id = QuestsManager.Communications.UniqueIdManager.GetNextQuestID(); quest.Faction = faction; int additionalValue = passedDays * 25; quest.GenerateRewards(quest.GetQuestThingFilter(), new FloatRange(1200 + additionalValue, 1800 + additionalValue), new IntRange(2, 8), null, null); LookTargets target = new LookTargets(newTile); quest.Target = target; QuestSite questPlace = (QuestSite)WorldObjectMaker.MakeWorldObject(QuestRim.WorldObjectDefOfLocal.QuestPlace); questPlace.Tile = newTile; questPlace.SetFaction(faction); questPlace.Init(quest); questPlace.RemoveAfterLeave = false; quest.Site = questPlace; Find.WorldObjects.Add(questPlace); string text = string.Format(def.letterText, faction.Name, days, passedDays, quest.TicksToPass.TicksToDays().ToString("f2")).CapitalizeFirst(); QuestsManager.Communications.AddQuest(quest, QuestsManager.Communications.MakeQuestLetter(quest, description: text, lookTarget: target)); return(true); }
public static Site CreateSite(int tile, SitePartDef sitePart, int days, Faction siteFaction, IList <Thing> items, bool sitePartsKnown) { Site site = (Site)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Site); site.Tile = tile; site.core = SiteCoreDefOf.ItemStash; site.writeSiteParts = sitePartsKnown; if (sitePart != null) { site.parts.Add(sitePart); } site.SetFaction(siteFaction); site.GetComponent <TimeoutComp>().StartTimeout(days * 60000); site.GetComponent <ItemStashContentsComp>().contents.TryAddRangeOrTransfer(items, false, false); Find.WorldObjects.Add(site); return(site); }
protected override void DoListingItems() { base.DoListingItems(); #if DEBUG if (!WorldRendererUtility.WorldRenderedNow) { return; } DoGap(); DoLabel("Tools - MFI"); DebugToolWorld_NewTmp("Spawn pirate base", () => { var tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, false); } else { var faction = (from x in Find.FactionManager.AllFactions where !x.def.hidden && !x.defeated && !x.IsPlayer && x.HostileTo(Faction.OfPlayer) && x.def.permanentEnemy select x).First(); var factionBase = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); factionBase.SetFaction(faction); factionBase.Tile = tile; factionBase.Name = SettlementNameGenerator.GenerateSettlementName(factionBase); Find.WorldObjects.Add(factionBase); } }, false ); DebugToolWorld_NewTmp("Test annual Expo", new AnnualExpoDialogue(null, null, null, Find.FactionManager.RandomAlliedFaction()) .DebugLogChances, false); #endif }
protected override void StrikeAction(ActiveArtilleryStrike strike, CellRect mapRect, CellRect baseRect, ref bool destroyed) { var radialCells = GenRadial.RadialCellsAround(mapRect.RandomCell, strike.shellDef.projectile.explosionRadius, true); int cellsInRect = radialCells.Count(c => baseRect.Contains(c)); // Destroy settlement if (cellsInRect > 0 && Rand.Chance(cellsInRect * DestroyChancePerCellInRect)) { Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), "VFESecurity.LetterFactionBaseDefeatedStrike".Translate(Settlement.Label), LetterDefOf.PositiveEvent, new GlobalTargetInfo(Settlement.Tile), Settlement.Faction, null); var destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(RimWorld.WorldObjectDefOf.DestroyedSettlement); destroyedSettlement.Tile = Settlement.Tile; Find.WorldObjects.Add(destroyedSettlement); Find.WorldObjects.Remove(Settlement); destroyed = true; } }
protected override bool TryExecuteWorker(IncidentParms parms) { bool result; Faction faction; if ((from wo in Find.WorldObjects.AllWorldObjects where wo.def == SiteDefOfReconAndDiscovery.RD_AdventurePeaceTalks select wo).Count <WorldObject>() > 0) { result = false; } else if (!this.TryFindFaction(out faction, (Faction f) => f != Faction.OfPlayer && f.PlayerGoodwill >= 0)) { result = false; } else { int tile; if (TileFinder.TryFindNewSiteTile(out tile)) { Site site = (Site)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Site); site.Tile = tile; site.SetFaction(faction); site.AddPart(new SitePart(site, SiteDefOfReconAndDiscovery.RD_Festival, SiteDefOfReconAndDiscovery.RD_Festival.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, faction))); // TODO: check if this works correctly SitePart outpost = new SitePart(site, SitePartDefOf.Outpost, SitePartDefOf.Outpost.Worker.GenerateDefaultParams(StorytellerUtility.DefaultSiteThreatPointsNow(), tile, faction)); outpost.hidden = true; site.parts.Add(outpost); int num = 8; site.GetComponent <TimeoutComp>().StartTimeout(num * 60000); base.SendStandardLetter(parms, site, new NamedArgument[] { faction.Name }); Find.WorldObjects.Add(site); result = true; } else { result = false; } } return(result); }
public static void Settle(LandedShip landedShip, bool settlePermanent = false) { Faction faction = landedShip.Faction; if (faction != Faction.OfPlayer) { Log.Error("Cannot settle with non-player faction."); return; } MapParent newWorldObject; if (settlePermanent) { newWorldObject = SettleUtility.AddNewHome(landedShip.Tile, faction); } else { newWorldObject = (ShipDropSite)WorldObjectMaker.MakeWorldObject(ShipNamespaceDefOfs.ShipDropSite); newWorldObject.SetFaction(faction); newWorldObject.Tile = landedShip.Tile; Find.WorldObjects.Add(newWorldObject); } LongEventHandler.QueueLongEvent(delegate { IntVec3 vec3; if (settlePermanent) { vec3 = Find.World.info.initialMapSize; } else { vec3 = new IntVec3(100, 1, 100); } Map visibleMap = MapGenerator.GenerateMap(vec3, landedShip.Tile, newWorldObject, null, null); Current.Game.VisibleMap = visibleMap; }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); LongEventHandler.QueueLongEvent(delegate { Map map = newWorldObject.Map; Pawn pawn = landedShip.PawnsListForReading[0]; Predicate <IntVec3> extraCellValidator = (IntVec3 x) => x.GetRegion(map).CellCount >= 600; TravelingShipsUtility.EnterMapWithShip(landedShip, map, CaravanEnterMode.Center); Find.CameraDriver.JumpTo(map.Center); Find.MainTabsRoot.EscapeCurrentTab(false); }, "SpawningColonists", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); }
protected override void LeaveMap() { if (alreadyLeft || !createWorldObject) { base.LeaveMap(); return; } if (groupID < 0) { Log.Error("Drop pod left the map, but its group ID is " + groupID); Destroy(); return; } if (destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + destinationTile); Destroy(); return; } Lord lord = TransporterUtility.FindLord(groupID, base.Map); if (lord != null) { base.Map.lordManager.RemoveLord(lord); } TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(worldObjectDef ?? WorldObjectDefOf.TravelingTransportPods); travelingTransportPods.Tile = base.Map.Tile; travelingTransportPods.SetFaction(Faction.OfPlayer); travelingTransportPods.destinationTile = destinationTile; travelingTransportPods.arrivalAction = arrivalAction; Find.WorldObjects.Add(travelingTransportPods); tmpActiveDropPods.Clear(); tmpActiveDropPods.AddRange(base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod)); for (int i = 0; i < tmpActiveDropPods.Count; i++) { DropPodLeaving dropPodLeaving = tmpActiveDropPods[i] as DropPodLeaving; if (dropPodLeaving != null && dropPodLeaving.groupID == groupID) { dropPodLeaving.alreadyLeft = true; travelingTransportPods.AddPod(dropPodLeaving.Contents, justLeftTheMap: true); dropPodLeaving.Contents = null; dropPodLeaving.Destroy(); } } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; if (!TileFinder.TryFindPassableTileWithTraversalDistance(map.Tile, 10, 15, out int newTile)) { return(false); } if (!Find.FactionManager.AllFactionsVisible.Any(x => { if (x == Faction.OfPlayer) { return(false); } var relation = x.RelationKindWith(Faction.OfPlayer); if (relation == FactionRelationKind.Ally || relation == FactionRelationKind.Neutral) { return(true); } return(false); })) { return(false); } var dialog = QuestsManager.Communications.MakeDialogFromIncident(def); FairPlace fairPlace = (FairPlace)WorldObjectMaker.MakeWorldObject(WorldObjectsDefOfLocal.FairPlace); fairPlace.Tile = newTile; fairPlace.SetFaction(Faction.OfPlayer); fairPlace.SetTimer(10); fairPlace.CommunicationDialog = dialog; DefDatabase <MapGeneratorBlueprints.MapGenerator.MapGeneratorDef> .AllDefsListForReading.Where(gen => gen.targetTags != null && gen.targetTags.Contains(fairPlace.MapGeneratorTag)).TryRandomElementByWeight(w => w.Commonality, out fairPlace.MapGenerator); QuestsManager.Communications.AddCommunication(dialog); Find.WorldObjects.Add(fairPlace); SendStandardLetter(parms, fairPlace); return(true); }
protected override void LeaveMap() { if (this.alreadyLeft) { base.LeaveMap(); } else if (this.groupID < 0) { Log.Error("Drop pod left the map, but its group ID is " + (object)this.groupID); this.Destroy(DestroyMode.Vanish); } else if (this.destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + (object)this.destinationTile); this.Destroy(DestroyMode.Vanish); } else { Lord lord = TransporterUtility.FindLord(this.groupID, this.Map); if (lord != null) { this.Map.lordManager.RemoveLord(lord); } TravelingSRTS travelingTransportPods = (TravelingSRTS)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("TravelingSRTS", true)); travelingTransportPods.Tile = this.Map.Tile; travelingTransportPods.SetFaction(Faction.OfPlayer); travelingTransportPods.destinationTile = this.destinationTile; travelingTransportPods.arrivalAction = this.arrivalAction; Find.WorldObjects.Add((WorldObject)travelingTransportPods); SRTSLeaving.tmpActiveDropPods.Clear(); SRTSLeaving.tmpActiveDropPods.AddRange((IEnumerable <Thing>) this.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod)); travelingTransportPods.flyingThing = tmpActiveDropPods.Find(x => (x as SRTSLeaving)?.groupID == this.groupID); for (int index = 0; index < SRTSLeaving.tmpActiveDropPods.Count; ++index) { SRTSLeaving tmpActiveDropPod = SRTSLeaving.tmpActiveDropPods[index] as SRTSLeaving; if (tmpActiveDropPod != null && tmpActiveDropPod.groupID == this.groupID) { tmpActiveDropPod.alreadyLeft = true; travelingTransportPods.AddPod(tmpActiveDropPod.Contents, true); tmpActiveDropPod.Contents = (ActiveDropPodInfo)null; tmpActiveDropPod.Destroy(DestroyMode.Vanish); } } } }
/// <summary> /// Returns an existing UWO or creates a new one, adding it to the world. /// </summary> /// <typeparam name="T">Your custom type that extends UtilityWorldObject</typeparam> public static T GetUtilityWorldObject <T>() where T : UtilityWorldObject { var worldObjects = GetHolder(); var obj = (T)worldObjects.ObjectsAt(UtilityObjectTile).FirstOrDefault(o => o is T); if (obj == null) { var def = DefDatabase <WorldObjectDef> .GetNamed(InjectedDefName); def.worldObjectClass = typeof(T); obj = (T)WorldObjectMaker.MakeWorldObject(def); def.worldObjectClass = typeof(WorldObject); obj.Tile = UtilityObjectTile; worldObjects.Add(obj); } return(obj); }
// Token: 0x0600271E RID: 10014 RVA: 0x00129D34 File Offset: 0x00128134 protected override void LeaveMap() { if (this.alreadyLeft) { base.LeaveMap(); return; } if (this.groupID < 0) { Log.Error("Drop pod left the map, but its group ID is " + this.groupID, false); this.Destroy(DestroyMode.Vanish); return; } if (this.destinationTile < 0) { Log.Error("Drop pod left the map, but its destination tile is " + this.destinationTile, false); this.Destroy(DestroyMode.Vanish); return; } Lord lord = TransporterUtility.FindLord(this.groupID, base.Map); if (lord != null) { base.Map.lordManager.RemoveLord(lord); } TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("TravelingHelicopters", true)); travelingTransportPods.Tile = base.Map.Tile; travelingTransportPods.SetFaction(Faction.OfPlayer); travelingTransportPods.destinationTile = this.destinationTile; travelingTransportPods.arrivalAction = this.arrivalAction; Find.WorldObjects.Add(travelingTransportPods); HelicopterLeaving.tmpActiveDropPods.Clear(); HelicopterLeaving.tmpActiveDropPods.AddRange(base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ActiveDropPod)); for (int i = 0; i < HelicopterLeaving.tmpActiveDropPods.Count; i++) { HelicopterLeaving HelicopterLeaving = HelicopterLeaving.tmpActiveDropPods[i] as HelicopterLeaving; if (HelicopterLeaving != null && HelicopterLeaving.groupID == this.groupID) { HelicopterLeaving.alreadyLeft = true; travelingTransportPods.AddPod(HelicopterLeaving.Contents, true); HelicopterLeaving.Contents = null; HelicopterLeaving.Destroy(DestroyMode.Vanish); } } }
public void EstablishFarcasterLink() { mapHome = this.Map; Messages.Message("GU_FarcasterActivated".Translate(), MessageTypeDefOf.PositiveEvent); FarcasterDestination worldObjectFarcaster = (FarcasterDestination)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("GU_FarcasterDestinationSigmaAlcyon", true)); mapParent = (MapParent)worldObjectFarcaster; mapParent.Tile = TileFinder.RandomStartingTile(); mapParent.SetFaction(Faction.OfPlayer); worldObjectFarcaster.mapHome = mapHome; worldObjectFarcaster.mapGen = DefDatabase <MapGeneratorDef> .GetNamed("GU_FarcasterMapSigmaAlcyon", true); Find.WorldObjects.Add(mapParent); myMap = new Map(); LongEventHandler.QueueLongEvent(delegate { myMap = GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, Find.World.info.initialMapSize, null); }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); LongEventHandler.QueueLongEvent(delegate { originalBiome = myMap.TileInfo.biome; originalTile = mapParent.Tile; myMap.TileInfo.biome = DefDatabase <BiomeDef> .GetNamed("GU_SigmaAlcyonIIb", true); mapParent.Tile = base.Tile; mapFarcast = myMap; //Remote Farcaster portal spawning Building_AncientFarcaster building_AncientFarcaster = (Building_AncientFarcaster)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPortal", true)); building_AncientFarcaster.mapHome = mapHome; building_AncientFarcaster.locationHome = this.Position; building_AncientFarcaster.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(building_AncientFarcaster, myMap.Center, myMap); locationFarcast = building_AncientFarcaster.Position; //An auxiliary pad too Building_Storage building_AncientPad = (Building_Storage)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("GU_AncientFarcasterPad", true)); building_AncientPad.SetFaction(Faction.OfPlayer); GenSpawn.Spawn(building_AncientPad, myMap.Center - GenAdj.CardinalDirections[0] * 4, myMap); //Farcaster portal spawning ends here }, "GU_LinkingWithFarcasters", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap)); }