public StateConnection(State from, State to, StateConnectionContext context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) : base(from, to, direction, weight) { Context = context; }
public StateConnection(string trigger, State from, State to, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) : base(from, to, direction, weight) { Context.Trigger = trigger; }
public NodeConnection(N from, N to, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) { ID = Guid.NewGuid(); From = from; To = to; Direction = direction; Weight = weight; }
public NC ConnectTo(N to, C context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) { if (to == null) { Debug.LogError("[LinkedNode:ConnectTo()] -> Target node cannot be null."); return(null); } if (to == this) { Debug.LogError("[LinkedNode:ConnectTo()] -> You cant connect to yourself."); return(null); } NC newConnection = Owner.CreateConnection(this as N, to, context, direction, weight); Connections.Add(newConnection); to.Connections.Add(newConnection); OnConnectionAdd?.Invoke(newConnection); return(newConnection); }
public NodeConnection(NodeConnectionDirection direction, int fromSupernode, int toSupernode) { Direction = direction; FromSupernode = fromSupernode; ToSupernode = toSupernode; }
public StateConnection ConnectTo(State targetState, string triggerName, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional) { if (targetState.HasSubGraph) { Debug.Log("[State:ConnectTo] -> You cant connect to a state with sub graph"); return(null); } if (targetState.IsAnyState) { Debug.Log("[State:ConnectTo] -> You cant connect to a Any State"); return(null); } StateMachine[] targetStateMachineHierarchy = targetState.Owner.GraphHierarchy; StateMachine[] selfStateMachineHierarchy = Owner.GraphHierarchy; if (targetStateMachineHierarchy != null && selfStateMachineHierarchy != null && targetStateMachineHierarchy.Length > 0 && selfStateMachineHierarchy.Length > 0) { if (targetStateMachineHierarchy[0] != selfStateMachineHierarchy[0]) { Debug.Log( "[State:ConnectTo] -> A state cannot connect to another state that is not in the same state machine family."); return(null); } } else { Debug.Log("[State:ConnectTo] -> Unable to verify that states are from the same family."); return(null); } if (outboundConnectionsLookup.ContainsKey(triggerName)) { Debug.Log( "[State:ConnectTo] -> A state cannot have multiple outbound transitions with the same trigger."); return(null); } if (targetState.outboundConnectionsLookup.ContainsKey(triggerName)) { if (targetState.outboundConnectionsLookup[triggerName].To == this) { if (targetState.outboundConnectionsLookup[triggerName].Direction == NodeConnectionDirection.Bidirectional) { Debug.Log( "[State:ConnectTo] -> Trigger is already registered as outbound transition and as inbound transition."); return(null); } targetState.outboundConnectionsLookup[triggerName].Direction = NodeConnectionDirection.Bidirectional; return(targetState.outboundConnectionsLookup[triggerName]); } } StateConnectionContext context; context.Trigger = triggerName; return(base.ConnectTo(targetState, context, direction)); }
public NodeConnection(NodeConnectionDirection direction, BitcoinEndpoint endpoint) { this.direction = direction; this.endpoint = endpoint; }
/// <summary> /// Adds a connection to the collection. /// <para/> /// Can reject the connection if the cancellation token was cancelled or the maximum number of connections is reached. /// </summary> /// <param name="direction">The direction of the connection.</param> /// <param name="endpoint">The connection to a Bitcoin node.</param> /// <returns>true if the connection was accepted; otherwise false.</returns> public bool Add(NodeConnectionDirection direction, BitcoinEndpoint endpoint) { NodeConnection connection = new NodeConnection(direction, endpoint); lock (lockObject) { if (!CanRegister(connection)) { return false; } if (direction == NodeConnectionDirection.Incoming) { incomingConnectionsCount++; } else if (direction == NodeConnectionDirection.Outgoing) { outgoingConnectionsCount++; } else { throw new InvalidOperationException($"Unexpected connection direction: {direction}."); } connections.Add(connection); } endpoint.CallWhenDisconnected(() => Remove(connection)); Changed?.Invoke(); return true; }
public abstract NC CreateConnection(N from, N to, C context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0);
public override StateConnection CreateConnection(State from, State to, StateConnectionContext context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) { return(new StateConnection(from, to, context, direction, weight)); }
public NodeConnection(N from, N to, C context, NodeConnectionDirection direction = NodeConnectionDirection.Bidirectional, float weight = 0) : this(from, to, direction, weight) { Context = context; }