public static Command BuildCopyCommand(BuildableDef buildable, ThingDef stuff) { Designator_Build des = BuildCopyCommandUtility.FindAllowedDesignator(buildable, true); if (des == null) { return(null); } Command_Action command_Action = new Command_Action(); command_Action.action = delegate { SoundDefOf.SelectDesignator.PlayOneShotOnCamera(null); des.SetStuffDef(stuff); Find.DesignatorManager.Select(des); }; command_Action.defaultLabel = "CommandBuildCopy".Translate(); command_Action.defaultDesc = "CommandBuildCopyDesc".Translate(); command_Action.icon = des.icon; command_Action.iconProportions = des.iconProportions; command_Action.iconDrawScale = des.iconDrawScale; command_Action.iconTexCoords = des.iconTexCoords; if (stuff != null) { command_Action.defaultIconColor = stuff.stuffProps.color; } else { command_Action.defaultIconColor = buildable.IconDrawColor; } command_Action.hotKey = KeyBindingDefOf.Misc11; return(command_Action); }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } Gizmo selectMonumentMarkerGizmo = QuestUtility.GetSelectMonumentMarkerGizmo(this); if (selectMonumentMarkerGizmo != null) { yield return(selectMonumentMarkerGizmo); } Command command = BuildCopyCommandUtility.BuildCopyCommand(def.entityDefToBuild, base.Stuff); if (command != null) { yield return(command); } if (base.Faction == Faction.OfPlayer) { foreach (Command item in BuildFacilityCommandUtility.BuildFacilityCommands(def.entityDefToBuild)) { yield return(item); } } }
public static IEnumerable <Command> BuildFacilityCommands(BuildableDef building) { ThingDef thingDef = building as ThingDef; if (thingDef == null) { yield break; } CompProperties_AffectedByFacilities affectedByFacilities = thingDef.GetCompProperties <CompProperties_AffectedByFacilities>(); if (affectedByFacilities == null) { yield break; } for (int i = 0; i < affectedByFacilities.linkableFacilities.Count; i++) { ThingDef facility = affectedByFacilities.linkableFacilities[i]; Designator_Build des = BuildCopyCommandUtility.FindAllowedDesignator(facility, true); if (des != null) { yield return(des); } } yield break; }
public static IEnumerable <Command> BuildFacilityCommands(BuildableDef building) { ThingDef thingDef = building as ThingDef; if (thingDef != null) { CompProperties_AffectedByFacilities affectedByFacilities = thingDef.GetCompProperties <CompProperties_AffectedByFacilities>(); if (affectedByFacilities != null) { int i = 0; Designator_Build des; while (true) { if (i >= affectedByFacilities.linkableFacilities.Count) { yield break; } ThingDef facility = affectedByFacilities.linkableFacilities[i]; des = BuildCopyCommandUtility.FindAllowedDesignator(facility); if (des != null) { break; } i++; } yield return((Command)des); /*Error: Unable to find new state assignment for yield return*/; } } }
private static Designator_Build FindAllowedDesignatorRecursive(Designator designator, BuildableDef buildable, bool mustBeVisible) { if (!Current.Game.Rules.DesignatorAllowed(designator)) { return(null); } if (mustBeVisible && !designator.Visible) { return(null); } Designator_Build designator_Build = designator as Designator_Build; if (designator_Build != null && designator_Build.PlacingDef == buildable) { return(designator_Build); } Designator_Dropdown designator_Dropdown = designator as Designator_Dropdown; if (designator_Dropdown != null) { for (int i = 0; i < designator_Dropdown.Elements.Count; i++) { Designator_Build designator_Build2 = BuildCopyCommandUtility.FindAllowedDesignatorRecursive(designator_Dropdown.Elements[i], buildable, mustBeVisible); if (designator_Build2 != null) { return(designator_Build2); } } } return(null); }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo c in base.GetGizmos()) { yield return(c); } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.def.entityDefToBuild, this.stuffToUse); if (buildCopy != null) { yield return(buildCopy); } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo c in base.GetGizmos()) { yield return(c); } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.ThingToInstall.def, this.ThingToInstall.Stuff); if (buildCopy != null) { yield return(buildCopy); } }
public static Designator_Build FindAllowedDesignator(BuildableDef buildable, bool mustBeVisible = true) { List <DesignationCategoryDef> allDefsListForReading = DefDatabase <DesignationCategoryDef> .AllDefsListForReading; for (int i = 0; i < allDefsListForReading.Count; i++) { List <Designator> allResolvedDesignators = allDefsListForReading[i].AllResolvedDesignators; for (int j = 0; j < allResolvedDesignators.Count; j++) { Designator_Build designator_Build = BuildCopyCommandUtility.FindAllowedDesignatorRecursive(allResolvedDesignators[j], buildable, mustBeVisible); if (designator_Build != null) { return(designator_Build); } } } return(null); }
public override IEnumerable<Gizmo> GetGizmos() { foreach (Gizmo c in base.GetGizmos()) { yield return c; } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.def.entityDefToBuild, this.stuffToUse); if (buildCopy != null) { yield return buildCopy; } if (base.Faction == Faction.OfPlayer) { foreach (Command facility in BuildFacilityCommandUtility.BuildFacilityCommands(this.def.entityDefToBuild)) { yield return facility; } } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } Command command = BuildCopyCommandUtility.BuildCopyCommand(ThingToInstall.def, ThingToInstall.Stuff); if (command != null) { yield return(command); } if (base.Faction == Faction.OfPlayer) { foreach (Command item in BuildFacilityCommandUtility.BuildFacilityCommands(ThingToInstall.def)) { yield return(item); } } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo c in base.GetGizmos()) { yield return(c); } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.ThingToInstall.def, this.ThingToInstall.Stuff); if (buildCopy != null) { yield return(buildCopy); } if (base.Faction == Faction.OfPlayer) { foreach (Command facility in BuildFacilityCommandUtility.BuildFacilityCommands(this.ThingToInstall.def)) { yield return(facility); } } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } Command command = BuildCopyCommandUtility.BuildCopyCommand(def.entityDefToBuild, stuffToUse); if (command != null) { yield return(command); } if (base.Faction == Faction.OfPlayer) { foreach (Command item in BuildFacilityCommandUtility.BuildFacilityCommands(def.entityDefToBuild)) { yield return(item); } } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo c in this.< GetGizmos > __BaseCallProxy0()) { yield return(c); } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.def.entityDefToBuild, this.stuffToUse); if (buildCopy != null) { yield return(buildCopy); } if (base.Faction == Faction.OfPlayer) { foreach (Command facility in BuildFacilityCommandUtility.BuildFacilityCommands(this.def.entityDefToBuild)) { yield return(facility); } } yield break; }
public override IEnumerable <Gizmo> GetGizmos() { using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator()) { if (enumerator.MoveNext()) { Gizmo c = enumerator.Current; yield return(c); /*Error: Unable to find new state assignment for yield return*/; } } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(def.entityDefToBuild, base.Stuff); if (buildCopy != null) { yield return((Gizmo)buildCopy); /*Error: Unable to find new state assignment for yield return*/; } if (base.Faction == Faction.OfPlayer) { using (IEnumerator <Command> enumerator2 = BuildFacilityCommandUtility.BuildFacilityCommands(def.entityDefToBuild).GetEnumerator()) { if (enumerator2.MoveNext()) { Command facility = enumerator2.Current; yield return((Gizmo)facility); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_01be: /*Error near IL_01bf: Unexpected return in MoveNext()*/; }
public override IEnumerable <Gizmo> GetGizmos() { using (IEnumerator <Gizmo> enumerator = base.GetGizmos().GetEnumerator()) { if (enumerator.MoveNext()) { Gizmo c = enumerator.Current; yield return(c); /*Error: Unable to find new state assignment for yield return*/; } } Command buildCopy = BuildCopyCommandUtility.BuildCopyCommand(base.def.entityDefToBuild, this.stuffToUse); if (buildCopy == null) { yield break; } yield return((Gizmo)buildCopy); /*Error: Unable to find new state assignment for yield return*/; IL_010e: /*Error near IL_010f: Unexpected return in MoveNext()*/; }
private void PlaceAllBlueprints(ThingDef preferredStuffIfNone) { foreach (SketchEntity entity in sketch.Entities) { SketchBuildable sketchBuildable = entity as SketchBuildable; if (sketchBuildable != null && !entity.IsSameSpawnedOrBlueprintOrFrame(entity.pos + base.Position, base.Map) && !entity.IsSpawningBlocked(entity.pos + base.Position, base.Map) && BuildCopyCommandUtility.FindAllowedDesignator(sketchBuildable.Buildable) != null) { SketchThing sketchThing; SketchTerrain sketchTerrain; if ((sketchThing = (entity as SketchThing)) != null && sketchThing.def.MadeFromStuff && sketchThing.stuff == null && preferredStuffIfNone != null && preferredStuffIfNone.stuffProps.CanMake(sketchThing.def)) { sketchThing.stuff = preferredStuffIfNone; entity.Spawn(entity.pos + base.Position, base.Map, Faction.OfPlayer, Sketch.SpawnMode.Blueprint); sketchThing.stuff = null; } else if ((sketchTerrain = (entity as SketchTerrain)) != null && sketchTerrain.stuffForComparingSimilar == null && preferredStuffIfNone != null) { sketchTerrain.stuffForComparingSimilar = preferredStuffIfNone; entity.Spawn(entity.pos + base.Position, base.Map, Faction.OfPlayer, Sketch.SpawnMode.Blueprint); sketchTerrain.stuffForComparingSimilar = null; } else { entity.Spawn(entity.pos + base.Position, base.Map, Faction.OfPlayer, Sketch.SpawnMode.Blueprint); } } } }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } if (!AllDone) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = "CommandCancelMonumentMarker".Translate(); command_Action.defaultDesc = "CommandCancelMonumentMarkerDesc".Translate(); command_Action.icon = CancelCommandTex; command_Action.action = delegate { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmCancelMonumentMarker".Translate(), delegate { QuestUtility.SendQuestTargetSignals(questTags, "MonumentCancelled", this.Named("SUBJECT")); RemovePossiblyRelatedBlueprints(); this.Uninstall(); }, destructive: true)); }; yield return(command_Action); } bool flag = false; foreach (SketchEntity entity in sketch.Entities) { SketchBuildable sketchBuildable = entity as SketchBuildable; if (sketchBuildable != null && !entity.IsSameSpawnedOrBlueprintOrFrame(entity.pos + base.Position, base.Map) && !entity.IsSpawningBlocked(entity.pos + base.Position, base.Map) && BuildCopyCommandUtility.FindAllowedDesignator(sketchBuildable.Buildable) != null) { flag = true; break; } } if (flag) { Command_Action command_Action2 = new Command_Action(); command_Action2.defaultLabel = "CommandPlaceBlueprints".Translate(); command_Action2.defaultDesc = "CommandPlaceBlueprintsDesc".Translate(); command_Action2.icon = PlaceBlueprintsCommandTex; command_Action2.action = delegate { IEnumerable <ThingDef> enumerable = AllowedStuffs(); if (!enumerable.Any()) { PlaceAllBlueprints(null); SoundDefOf.Click.PlayOneShotOnCamera(); } else if (enumerable.Count() == 1) { PlaceAllBlueprints(enumerable.First()); SoundDefOf.Click.PlayOneShotOnCamera(); } else { ListFloatMenuOptions(enumerable, delegate(ThingDef stuff) { PlaceAllBlueprints(stuff); }); } }; yield return(command_Action2); } foreach (Gizmo questRelatedGizmo in QuestUtility.GetQuestRelatedGizmos(this)) { yield return(questRelatedGizmo); } if (Prefs.DevMode) { bool flag2 = false; foreach (SketchEntity entity2 in sketch.Entities) { if (!entity2.IsSameSpawned(entity2.pos + base.Position, base.Map) && !entity2.IsSpawningBlocked(entity2.pos + base.Position, base.Map)) { flag2 = true; break; } } if (flag2) { Command_Action command_Action3 = new Command_Action(); command_Action3.defaultLabel = "Dev: Build all"; command_Action3.action = delegate { DebugBuildAll(); SoundDefOf.Click.PlayOneShotOnCamera(); }; yield return(command_Action3); } if (AllDone && AnyDisallowedBuilding && !DisallowedBuildingTicksExpired) { Command_Action command_Action4 = new Command_Action(); command_Action4.defaultLabel = "Dev: Disallowed building ticks +6 hours"; command_Action4.action = delegate { ticksSinceDisallowedBuilding += 15000; }; yield return(command_Action4); } } tmpUniqueBuildableDefs.Clear(); foreach (SketchEntity entity3 in sketch.Entities) { SketchBuildable buildable = entity3 as SketchBuildable; if (buildable == null || entity3.IsSameSpawnedOrBlueprintOrFrame(entity3.pos + base.Position, base.Map) || !tmpUniqueBuildableDefs.Add(new Pair <BuildableDef, ThingDef>(buildable.Buildable, buildable.Stuff))) { continue; } SketchTerrain sketchTerrain; if ((sketchTerrain = buildable as SketchTerrain) != null && sketchTerrain.treatSimilarAsSame) { TerrainDef terrain = buildable.Buildable as TerrainDef; if (terrain.designatorDropdown != null) { Designator designator = BuildCopyCommandUtility.FindAllowedDesignatorRoot(buildable.Buildable); if (designator != null) { yield return(designator); } } else { IEnumerable <TerrainDef> allDefs = DefDatabase <TerrainDef> .AllDefs; foreach (TerrainDef item in allDefs) { if (!item.BuildableByPlayer || item.designatorDropdown != null) { continue; } bool flag3 = true; for (int i = 0; i < terrain.affordances.Count; i++) { if (!item.affordances.Contains(terrain.affordances[i])) { flag3 = false; break; } } if (flag3) { Command command = BuildCopyCommandUtility.BuildCommand(item, null, item.label, item.description, allowHotKey: false); if (command != null) { yield return(command); } } } } } else { Command command2 = BuildCopyCommandUtility.BuildCommand(buildable.Buildable, buildable.Stuff, entity3.LabelCap, buildable.Buildable.description, allowHotKey: false); if (command2 != null) { yield return(command2); } } Command_Action placeBlueprintsCommand = GetPlaceBlueprintsCommand(buildable); if (placeBlueprintsCommand != null) { yield return(placeBlueprintsCommand); } } tmpUniqueBuildableDefs.Clear(); }
public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } if (!AllDone) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = "CommandCancelMonumentMarker".Translate(); command_Action.defaultDesc = "CommandCancelMonumentMarkerDesc".Translate(); command_Action.icon = CancelCommandTex; command_Action.action = delegate { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmCancelMonumentMarker".Translate(), delegate { QuestUtility.SendQuestTargetSignals(questTags, "MonumentCancelled", this.Named("SUBJECT")); RemovePossiblyRelatedBlueprints(); this.Uninstall(); }, destructive: true)); }; yield return(command_Action); } bool flag = false; foreach (SketchEntity entity in sketch.Entities) { SketchBuildable sketchBuildable = entity as SketchBuildable; if (sketchBuildable != null && !entity.IsSameSpawnedOrBlueprintOrFrame(entity.pos + base.Position, base.Map) && !entity.IsSpawningBlocked(entity.pos + base.Position, base.Map) && BuildCopyCommandUtility.FindAllowedDesignator(sketchBuildable.Buildable) != null) { flag = true; break; } } if (flag) { Command_Action command_Action2 = new Command_Action(); command_Action2.defaultLabel = "CommandPlaceBlueprints".Translate(); command_Action2.defaultDesc = "CommandPlaceBlueprintsDesc".Translate(); command_Action2.icon = PlaceBlueprintsCommandTex; MonumentMarker monumentMarker = default(MonumentMarker); ThingDef stuffLocal = default(ThingDef); command_Action2.action = delegate { IEnumerable <ThingDef> enumerable = AllowedStuffs(); if (!enumerable.Any()) { PlaceAllBlueprints(null); SoundDefOf.Click.PlayOneShotOnCamera(); } else if (enumerable.Count() == 1) { PlaceAllBlueprints(enumerable.First()); SoundDefOf.Click.PlayOneShotOnCamera(); } else { List <FloatMenuOption> list = new List <FloatMenuOption>(); bool flag4 = false; foreach (ThingDef item in enumerable) { if (base.Map.listerThings.ThingsOfDef(item).Count > 0) { flag4 = true; break; } } foreach (ThingDef item2 in enumerable) { monumentMarker = this; if (!flag4 || base.Map.listerThings.ThingsOfDef(item2).Count != 0) { stuffLocal = item2; list.Add(new FloatMenuOption(stuffLocal.LabelCap, delegate { monumentMarker.PlaceAllBlueprints(stuffLocal); }, item2)); } } Find.WindowStack.Add(new FloatMenu(list)); } }; yield return(command_Action2); } foreach (Gizmo questRelatedGizmo in QuestUtility.GetQuestRelatedGizmos(this)) { yield return(questRelatedGizmo); } if (Prefs.DevMode) { bool flag2 = false; foreach (SketchEntity entity2 in sketch.Entities) { if (!entity2.IsSameSpawned(entity2.pos + base.Position, base.Map) && !entity2.IsSpawningBlocked(entity2.pos + base.Position, base.Map)) { flag2 = true; break; } } if (flag2) { Command_Action command_Action3 = new Command_Action(); command_Action3.defaultLabel = "Dev: Build all"; command_Action3.action = delegate { DebugBuildAll(); SoundDefOf.Click.PlayOneShotOnCamera(); }; yield return(command_Action3); } } tmpUniqueBuildableDefs.Clear(); foreach (SketchEntity entity3 in sketch.Entities) { SketchBuildable sketchBuildable2 = entity3 as SketchBuildable; if (sketchBuildable2 != null && !entity3.IsSameSpawnedOrBlueprintOrFrame(entity3.pos + base.Position, base.Map) && tmpUniqueBuildableDefs.Add(new Pair <BuildableDef, ThingDef>(sketchBuildable2.Buildable, sketchBuildable2.Stuff))) { SketchTerrain sketchTerrain; if ((sketchTerrain = (sketchBuildable2 as SketchTerrain)) != null && sketchTerrain.treatSimilarAsSame) { TerrainDef terrain = sketchBuildable2.Buildable as TerrainDef; if (terrain.designatorDropdown != null) { Designator designator = BuildCopyCommandUtility.FindAllowedDesignatorRoot(sketchBuildable2.Buildable); if (designator != null) { yield return(designator); } } else { IEnumerable <TerrainDef> allDefs = DefDatabase <TerrainDef> .AllDefs; foreach (TerrainDef item3 in allDefs) { if (item3.BuildableByPlayer && item3.designatorDropdown == null) { bool flag3 = true; for (int i = 0; i < terrain.affordances.Count; i++) { if (!item3.affordances.Contains(terrain.affordances[i])) { flag3 = false; break; } } if (flag3) { Command command = BuildCopyCommandUtility.BuildCommand(item3, null, item3.label, item3.description, allowHotKey: false); if (command != null) { yield return(command); } } } } } } else { Command command2 = BuildCopyCommandUtility.BuildCommand(sketchBuildable2.Buildable, sketchBuildable2.Stuff, entity3.Label, sketchBuildable2.Buildable.description, allowHotKey: false); if (command2 != null) { yield return(command2); } } } } tmpUniqueBuildableDefs.Clear(); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: enumerator = base.< GetGizmos > __BaseCallProxy0().GetEnumerator(); num = 4294967293u; break; case 1u: break; case 2u: goto IL_10D; case 3u: goto IL_147; default: return(false); } try { switch (num) { } if (enumerator.MoveNext()) { c = enumerator.Current; this.$current = c; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } buildCopy = BuildCopyCommandUtility.BuildCopyCommand(this.def.entityDefToBuild, this.stuffToUse); if (buildCopy != null) { this.$current = buildCopy; if (!this.$disposing) { this.$PC = 2; } return(true); } IL_10D: if (base.Faction != Faction.OfPlayer) { goto IL_1BE; } enumerator2 = BuildFacilityCommandUtility.BuildFacilityCommands(this.def.entityDefToBuild).GetEnumerator(); num = 4294967293u; try { IL_147: switch (num) { } if (enumerator2.MoveNext()) { facility = enumerator2.Current; this.$current = facility; if (!this.$disposing) { this.$PC = 3; } flag = true; return(true); } } finally { if (!flag) { if (enumerator2 != null) { enumerator2.Dispose(); } } } IL_1BE: this.$PC = -1; return(false); }