public static GraphReference Intern(GraphPointer pointer) { var hash = pointer.ComputeHashCode(); if (internPool.TryGetValue(hash, out var interns)) { foreach (var intern in interns) { if (intern.InstanceEquals(pointer)) { return(intern); } } var reference = New(pointer); interns.Add(reference); return(reference); } else { var reference = New(pointer); internPool.Add(reference.hashCode, new List <GraphReference>() { reference }); return(reference); } }
private static GraphReference New(GraphPointer model) { var reference = new GraphReference(); reference.CopyFrom(model); return(reference); }
internal static GraphStack New(GraphPointer model) { var stack = GenericPool <GraphStack> .New(() => new GraphStack()); stack.CopyFrom(model); return(stack); }
public static void HandleException(this IGraphElementWithDebugData element, GraphPointer pointer, Exception ex) { Ensure.That(nameof(ex)).IsNotNull(ex); if (pointer == null) { Debug.LogError("Caught exception with null graph pointer (flow was likely disposed):\n" + ex); return; } var reference = pointer.AsReference(); if (!ex.HandledIn(reference)) { element.SetException(pointer, ex); } while (reference.isChild) { var parentElement = reference.parentElement; reference = reference.ParentReference(true); if (parentElement is IGraphElementWithDebugData debuggableParentElement) { if (!ex.HandledIn(reference)) { debuggableParentElement.SetException(reference, ex); } } } }
public bool IsListening(GraphPointer pointer) { if (!pointer.hasData) { return(false); } return(pointer.GetElementData <Data>(this).isListening); }
public static GraphPointerData FromPointer(GraphPointer pointer) { if (pointer == null || !pointer.isValid) { return(null); } return(new GraphPointerData(pointer)); }
public static void SetException(this IGraphElementWithDebugData element, GraphPointer pointer, Exception ex) { if (!pointer.hasDebugData) { return; } var debugData = pointer.GetElementDebugData <IGraphElementDebugData>(element); debugData.runtimeException = ex; }
public override void CopyFrom(GraphPointer other) { base.CopyFrom(other); if (other is GraphReference reference) { hashCode = reference.hashCode; } else { Hash(); } }
public static VariableDeclarations Graph(GraphPointer pointer) { Ensure.That(nameof(pointer)).IsNotNull(pointer); if (pointer.hasData) { return(GraphInstance(pointer)); } else { return(GraphDefinition(pointer)); } }
// Active state detection happens twice: // // 1. Before the enumeration, because any state // that becomes active during an update shouldn't // be updated until the next update // // 2. Inside the update method, because a state // that was active during enumeration and no longer // is shouldn't be updated. private HashSet <IState> GetActiveStatesNoAlloc(GraphPointer pointer) { var activeStates = HashSetPool <IState> .New(); foreach (var state in states) { var stateData = pointer.GetElementData <State.Data>(state); if (stateData.isActive) { activeStates.Add(state); } } return(activeStates); }
public virtual void CopyFrom(GraphPointer other) { root = other.root; gameObject = other.gameObject; parentStack.Clear(); parentElementStack.Clear(); graphStack.Clear(); dataStack.Clear(); debugDataStack.Clear(); foreach (var parent in other.parentStack) { parentStack.Add(parent); } foreach (var parentElement in other.parentElementStack) { parentElementStack.Add(parentElement); } foreach (var graph in other.graphStack) { graphStack.Add(graph); } foreach (var data in other.dataStack) { dataStack.Add(data); } foreach (var debugData in other.debugDataStack) { debugDataStack.Add(debugData); } }
public static VariableDeclarations GraphInstance(GraphPointer pointer) { return(pointer.GetGraphData <IGraphDataWithVariables>().variables); }
public bool IsListening(GraphPointer pointer) { return(pointer.GetElementData <State.Data>(source).isActive); }
public static VariableDeclarations GraphDefinition(GraphPointer pointer) { return(GraphDefinition((IGraphWithVariables)pointer.graph)); }
public static Exception GetException(this IGraphElementWithDebugData element, GraphPointer pointer) { if (!pointer.hasDebugData) { return(null); } var debugData = pointer.GetElementDebugData <IGraphElementDebugData>(element); return(debugData.runtimeException); }
public bool IsListening(GraphPointer pointer) { return(pointer.GetElementData <Data>(this).isListening); }
private GraphPointerData(GraphPointer pointer) { rootObjectInstanceID = pointer.rootObject.GetInstanceID(); parentElementGuids = pointer.parentElementGuids.ToArray(); }
public RecursionNode(IUnitPort port, GraphPointer pointer) { this.port = port; this.context = pointer.parent; }
public bool IsListening(GraphPointer pointer) { return(pointer.GetGraphData <FlowGraphData>().isListening); }
public GraphPointerException(string message, GraphPointer pointer) : base(message + "\n" + pointer) { this.pointer = pointer; }