protected override void OnDragTool(int cell, int distFromOrigin) { GameObject gameObject = Grid.Objects[cell, 3]; if (!((Object)gameObject == (Object)null)) { ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem; while (objectLayerListItem != null) { GameObject gameObject2 = objectLayerListItem.gameObject; objectLayerListItem = objectLayerListItem.nextItem; if (!((Object)gameObject2 == (Object)null) && !((Object)gameObject2.GetComponent <MinionIdentity>() != (Object)null)) { Clearable component = gameObject2.GetComponent <Clearable>(); if (component.isClearable) { gameObject2.GetComponent <Clearable>().MarkForClear(false); Prioritizable component2 = gameObject2.GetComponent <Prioritizable>(); if ((Object)component2 != (Object)null) { component2.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } } }
protected override void OnDragTool(int cell, int distFromOrigin) { for (int i = 0; i < 39; i++) { if (IsActiveLayer((ObjectLayer)i)) { GameObject gameObject = Grid.Objects[cell, i]; if (!((Object)gameObject == (Object)null)) { EmptyConduitWorkable component = gameObject.GetComponent <EmptyConduitWorkable>(); if (!((Object)component == (Object)null)) { if (DebugHandler.InstantBuildMode) { component.EmptyPipeContents(); } else { component.MarkForEmptying(); Prioritizable component2 = gameObject.GetComponent <Prioritizable>(); if ((Object)component2 != (Object)null) { component2.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } } } }
protected override void OnDragTool(int cell, int distFromOrigin) { for (int index = 0; index < 40; ++index) { if (MultiToolParameterMenu.Instance.IsActiveLayer((ObjectLayer)index)) { GameObject gameObject = Grid.Objects[cell, index]; if (gameObject != null) { EmptyConduitWorkable conduitWorkable = gameObject.GetComponent <EmptyConduitWorkable>(); if (conduitWorkable != null) { if (DebugHandler.InstantBuildMode) { conduitWorkable.EmptyPipeContents(); } else { conduitWorkable.MarkForEmptying(); Prioritizable prioritizable = gameObject.GetComponent <Prioritizable>(); if (prioritizable != null) { prioritizable.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } } } }
protected override void OnDragTool(int cell, int distFromOrigin) { if (Grid.IsValidCell(cell)) { foreach (HarvestDesignatable item in Components.HarvestDesignatables.Items) { OccupyArea area = item.area; if (Grid.PosToCell(item) == cell || ((Object)area != (Object)null && area.CheckIsOccupying(cell))) { if (options["HARVEST_WHEN_READY"] == ToolParameterMenu.ToggleState.On) { item.SetHarvestWhenReady(true); } else if (options["DO_NOT_HARVEST"] == ToolParameterMenu.ToggleState.On) { item.SetHarvestWhenReady(false); } Prioritizable component = item.GetComponent <Prioritizable>(); if ((Object)component != (Object)null) { component.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } }
private bool TryPrioritizeGameObject(GameObject target, PrioritySetting priority) { if (MultiToolParameterMenu.Instance.IsActiveLayer(GetFilterLayerFromGameObject(target))) { Prioritizable prioritizable = target.GetComponent <Prioritizable>(); if (prioritizable != null && prioritizable.showIcon && prioritizable.IsPrioritizable()) { prioritizable.SetMasterPriority(priority); return(true); } } return(false); }
private bool TryPrioritizeGameObject(GameObject target, PrioritySetting priority) { string filterLayerFromGameObject = GetFilterLayerFromGameObject(target); if (IsActiveLayer(filterLayerFromGameObject)) { Prioritizable component = target.GetComponent <Prioritizable>(); if ((Object)component != (Object)null && component.showIcon && component.IsPrioritizable()) { component.SetMasterPriority(priority); return(true); } } return(false); }
protected override void OnDragTool(int cell, int distFromOrigin) { if (Grid.IsValidCell(cell)) { if (DebugHandler.InstantBuildMode) { if (Grid.IsValidCell(cell)) { Moppable.MopCell(cell, 1000000f, null); } } else { GameObject gameObject = Grid.Objects[cell, 8]; if (!Grid.Solid[cell] && (Object)gameObject == (Object)null && Grid.Element[cell].IsLiquid) { bool flag = Grid.Solid[Grid.CellBelow(cell)]; bool flag2 = Grid.Mass[cell] <= maxMopAmt; if (flag && flag2) { gameObject = (Grid.Objects[cell, 8] = Util.KInstantiate(Placer, null, null)); Vector3 position = Grid.CellToPosCBC(cell, visualizerLayer); float num = -0.15f; position.z += num; gameObject.transform.SetPosition(position); gameObject.SetActive(true); } else { string text = UI.TOOLS.MOP.TOO_MUCH_LIQUID; if (!flag) { text = UI.TOOLS.MOP.NOT_ON_FLOOR; } PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, text, null, Grid.CellToPosCBC(cell, visualizerLayer), 1.5f, false, false); } } if ((Object)gameObject != (Object)null) { Prioritizable component = gameObject.GetComponent <Prioritizable>(); if ((Object)component != (Object)null) { component.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } }
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 void DeconstructCell(int cell) { for (int i = 0; i < 39; i++) { GameObject gameObject = Grid.Objects[cell, i]; if ((Object)gameObject != (Object)null) { string filterLayerFromGameObject = GetFilterLayerFromGameObject(gameObject); if (IsActiveLayer(filterLayerFromGameObject)) { gameObject.Trigger(-790448070, null); Prioritizable component = gameObject.GetComponent <Prioritizable>(); if ((Object)component != (Object)null) { component.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } } }
public void MarkForCapture(bool mark, PrioritySetting priority) { mark = (mark && IsCapturable()); if (markedForCapture && !mark) { Prioritizable.RemoveRef(base.gameObject); } else if (!markedForCapture && mark) { Prioritizable.AddRef(base.gameObject); Prioritizable component = GetComponent <Prioritizable>(); if ((bool)component) { component.SetMasterPriority(priority); } } markedForCapture = mark; UpdateStatusItem(); UpdateChore(); }
protected override void OnDragTool(int cell, int distFromOrigin) { if (!Grid.Solid[cell]) { foreach (Uprootable item in Components.Uprootables.Items) { if (Grid.PosToCell(item.gameObject) == cell) { item.MarkForUproot(true); break; } OccupyArea area = item.area; if ((Object)area != (Object)null && area.CheckIsOccupying(cell)) { item.MarkForUproot(true); } } } if (DebugHandler.InstantBuildMode) { if (Grid.IsValidCell(cell) && Grid.Solid[cell] && !Grid.Foundation[cell]) { WorldDamage.Instance.DestroyCell(cell, -1); } } else { GameObject gameObject = PlaceDig(cell, distFromOrigin); if ((Object)gameObject != (Object)null) { Prioritizable component = gameObject.GetComponent <Prioritizable>(); if ((Object)component != (Object)null) { component.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } } }
public static void Postfix(DeconstructTool __instance, int cell) { if (!((FilteredDragTool)__instance).IsActiveLayer(ToolParameterMenu.FILTERLAYERS.BACKWALL)) { return; } if (!MyGrid.IsScaffolding(cell)) { return; } GameObject gameObject = Grid.Objects[cell, (int)ObjectLayer.AttachableBuilding]; if (gameObject != null) { gameObject.Trigger(-790448070, null); Prioritizable component = gameObject.GetComponent <Prioritizable>(); if (component != null) { component.SetMasterPriority(ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority()); } } }
private void TryBuild(int cell) { if (!((Object)visualizer == (Object)null) && (cell != lastDragCell || buildingOrientation != lastDragOrientation)) { int num = Grid.PosToCell(visualizer); if (num == cell || (!(bool)def.BuildingComplete.GetComponent <LogicPorts>() && !(bool)def.BuildingComplete.GetComponent <LogicGateBase>())) { lastDragCell = cell; lastDragOrientation = buildingOrientation; ClearTilePreview(); Vector3 vector = Grid.CellToPosCBC(cell, Grid.SceneLayer.Building); GameObject gameObject = null; if (DebugHandler.InstantBuildMode || (Game.Instance.SandboxModeActive && SandboxToolParameterMenu.instance.settings.InstantBuild)) { if (def.IsValidBuildLocation(visualizer, vector, buildingOrientation) && def.IsValidPlaceLocation(visualizer, vector, buildingOrientation, out string _)) { gameObject = def.Build(cell, buildingOrientation, null, selectedElements, 293.15f, false, GameClock.Instance.GetTime()); if ((Object)source != (Object)null) { source.DeleteObject(); } } } else { gameObject = def.TryPlace(visualizer, vector, buildingOrientation, selectedElements, 0); if ((Object)gameObject == (Object)null && def.ReplacementLayer != ObjectLayer.NumLayers) { GameObject replacementCandidate = def.GetReplacementCandidate(cell); if ((Object)replacementCandidate != (Object)null && !def.IsReplacementLayerOccupied(cell)) { BuildingComplete component = replacementCandidate.GetComponent <BuildingComplete>(); if ((Object)component != (Object)null && component.Def.Replaceable && def.CanReplace(replacementCandidate) && ((Object)component.Def != (Object)def || selectedElements[0] != replacementCandidate.GetComponent <PrimaryElement>().Element.tag)) { gameObject = def.TryReplaceTile(visualizer, vector, buildingOrientation, selectedElements, 0); Grid.Objects[cell, (int)def.ReplacementLayer] = gameObject; } } } if ((Object)gameObject != (Object)null) { Prioritizable component2 = gameObject.GetComponent <Prioritizable>(); if ((Object)component2 != (Object)null) { if ((Object)BuildMenu.Instance != (Object)null) { component2.SetMasterPriority(BuildMenu.Instance.GetBuildingPriority()); } if ((Object)PlanScreen.Instance != (Object)null) { component2.SetMasterPriority(PlanScreen.Instance.GetBuildingPriority()); } } if ((Object)source != (Object)null) { source.Trigger(2121280625, gameObject); } } } if ((Object)gameObject != (Object)null) { if (def.MaterialsAvailable(selectedElements) || DebugHandler.InstantBuildMode) { placeSound = GlobalAssets.GetSound("Place_Building_" + def.AudioSize, false); if (placeSound != null) { buildingCount = buildingCount % 14 + 1; EventInstance instance = SoundEvent.BeginOneShot(placeSound, vector); if (def.AudioSize == "small") { instance.setParameterValue("tileCount", (float)buildingCount); } SoundEvent.EndOneShot(instance); } } else { PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, UI.TOOLTIPS.NOMATERIAL, null, vector, 1.5f, false, false); } Rotatable component3 = gameObject.GetComponent <Rotatable>(); if ((Object)component3 != (Object)null) { component3.SetOrientation(buildingOrientation); } } } } }
private void BuildPath() { ApplyPathToConduitSystem(); int num = 0; for (int i = 0; i < path.Count; i++) { PathNode pathNode = path[i]; Vector3 vector = Grid.CellToPosCBC(pathNode.cell, Grid.SceneLayer.Building); UtilityConnections utilityConnections = (UtilityConnections)0; GameObject gameObject = Grid.Objects[pathNode.cell, (int)def.TileLayer]; if ((Object)gameObject == (Object)null) { utilityConnections = conduitMgr.GetConnections(pathNode.cell, false); if ((DebugHandler.InstantBuildMode || (Game.Instance.SandboxModeActive && SandboxToolParameterMenu.instance.settings.InstantBuild)) && def.IsValidBuildLocation(visualizer, vector, Orientation.Neutral) && def.IsValidPlaceLocation(visualizer, vector, Orientation.Neutral, out string _)) { BuildingDef buildingDef = def; int cell = pathNode.cell; Orientation orientation = Orientation.Neutral; Storage resource_storage = null; IList <Tag> selected_elements = selectedElements; float temperature = 293.15f; float time = GameClock.Instance.GetTime(); gameObject = buildingDef.Build(cell, orientation, resource_storage, selected_elements, temperature, true, time); } else { gameObject = def.TryPlace(null, vector, Orientation.Neutral, selectedElements, 0); if ((Object)gameObject != (Object)null) { if (!def.MaterialsAvailable(selectedElements) && !DebugHandler.InstantBuildMode) { PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, UI.TOOLTIPS.NOMATERIAL, null, vector, 1.5f, false, false); } Constructable component = gameObject.GetComponent <Constructable>(); if (component.IconConnectionAnimation(0.1f * (float)num, num, "Wire", "OutletConnected_release") || component.IconConnectionAnimation(0.1f * (float)num, num, "Pipe", "OutletConnected_release")) { num++; } Prioritizable component2 = gameObject.GetComponent <Prioritizable>(); if ((Object)component2 != (Object)null) { if ((Object)BuildMenu.Instance != (Object)null) { component2.SetMasterPriority(BuildMenu.Instance.GetBuildingPriority()); } if ((Object)PlanScreen.Instance != (Object)null) { component2.SetMasterPriority(PlanScreen.Instance.GetBuildingPriority()); } } } } } else { IUtilityItem component3 = gameObject.GetComponent <KAnimGraphTileVisualizer>(); if (component3 != null) { utilityConnections = component3.Connections; } utilityConnections |= conduitMgr.GetConnections(pathNode.cell, false); if ((Object)gameObject.GetComponent <BuildingComplete>() != (Object)null) { component3.UpdateConnections(utilityConnections); } } if (def.ReplacementLayer != ObjectLayer.NumLayers && !DebugHandler.InstantBuildMode && (!Game.Instance.SandboxModeActive || !SandboxToolParameterMenu.instance.settings.InstantBuild) && def.IsValidBuildLocation(null, vector, Orientation.Neutral)) { GameObject gameObject2 = Grid.Objects[pathNode.cell, (int)def.TileLayer]; GameObject x = Grid.Objects[pathNode.cell, (int)def.ReplacementLayer]; if ((Object)gameObject2 != (Object)null && (Object)x == (Object)null) { BuildingComplete component4 = gameObject2.GetComponent <BuildingComplete>(); if ((Object)component4 != (Object)null && (Object)component4.Def != (Object)def) { Constructable component5 = def.BuildingUnderConstruction.GetComponent <Constructable>(); component5.IsReplacementTile = true; gameObject = def.Instantiate(vector, Orientation.Neutral, selectedElements, 0); component5.IsReplacementTile = false; if (!def.MaterialsAvailable(selectedElements) && !DebugHandler.InstantBuildMode) { PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, UI.TOOLTIPS.NOMATERIAL, null, vector, 1.5f, false, false); } Grid.Objects[pathNode.cell, (int)def.ReplacementLayer] = gameObject; IUtilityItem component6 = gameObject.GetComponent <KAnimGraphTileVisualizer>(); if (component6 != null) { utilityConnections = component6.Connections; } utilityConnections |= conduitMgr.GetConnections(pathNode.cell, false); if ((Object)gameObject.GetComponent <BuildingComplete>() != (Object)null) { component6.UpdateConnections(utilityConnections); } string visualizerString = conduitMgr.GetVisualizerString(utilityConnections); string text = visualizerString; if (gameObject.GetComponent <KBatchedAnimController>().HasAnimation(visualizerString + "_place")) { text += "_place"; } Play(gameObject, text); } } } if ((Object)gameObject != (Object)null) { IUtilityItem component7 = gameObject.GetComponent <KAnimGraphTileVisualizer>(); if (component7 != null) { component7.Connections = utilityConnections; } } TileVisualizer.RefreshCell(pathNode.cell, def.TileLayer, def.ReplacementLayer); } ResourceRemainingDisplayScreen.instance.SetNumberOfPendingConstructions(0); }