Esempio n. 1
0
        private void HandleConnect(MouseOverInteractable interactable)
        {
            if (ImprovedMouse.DidJustRightClick && !GameState.GameOver)
            {
                if (interactable.Type == InteractableType.Node)
                {
                    startConnection = interactable.Entity;
                    if (IsAlive(startConnection))
                    {
                        var connectionLine = new ConnectionLine(startConnection, this);
                        Parent.Add(connectionLine);
                        connecting = connectionLine;
                    }
                }

                SetTexture("handclick");
            }

            if (IsConnecting && ImprovedMouse.DidJustRightRelease)
            {
                if (interactable.Type == InteractableType.Node && CanConnect(connecting, startConnection, interactable.Entity))
                {
                    connecting.Connected(startConnection, interactable.Entity);
                    ConnectionHelper.RealignAllConnections();
                }
                else
                {
                    Parent.Remove(connecting);
                }
                SetTexture("hand");
                connecting = null;
            }
        }
Esempio n. 2
0
 private static void SwapEndsIfNeeded(ConnectionLine connection, Entity entity)
 {
     if (connection.End != entity)
     {
         var tmp = connection.Start;
         connection.Start = connection.End;
         connection.End   = tmp;
     }
 }
Esempio n. 3
0
        private bool CanConnect(ConnectionLine connection, Entity e1, Entity e2)
        {
            var areSame      = e1 == e2;
            var twoContracts = e1 is ContractEntity && e2 is ContractEntity;
            var areBothAlive = IsAlive(e1) && IsAlive(e2);

            return(!areSame &&
                   !twoContracts &&
                   areBothAlive &&
                   !connection.AlreadyHasConnection(e1, e2));
        }
Esempio n. 4
0
        private static void EnforceContractDirection(ConnectionLine connection)
        {
            if (connection.End is ContractEntity)
            {
                return;
            }

            var tmp = connection.Start;

            connection.Start = connection.End;
            connection.End   = tmp;
        }