public Command_SetItemsToSpawn() { foreach (object obj in Find.Selector.SelectedObjects) { Building currentbuilding = obj as Building; building = currentbuilding.TryGetComp <CompConfigurableSpawner>(); if (building != null) { if (building.currentThingList != null) { icon = ContentFinder <Texture2D> .Get(building.currentThingList.GizmoIcon, true); defaultLabel = building.currentThingList.GizmoLabel.Translate(); defaultDesc = building.currentThingList.GizmoDescription.Translate(); } else { icon = ContentFinder <Texture2D> .Get("UI/IP_SetOutput", true); defaultLabel = "IP_ChooseOutput".Translate(); defaultDesc = "IP_ChooseOutput".Translate(); } } } }
public static Command_SetItemsToSpawn SetItemsToSpawnCommand(CompConfigurableSpawner passingbuilding) { return(new Command_SetItemsToSpawn() { hotKey = KeyBindingDefOf.Misc1, building = passingbuilding }); }
public bool TryDoSpawn() { if (!this.parent.Spawned) { return(false); } IntVec3 center; ThingDef thingToSpawn = ThingDef.Named(currentThingList.items.RandomElement()); if (thingToSpawn == null) { return(false); } if (CompConfigurableSpawner.TryFindSpawnCell(this.parent, thingToSpawn, this.PropsSpawner.spawnCount, out center)) { Thing thing = ThingMaker.MakeThing(thingToSpawn, null); thing.stackCount = this.PropsSpawner.spawnCount; if (thing == null) { Log.Error("Could not spawn anything for " + this.parent); } if (this.PropsSpawner.inheritFaction && thing.Faction != this.parent.Faction) { thing.SetFaction(this.parent.Faction, null); } Thing t; GenPlace.TryPlaceThing(thing, this.parent.InteractionCell, this.parent.MapHeld, ThingPlaceMode.Direct, out t, null, null, default(Rot4)); if (this.PropsSpawner.spawnForbidden) { t.SetForbidden(true, true); } if (this.PropsSpawner.showMessageIfOwned && this.parent.Faction == Faction.OfPlayer) { Messages.Message("MessageCompSpawnerSpawnedItem".Translate(thingToSpawn.LabelCap), thing, MessageTypeDefOf.PositiveEvent, true); } return(true); } return(false); }