コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }