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); } } }
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()); } } } }
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); }