/* * Should not be called directly; instead, add an edge and simply call Connect() */ public void Connect(ElectricNetworkConnector startConnector, ElectricNetworkConnector endConnector) { cableA.GetComponent <CableDrawer>().SetTransforms(startConnector.connectionPointA, endConnector.connectionPointA); cableB.GetComponent <CableDrawer>().SetTransforms(startConnector.connectionPointB, endConnector.connectionPointB); gameObject.transform.position = MathUtil.Midpoint(startConnector.transform.position, endConnector.transform.position); }
private void UpdateCablePreview() { ElectricNetworkConnector electricNetworkConnector = gameObjectToBePlaced.GetComponent <ElectricNetworkConnector>(); // First, clear all preview cables PlayerManager.electricNetworkManager.ClearPreviewNetworkEdges(); // Then add them for each electric node collider //TODO: Due to refactoring this should probably only be called, when the Preview Updates (and not each tick) electricNetworkConnector.ShowPlacementPreviewOfElectricNetworkNodeAddOn(PlayerManager.electricNetworkManager, electricCollisionHandler); }
private void Demolish(GameObject gameObject) { ElectricNetworkConnector electricNetworkConnector = gameObject.GetComponent <ElectricNetworkConnector>(); if (electricNetworkConnector != null) { electricNetworkConnector.HandleDemolishingBy(PlayerManager.electricNetworkManager); return; } Destroy(gameObject); }
private static List <ElectricNetworkNode> GetInteractedNetworkNodes(ElectricNetworkConnector triggeringConnector, CollisionHandler electricCollisionHandler) { ElectricNetworkConnector[] interactedConnectors = GetInteractedNetworkConnectors(triggeringConnector, electricCollisionHandler.enteredColliders.ToArray()); List <ElectricNetworkNode> interactedNodes = new List <ElectricNetworkNode>(); foreach (ElectricNetworkConnector interactedConnector in interactedConnectors) { if (interactedConnector == triggeringConnector) { continue; } interactedNodes.Add(interactedConnector.node); } return(interactedNodes); }
public void CompletePlacingGameObject() { if (electricCollisionHandler != null) { ElectricNetworkConnector electricNetworkConnector = gameObjectToBePlaced.GetComponent <ElectricNetworkConnector>(); UnlinkElectricColliderFromCablePreview(); PlayerManager.electricNetworkManager.ClearPreviewNetworkEdges(); electricNetworkConnector.HandlePlacement(PlayerManager.electricNetworkManager, electricCollisionHandler); } UnlinkFootprintColliderHandlerToModelDyerMaterialChanging(); PlayerManager.ResetInteractionState(); modelDyer.ChangeMaterialsBackToInitial(); gameObjectToBePlaced = null; modelDyer = null; }
public void Connect() { // Check if edge exists if (edge == null) { Debug.LogError($"ERROR CONNECTING CABLE: Edge in {this} is null. "); return; } // Check if the nodes in the pair are not null if (edge.nodes.Item1 == null || edge.nodes.Item2 == null) { Debug.LogError($"ERROR CONNECTING CABLE: One or both of the edge nodes are null. " + $"Node 1: {edge.nodes.Item1}; Node 2: {edge.nodes.Item2}. "); } // Actually Connect ElectricNetworkConnector connector1 = edge.nodes.Item1.connector; ElectricNetworkConnector connector2 = edge.nodes.Item2.connector; Connect(connector1, connector2); }
// Returns the Connector/Nodes, which are already there and get interacted with by the justAddedConnector. // The justAddedConnector is not included in the returned value. private static ElectricNetworkConnector[] GetInteractedNetworkConnectors(ElectricNetworkConnector justAddedConnector, Collider[] colliders) { List <ElectricNetworkConnector> connectorsList = new List <ElectricNetworkConnector>(); foreach (Collider collider in colliders) { ElectricNetworkConnector connector = collider.transform.parent.gameObject.GetComponent <ElectricNetworkConnector>(); if (connector == null) { Debug.LogError("There is no ElectricNetworkConnector component connected to " + collider.transform.parent.gameObject + ". "); } if (connector == justAddedConnector) { continue; } connectorsList.Add(connector); } return(connectorsList.ToArray()); }
public ElectricNetworkNode(ElectricNetworkConnector connector) { this.connector = connector; }