/// <summary> /// Add a connect to a given object and optional target input. /// </summary> /// <param name="targetObject">The object to target.</param> /// <param name="targetConnection">A optional argument of the target input on the object.</param> /// <returns>Returns true if a Connection object was added.</returns> public bool AddConnection(GameObject targetObject, string targetConnection = null) { if (!AllowMany && _connections.Count > 0) { return(false); // already connected. } Connection c = new Connection(); c.Start(this); c.TargetObject = targetObject; if (targetConnection != null) { c.TargetConnection = targetConnection; } if (!c.ResolveTargetInput()) { return(false); // couldn't resolve a input } _connections.Add(c); if (OnInputAdded != null) { OnInputAdded.Invoke(c.TargetInput); } return(true); }
/// <summary> /// Add a connection to this output, returns false if the connection can't be made. /// </summary> /// <param name="input">A reference to the connection to establish.</param> /// <returns>Returns true on success.</returns> public bool AddConnection(Input input) { if (!AllowMany && _connections.Count > 0) { return(false); // already connected. } if (input.DataType != DataType) { return(false); // wrong data type } Connection c = new Connection(); c.Start(this); c.TargetInput = input; _connections.Add(c); if (OnInputAdded != null) { OnInputAdded.Invoke(input); } return(true); }