private static void SpawnWorldObject() { int tile = GenWorld.MouseTile(); if (tile < 0 || Find.World.Impassable(tile)) { Messages.Message("Impassable", MessageTypeDefOf.RejectInput, historical: false); return; } List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (WorldObjectDef allDef in DefDatabase <WorldObjectDef> .AllDefs) { WorldObjectDef localDef = allDef; Action action = null; action = delegate { WorldObject worldObject = WorldObjectMaker.MakeWorldObject(localDef); worldObject.Tile = tile; Find.WorldObjects.Add(worldObject); }; list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Action, action)); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }
private void Initialize() { _capitalWorldObjs = new List <WorldObject>(); _neighboors = new List <int>(); _core = new List <int>(); _wall = new List <int>(); _outerRim = new List <int>(); _dominion = new List <int>(); _centerDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalCenter"); _downtownDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalDowntown"); _housingDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalHousing"); _farmDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalFarm"); _factoryDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalFactory"); _powerPlantDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalPowerPlant"); _windFarmDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalWindFarm"); _defenseBaseDef = DefDatabase <WorldObjectDef> .GetNamed("CapitalDefenseBase"); }
public static void CreateWorldObject(WorldObjectDef def, int tile, Faction faction = null) { WorldObject worldObject = WorldObjectMaker.MakeWorldObject(def); worldObject.Tile = tile; worldObject.SetFaction(faction); Find.WorldObjects.Add(worldObject); }
public AbandonedSettlementMenu(WorldObject obj) { resizeable = false; edit = true; editObject = obj; type = editObject.def; }
public static WorldObject MakeWorldObject(WorldObjectDef def) { WorldObject worldObject = (WorldObject)Activator.CreateInstance(def.worldObjectClass); worldObject.def = def; worldObject.ID = Find.UniqueIDsManager.GetNextWorldObjectID(); worldObject.creationGameTicks = Find.TickManager.TicksGame; worldObject.PostMake(); return(worldObject); }
public override Map GetOrGenerateMap(int tile, IntVec3 mapSize, WorldObjectDef suggestedMapParentDef) { Map map = Current.Game.FindMap(tile); if (map == null) { map = Verse.MapGenerator.GenerateMap(mapSize, MapParent, MapGeneratorDefOfLocal.EmptyMap); } return(map); }
public static void Prefix(int tile, ref IntVec3 size, WorldObjectDef suggestedMapParentDef) { Map map = Current.Game.FindMap(tile); Faction faction = null; if (map != null) { if (map.ParentFaction != null) { faction = map.ParentFaction; } } else { MapParent mapParent = Find.WorldObjects.MapParentAt(tile); if (mapParent?.Faction != null) { faction = mapParent.Faction; } } if (faction == null) { return; } HiveFactionEvolutionTracker evolutionTracker = Find.World.GetComponent <HiveFactionEvolutionTracker>(); HiveFactionExtension hive = faction.def.GetModExtension <HiveFactionExtension>(); if (evolutionTracker != null && hive != null) { int sizemod = 0; // Log.Message("GetOrGenerateMap for " + faction + " Default: " + size.x + " Max Hive size: " + hive.CurStage.sizeRange.max); for (int i = 0; i < 10; i++) { if (hive.CurStage.sizeRange.max >= ((size.x + sizemod) / 2) * 0.75f) { sizemod = (int)(size.x * 0.25f); } else { break; } } if (sizemod > 0) { size.x += sizemod; size.z += sizemod; // Log.Message("GetOrGenerateMap for " + faction +" applied sizemod: "+ sizemod +" resulting: "+ size); } } else { // Log.Message("GetOrGenerateMap evolutionTracker: "+ (evolutionTracker != null) + " hiveext: " + (hive != null)); } }
public WorldObject WorldObjectAt(int tile, WorldObjectDef def) { for (int i = 0; i < this.worldObjects.Count; i++) { if (this.worldObjects[i].Tile == tile && this.worldObjects[i].def == def) { return(this.worldObjects[i]); } } return(null); }
public static Map GetOrGenerateMapForIncident(Caravan caravan, IntVec3 size, WorldObjectDef suggestedMapParentDef) { int tile = caravan.Tile; bool flag = Current.Game.FindMap(tile) == null; Map orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(tile, size, suggestedMapParentDef); if (flag && orGenerateMap != null) { caravan.StoryState.CopyTo(orGenerateMap.StoryState); } return orGenerateMap; }
public WorldObject WorldObjectOfDefAt(WorldObjectDef def, int tile) { for (int i = 0; i < worldObjects.Count; i++) { if (worldObjects[i].def == def && worldObjects[i].Tile == tile) { return(worldObjects[i]); } } return(null); }
public static WorldObject MakeWorldObject(WorldObjectDef def, int id) { var instance = (WorldObject)Activator.CreateInstance(def.worldObjectClass); instance.def = def; instance.ID = id; instance.creationGameTicks = Find.TickManager.TicksGame; instance.PostMake(); return(instance); }
public static Map GetOrGenerateMapForIncident(Caravan caravan, IntVec3 size, WorldObjectDef suggestedMapParentDef) { int tile = caravan.Tile; bool num = Current.Game.FindMap(tile) == null; Map orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(tile, size, suggestedMapParentDef); if (num) { orGenerateMap?.retainedCaravanData.Notify_GeneratedTempIncidentMapFor(caravan); } return(orGenerateMap); }
public override IEnumerable <string> ConfigErrors(WorldObjectDef parentDef) { foreach (string e in base.ConfigErrors(parentDef)) { yield return(e); } if (!typeof(MapParent).IsAssignableFrom(parentDef.worldObjectClass)) { yield return(parentDef.defName + " has WorldObjectCompProperties_PrisonerRescueQuest but it's not MapParent."); } yield break; }
private static void InjectUtilityObjectDef() { var def = new WorldObjectDef { defName = InjectedDefName, worldObjectClass = typeof(WorldObject), canHaveFaction = false, selectable = false, neverMultiSelect = true, useDynamicDrawer = true }; InjectedDefHasher.GiveShortHasToDef(def, typeof(WorldObject)); DefDatabase <WorldObjectDef> .Add(def); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Widgets.Label(new Rect(0, 0, 290, 20), Translator.Translate("AddAbandonedDestroyedSettlement")); int factionDefSize = Find.WorldObjects.Settlements.Count * 25; Widgets.Label(new Rect(0, 20, 240, 20), Translator.Translate("FactionOwner")); Rect scrollRectFact = new Rect(0, 45, 295, 180); Rect scrollVertRectFact = new Rect(0, 0, scrollRectFact.x, factionDefSize); Widgets.BeginScrollView(scrollRectFact, ref scroll, scrollVertRectFact); int yButtonPos = 0; foreach (var spawnedSettl in Find.WorldObjects.Settlements) { if (Widgets.ButtonText(new Rect(0, yButtonPos, 290, 20), spawnedSettl.Name)) { selectedSettlement = spawnedSettl; Messages.Message($"Selected settlement {selectedSettlement.Name}", MessageTypeDefOf.NeutralEvent, false); } yButtonPos += 22; } Widgets.EndScrollView(); Widgets.Label(new Rect(0, 230, 240, 20), $"Selected tile ID: {Find.WorldSelector.selectedTile}"); if (type == WorldObjectDefOf.AbandonedSettlement) { if (Widgets.ButtonText(new Rect(0, 255, 290, 20), Translator.Translate("AbandonedType"))) { type = WorldObjectDefOf.DestroyedSettlement; } } else { if (Widgets.ButtonText(new Rect(0, 255, 290, 20), Translator.Translate("DestroyedType"))) { type = WorldObjectDefOf.AbandonedSettlement; } } if (Widgets.ButtonText(new Rect(0, 275, 290, 20), Translator.Translate("SetAbandonedDestroyedSettlement"))) { AddSettlementObject(); } }
// Basically replace the original method with our own, that's basically the same // (with the main difference being how we are handling the button) private static bool PreDoOutpostDisplay(ref Rect inRect, WorldObjectDef outpostDef, Dialog_CreateCamp __instance) { var font = Text.Font; var anchor = Text.Anchor; Text.Font = GameFont.Tiny; inRect.height = Text.CalcHeight(outpostDef.description, inRect.width - 90f) + 60f; var outerRect = inRect.LeftPartPixels(50f); var rect = inRect.RightPartPixels(inRect.width - 60f); var expandingIconTexture = outpostDef.ExpandingIconTexture; GUI.color = __instance.creator.Faction.Color; Widgets.DrawTextureFitted(outerRect, expandingIconTexture, 1f, new Vector2(expandingIconTexture.width, expandingIconTexture.height), new Rect(0f, 0f, 1f, 1f)); GUI.color = Color.white; Text.Font = GameFont.Medium; Widgets.Label(rect.TopPartPixels(30f), outpostDef.label.CapitalizeFirst(outpostDef)); var rect2 = rect.BottomPartPixels(30f).LeftPartPixels(100f); var rect3 = rect.BottomPartPixels(30f).RightPartPixels(rect.width - 120f); Text.Font = GameFont.Tiny; Widgets.Label(new Rect(rect.x, rect.y + 30f, rect.width, rect.height - 60f), outpostDef.description); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(rect3, __instance.validity[outpostDef].First); Text.Font = font; Text.Anchor = anchor; if (Widgets.ButtonText(rect2, "Outposts.Dialog.Create".Translate())) { if (__instance.validity[outpostDef].First.NullOrEmpty()) { // If the button was clicked and the outpost is valid, call the synced creation method SyncedCreateOutpost(outpostDef, __instance.creator); __instance.Close(); Find.WorldSelector.Deselect(__instance.creator); } else { Messages.Message(__instance.validity[outpostDef].First, MessageTypeDefOf.RejectInput, false); } } TooltipHandler.TipRegion(inRect, __instance.validity[outpostDef].Second); return(false); }
private static void SyncedCreateOutpost(WorldObjectDef outpostDef, Caravan creator) { var outpost = (Outpost)WorldObjectMaker.MakeWorldObject(outpostDef); outpost.Name = NameGenerator.GenerateName(creator.Faction.def.settlementNameMaker, Find.WorldObjects.AllWorldObjects.OfType <Outpost>().Select(o => o.Name)); outpost.Tile = creator.Tile; outpost.SetFaction(creator.Faction); Find.WorldObjects.Add(outpost); foreach (var pawn in creator.PawnsListForReading.ListFullCopy()) { outpost.AddPawn(pawn); } // Normally we would select the outpost here, but I'm not sure how // we could accomplish this ONLY for the player calling the method }
void GenerateCity(WorldObjectDef def, bool abandoned, System.Predicate <Faction> factionFilter = null) { var city = (City)WorldObjectMaker.MakeWorldObject(def); city.SetFaction(GenCity.RandomCityFaction(factionFilter)); if (!abandoned) { city.inhabitantFaction = city.Faction; } city.Tile = TileFinder.RandomSettlementTileFor(city.Faction); city.Name = city.ChooseName(); if (!TileFinder.IsValidTileForNewSettlement(city.Tile)) { // (Faction Control) ensure valid tile for existing saves city.Tile = TileFinder.RandomStartingTile(); } Find.WorldObjects.Add(city); }
public static Map GetOrGenerateMap(int tile, IntVec3 size, WorldObjectDef suggestedMapParentDef) { Map map = Current.Game.FindMap(tile); if (map == null) { MapParent mapParent = Find.WorldObjects.MapParentAt(tile); if (mapParent == null) { if (suggestedMapParentDef == null) { Log.Error("Tried to get or generate map at " + tile + ", but there isn't any MapParent world object here and map parent def argument is null.", false); return(null); } mapParent = (MapParent)WorldObjectMaker.MakeWorldObject(suggestedMapParentDef); mapParent.Tile = tile; Find.WorldObjects.Add(mapParent); } map = MapGenerator.GenerateMap(size, mapParent, mapParent.MapGeneratorDef, mapParent.ExtraGenStepDefs, null); } return(map); }
public override Map GetOrGenerateMap(int tile, IntVec3 mapSize, WorldObjectDef suggestedMapParentDef) { Map map = Current.Game.FindMap(tile); if (map == null) { MapParent mapParent = MapParentAt(tile).Where(p => p is FriendlySettlement).FirstOrDefault(); if (mapParent == null) { if (suggestedMapParentDef == null) { Log.Error("Tried to get or generate map at " + tile + ", but there isn't any MapParent world object here and map parent def argument is null."); return(null); } mapParent = (MapParent)WorldObjectMaker.MakeWorldObject(suggestedMapParentDef); mapParent.Tile = tile; Find.WorldObjects.Add(mapParent); } map = Verse.MapGenerator.GenerateMap(mapSize, mapParent, mapParent.MapGeneratorDef, mapParent.ExtraGenStepDefs); } return(map); }
public static Map GetOrGenerateMap(int tile, WorldObjectDef suggestedMapParentDef) { return(GetOrGenerateMapUtility.GetOrGenerateMap(tile, Find.World.info.initialMapSize, suggestedMapParentDef)); }
public virtual Map GetOrGenerateMap(int tile, IntVec3 mapSize, MapParent mapParent, WorldObjectDef suggestedMapParentDef) { return(Verse.MapGenerator.GenerateMap(mapSize, mapParent, MapGeneratorDefOfLocal.EmptyMap)); }
public bool AnyWorldObjectOfDefAt(WorldObjectDef def, int tile) { return(WorldObjectOfDefAt(def, tile) != null); }
public bool AnyWorldObjectAt(int tile, WorldObjectDef def) { return(WorldObjectAt(tile, def) != null); }
public static RimWorld.Planet.Settlement GenerateCity(int tile, Faction faction, WorldObjectDef def) { City city = (City)WorldObjectMaker.MakeWorldObject(def); city.SetFaction(faction); city.inhabitantFaction = city.Faction; city.Tile = tile; city.Name = city.ChooseName(); Find.WorldObjects.Add(city); return(city); }
public static RimWorld.Planet.Settlement AddNewHome(int tile, Faction faction, WorldObjectDef cityDef = null) { if (cityDef == null) { cityDef = WorldObjectDefOf.Settlement; } if (ModsConfig.IsActive("Cabbage.RimCities")) { if (cityDef.worldObjectClass.ToString() == "Cities.City") { return(GenerateCity(tile, faction, cityDef)); } else { return(SettleUtility.AddNewHome(tile, faction)); } } else { return(SettleUtility.AddNewHome(tile, faction)); } }
public Map GetOrGenerateMap(int tile, IntVec3 mapSize, WorldObjectDef suggestedMapParentDef) { return(GetOrGenerateMapUtility.GetOrGenerateMap(mapParent.Tile, MapSize, null)); }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } if (WorldUtility.GetRimWarDataForFaction(this.parent.Faction).AllianceFactions.Contains(Faction.OfPlayer)) { int ptsToSend = 500; Command_Action command_SendTrader = new Command_Action(); command_SendTrader.defaultLabel = "RW_SendTrader".Translate(); command_SendTrader.defaultDesc = "RW_SendTraderDesc".Translate(); command_SendTrader.icon = RimWarMatPool.Icon_Trader; if (this.RimWarPoints < ptsToSend) { command_SendTrader.Disable("RW_NotEnoughPointsToSendUnit".Translate(this.RimWarPoints, ptsToSend, RimWarDefOf.RW_Trader.label)); } command_SendTrader.action = delegate { sendTypeDef = RimWarDefOf.RW_Trader; StartChoosingRequestDestination(); }; yield return((Gizmo)command_SendTrader); Command_Action command_SendScout = new Command_Action(); command_SendScout.defaultLabel = "RW_SendScout".Translate(); command_SendScout.defaultDesc = "RW_SendScoutDesc".Translate(); command_SendScout.icon = RimWarMatPool.Icon_Scout; ptsToSend = 800; if (this.RimWarPoints < ptsToSend) { command_SendScout.Disable("RW_NotEnoughPointsToSendUnit".Translate(this.RimWarPoints, ptsToSend, RimWarDefOf.RW_Scout.label)); } command_SendScout.action = delegate { sendTypeDef = RimWarDefOf.RW_Scout; StartChoosingRequestDestination(); }; yield return((Gizmo)command_SendScout); Command_Action command_SendWarband = new Command_Action(); command_SendWarband.defaultLabel = "RW_SendWarband".Translate(); command_SendWarband.defaultDesc = "RW_SendWarbandDesc".Translate(); command_SendWarband.icon = RimWarMatPool.Icon_Warband; ptsToSend = 1000; if (this.RimWarPoints < ptsToSend) { command_SendWarband.Disable("RW_NotEnoughPointsToSendUnit".Translate(this.RimWarPoints, ptsToSend, RimWarDefOf.RW_Warband.label)); } command_SendWarband.action = delegate { sendTypeDef = RimWarDefOf.RW_Warband; StartChoosingRequestDestination(); }; yield return((Gizmo)command_SendWarband); Command_Action command_LaunchWarband = new Command_Action(); command_LaunchWarband.defaultLabel = "RW_LaunchWarband".Translate(); command_LaunchWarband.defaultDesc = "RW_LaunchWarbandDesc".Translate(); command_LaunchWarband.icon = RimWarMatPool.Icon_LaunchWarband; ptsToSend = 1200; if (!RWD.CanLaunch) { command_LaunchWarband.Disable("RW_FactionIncapableOfTech".Translate(this.parent.Faction.Name)); } if (this.RimWarPoints < ptsToSend) { command_LaunchWarband.Disable("RW_NotEnoughPointsToSendUnit".Translate(this.RimWarPoints, ptsToSend, RimWarDefOf.RW_LaunchedWarband.label)); } command_LaunchWarband.action = delegate { sendTypeDef = RimWarDefOf.RW_LaunchedWarband; StartChoosingRequestDestination(); }; yield return((Gizmo)command_LaunchWarband); } }