Exemplo n.º 1
0
            public static void Postfix()
            {
                Dictionary <string, ToolParameterMenu.ToggleState> cancelToolParameters = new Dictionary <string, ToolParameterMenu.ToggleState>();

                AccessTools.Method(typeof(FilteredDragTool), "GetDefaultFilters").Invoke(CancelTool.Instance, new object[] { cancelToolParameters });
                Utilities.CleanVanillaFilters(cancelToolParameters);
                AdvancedFilterMenuCancelTool.Instance.DefaultParameters = cancelToolParameters;

                Dictionary <string, ToolParameterMenu.ToggleState> deconstructToolParameters = new Dictionary <string, ToolParameterMenu.ToggleState>();

                AccessTools.Method(typeof(FilteredDragTool), "GetDefaultFilters").Invoke(DeconstructTool.Instance, new object[] { deconstructToolParameters });
                Utilities.CleanVanillaFilters(deconstructToolParameters);
                AdvancedFilterMenuDeconstructTool.Instance.DefaultParameters = deconstructToolParameters;

                Dictionary <string, ToolParameterMenu.ToggleState> prioritizeToolParameters = new Dictionary <string, ToolParameterMenu.ToggleState>();

                AccessTools.Method(typeof(FilteredDragTool), "GetDefaultFilters").Invoke(PrioritizeTool.Instance, new object[] { prioritizeToolParameters });
                Utilities.CleanVanillaFilters(prioritizeToolParameters);
                AdvancedFilterMenuPrioritizeTool.Instance.DefaultParameters = prioritizeToolParameters;

                Dictionary <string, ToolParameterMenu.ToggleState> emptyPipeToolParameters = new Dictionary <string, ToolParameterMenu.ToggleState>();

                AccessTools.Method(typeof(FilteredDragTool), "GetDefaultFilters").Invoke(EmptyPipeTool.Instance, new object[] { emptyPipeToolParameters });
                Utilities.CleanVanillaFilters(emptyPipeToolParameters);
                AdvancedFilterMenuEmptyPipeTool.Instance.DefaultParameters = emptyPipeToolParameters;

                MultiToolParameterMenu.CreateInstance();
            }
Exemplo n.º 2
0
            public static void Postfix()
            {
                CreateBlueprintTool.DestroyInstance();
                UseBlueprintTool.DestroyInstance();
                SnapshotTool.DestroyInstance();
                MultiToolParameterMenu.DestroyInstance();

                BlueprintsAssets.BLUEPRINTS_AUTOFILE_WATCHER.Dispose();
            }
Exemplo n.º 3
0
            public static void Postfix()
            {
                MultiToolParameterMenu.CreateInstance();
                ToolParameterMenu.ToggleState defaultSelection = BlueprintsAssets.Options.DefaultMenuSelections == DefaultSelections.All ? ToolParameterMenu.ToggleState.On : ToolParameterMenu.ToggleState.Off;

                SnapshotTool.Instance.DefaultParameters            =
                    CreateBlueprintTool.Instance.DefaultParameters = new Dictionary <string, ToolParameterMenu.ToggleState> {
                    { ToolParameterMenu.FILTERLAYERS.WIRES, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.LIQUIDCONDUIT, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.GASCONDUIT, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.SOLIDCONDUIT, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.BUILDINGS, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.LOGIC, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.BACKWALL, defaultSelection },
                    { ToolParameterMenu.FILTERLAYERS.DIGPLACER, defaultSelection },
                    //{ BlueprintsStrings.STRING_BLUEPRINTS_MULTIFILTER_GASTILES, defaultSelection },
                };
            }
