Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        private static GraphReference New(GraphPointer model)
        {
            var reference = new GraphReference();

            reference.CopyFrom(model);
            return(reference);
        }
Esempio n. 3
0
        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);
                    }
                }
            }
        }
Esempio n. 5
0
        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;
        }
Esempio n. 8
0
        public override void CopyFrom(GraphPointer other)
        {
            base.CopyFrom(other);

            if (other is GraphReference reference)
            {
                hashCode = reference.hashCode;
            }
            else
            {
                Hash();
            }
        }
Esempio n. 9
0
        public static VariableDeclarations Graph(GraphPointer pointer)
        {
            Ensure.That(nameof(pointer)).IsNotNull(pointer);

            if (pointer.hasData)
            {
                return(GraphInstance(pointer));
            }
            else
            {
                return(GraphDefinition(pointer));
            }
        }
Esempio n. 10
0
        // 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);
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
 public static VariableDeclarations GraphInstance(GraphPointer pointer)
 {
     return(pointer.GetGraphData <IGraphDataWithVariables>().variables);
 }
 public bool IsListening(GraphPointer pointer)
 {
     return(pointer.GetElementData <State.Data>(source).isActive);
 }
Esempio n. 14
0
 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);
        }
Esempio n. 16
0
 public bool IsListening(GraphPointer pointer)
 {
     return(pointer.GetElementData <Data>(this).isListening);
 }
 private GraphPointerData(GraphPointer pointer)
 {
     rootObjectInstanceID = pointer.rootObject.GetInstanceID();
     parentElementGuids   = pointer.parentElementGuids.ToArray();
 }
Esempio n. 18
0
 public RecursionNode(IUnitPort port, GraphPointer pointer)
 {
     this.port    = port;
     this.context = pointer.parent;
 }
Esempio n. 19
0
 public bool IsListening(GraphPointer pointer)
 {
     return(pointer.GetGraphData <FlowGraphData>().isListening);
 }
 public GraphPointerException(string message, GraphPointer pointer) : base(message + "\n" + pointer)
 {
     this.pointer = pointer;
 }