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