Exemplo n.º 4
0
        protected override void OnDragTool(int cell, int distFromOrigin)
        {
            for (int index = 0; index < 40; ++index)
            {
                GameObject gameObject = Grid.Objects[cell, index];

                if (gameObject != null && MultiToolParameterMenu.Instance.IsActiveLayer(MultiToolParameterMenu.GetFilterLayerFromGameObject(gameObject)))
                {
                    gameObject.Trigger(-790448070, null);
                    Prioritizable prioritizable = gameObject.GetComponent <Prioritizable>();

                    if (prioritizable != null)
                    {
                        prioritizable.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority());
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected override void OnDragTool(int cell, int distFromOrigin)
        {
            for (int index = 0; index < 40; ++index)
            {
                GameObject gameObject = Grid.Objects[cell, index];

                if (gameObject != null && MultiToolParameterMenu.Instance.IsActiveLayer(MultiToolParameterMenu.GetFilterLayerFromGameObject(gameObject)))
                {
                    gameObject.Trigger(2127324410, null);
                }
            }
        }
Exemplo n.º 6
0
        public static Blueprint CreateBlueprint(Vector2I topLeft, Vector2I bottomRight, MultiToolParameterMenu filter = null)
        {
            Blueprint blueprint = new Blueprint("unnamed", "");

            int  blueprintHeight    = (topLeft.y - bottomRight.y);
            bool collectingGasTiles = filter.IsActiveLayer(BlueprintsStrings.STRING_BLUEPRINTS_MULTIFILTER_GASTILES);

            for (int x = topLeft.x; x <= bottomRight.x; ++x)
            {
                for (int y = bottomRight.y; y <= topLeft.y; ++y)
                {
                    int cell = Grid.XYToCell(x, y);

                    if (Grid.IsVisible(cell))
                    {
                        bool emptyCell = true;

                        for (int layer = 0; layer < Grid.ObjectLayers.Length; ++layer)
                        {
                            if (layer == 7)
                            {
                                continue;
                            }

                            GameObject gameObject = Grid.Objects[cell, layer];

                            if (gameObject != null && (gameObject.GetComponent <Constructable>() != null || gameObject.GetComponent <Deconstructable>() != null))
                            {
                                Building building;

                                bool validBuilding = (building = gameObject.GetComponent <Building>()) != null;
                                if (!validBuilding && (building = gameObject.GetComponent <BuildingUnderConstruction>()) != null)
                                {
                                    validBuilding = true;
                                }

                                if (gameObject != null && validBuilding && building.Def.IsBuildable() && (filter == null || filter.IsActiveLayer(MultiToolParameterMenu.GetFilterLayerFromGameObject(gameObject))))
                                {
                                    Vector2I centre = Grid.CellToXY(GameUtil.NaturalBuildingCell(building));

                                    BuildingConfig buildingConfig = new BuildingConfig {
                                        Offset      = new Vector2I(centre.x - topLeft.x, blueprintHeight - (topLeft.y - centre.y)),
                                        BuildingDef = building.Def,
                                        Orientation = building.Orientation
                                    };

                                    if (gameObject.GetComponent <Deconstructable>() != null)
                                    {
                                        buildingConfig.SelectedElements.AddRange(gameObject.GetComponent <Deconstructable>().constructionElements);
                                    }

                                    else
                                    {
                                        buildingConfig.SelectedElements.AddRange(Traverse.Create(gameObject.GetComponent <Constructable>()).Field("selectedElementsTags").GetValue <Tag[]>());
                                    }

                                    if (building.Def.BuildingComplete.GetComponent <IHaveUtilityNetworkMgr>() != null)
                                    {
                                        buildingConfig.Flags = (int)building.Def.BuildingComplete.GetComponent <IHaveUtilityNetworkMgr>().GetNetworkManager()?.GetConnections(cell, false);
                                    }

                                    if (!blueprint.BuildingConfiguration.Contains(buildingConfig))
                                    {
                                        blueprint.BuildingConfiguration.Add(buildingConfig);
                                    }

                                    emptyCell = false;
                                }
                            }
                        }

                        if (emptyCell && (collectingGasTiles && !Grid.IsSolidCell(cell) || filter.IsActiveLayer(ToolParameterMenu.FILTERLAYERS.DIGPLACER) && Grid.Objects[cell, 7] != null && Grid.Objects[cell, 7].name == "DigPlacer"))
                        {
                            Vector2I digLocation = new Vector2I(x - topLeft.x, blueprintHeight - (topLeft.y - y));

                            if (!blueprint.DigLocations.Contains(digLocation))
                            {
                                blueprint.DigLocations.Add(digLocation);
                            }
                        }
                    }
                }
            }

            blueprint.CacheCost();
            return(blueprint);
        }