diff --git a/GameEngine/src/main/java/gameEngine/ConnectionManager.java b/GameEngine/src/main/java/gameEngine/ConnectionManager.java index 66fabec..8e3f740 100644 --- a/GameEngine/src/main/java/gameEngine/ConnectionManager.java +++ b/GameEngine/src/main/java/gameEngine/ConnectionManager.java @@ -3,13 +3,12 @@ import java.util.ArrayList; import java.util.List; -import gameEngine.entites.gameComponents.Connection; -import gameEngine.entites.gameComponents.PortView; +import gameEngine.entites.Entity; +import gameEngine.entites.GameObject; +import gameEngine.entites.gameComponents.*; import gameEngine.input.Input; import gameEngine.input.MouseInput; -import javax.sound.sampled.Port; - public class ConnectionManager { private List connections = new ArrayList<>(); private PortView pressedPort; @@ -23,6 +22,14 @@ System.out.println("Connect!"); Connection newConnection = new Connection(pressedPort, port); connections.add(newConnection); + + GameObject entityA = (GameObject) pressedPort.getParent(); + GameObject entityB = (GameObject) port.getParent(); + if(entityA.getComponent(EntityView.class) != null){ + entityA.ComponentConnections.add(entityB.getComponent(ComponentView.class).connectionType); + }else { + entityB.ComponentConnections.add(entityA.getComponent(ComponentView.class).connectionType); + } } pressedPort = null; }