예제 #1
0
        public static void AddWindow(GraphAsset asset) //ActionScriptGraphAsset graphAsset
        {
            GraphEditor window = (GraphEditor)GetWindow(typeof(GraphEditor));

            window.titleContent.text = "ActionFlow Graph Editor";
            window.Show();

            window.GraphAsset = asset;
            if (window._graphView != null)
            {
                window._graphView.Show(asset);
            }

            window.Repaint();
            // window.RefreshView();
            object t = null;

            if (t is int a)
            {
                Debug.Log(a);
            }
            Instance = window;

            //Debug.Log(t?.Length);
        }
예제 #2
0
 public List <Info> GetList(GraphAsset graphAsset)
 {
     if (Map.TryGetValue(graphAsset, out var list))
     {
         return(list.Infos);
     }
     return(null);
 }
예제 #3
0
 public InfoList GetInfoList(GraphAsset graphAsset)
 {
     if (Map.TryGetValue(graphAsset, out var list))
     {
         return(list);
     }
     return(null);
 }
예제 #4
0
 void Update()
 {
     if (GraphEditor.Instance?.GraphAsset != _CurrentGraph || setSelectedNode() == true)
     {
         _CurrentGraph = GraphEditor.Instance?.GraphAsset;
         DrawUI();
     }
 }
예제 #5
0
 public float GetInputTime(GraphAsset graphAsset, ActionStateIndex index)
 {
     if (Map.TryGetValue(graphAsset, out var infoList))
     {
         if (infoList.InputTime.TryGetValue(index, out var t))
         {
             return(t);
         }
     }
     return(-1000);
 }
예제 #6
0
 // private int _currentFrameCount = -1;
 // private float _currentFrameFirstTime = 0f;
 public void SetInputTime(GraphAsset graphAsset, ActionStateIndex index)
 {
     if (Map.TryGetValue(graphAsset, out var infoList))
     {
         var rTime = Time.realtimeSinceStartup;
         // if (_currentFrameCount != Time.frameCount)
         // {
         //     _currentFrameCount = Time.frameCount;
         //     _currentFrameFirstTime = rTime;// Time.realtimeSinceStartup;
         // }
         //Debug.Log($"Time:{CurrentFrameFirstTime}:{Time.realtimeSinceStartup}");
         infoList.InputTime[index] = rTime;//(rTime - _currentFrameFirstTime) * 100000f + rTime;
     }
 }
예제 #7
0
 public void Add(GraphAsset graphAsset, string name, ActionStateContainer container, int index)
 {
     if (Map.TryGetValue(graphAsset, out var list) == false)
     {
         list = new InfoList();
         Map.Add(graphAsset, list);
     }
     list.Version++;
     list.Infos.Add(new Info()
     {
         Name      = (name == string.Empty)?"Entity":name,
         container = container,
         Index     = index
     });
 }
예제 #8
0
        public static void AddWindow(GraphAsset asset) //ActionScriptGraphAsset graphAsset
        {
            GraphEditor window = (GraphEditor)GetWindow(typeof(GraphEditor));

            window.titleContent.text = "ActionFlow Graph Editor";
            window.Show();

            window.GraphAsset = asset;
            window._graphView?.Show(asset);

            window.Repaint();
            // window.RefreshView();
            Instance = window;

            //Debug.Log(t?.Length);
        }
예제 #9
0
        public Info GetInfo(GraphAsset graphAsset, int index)
        {
            var list = GetList(graphAsset);

            if (list == null)
            {
                return(null);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Index == index)
                {
                    return(list[i]);
                }
            }
            return(null);
        }
예제 #10
0
        public void Show(GraphAsset graphAsset)
        {
            if (graphAsset != GraphAsset)
            {
                GraphAsset = graphAsset;
                graphElements.ForEach((element) => RemoveElement(element));

                for (int i = 0; i < GraphAsset.Nodes.Count; i++)
                {
                    DrawNode(i);
                }
                for (int i = 0; i < GraphAsset.Nodes.Count; i++)
                {
                    DrawEdge(i);
                }
                this.UpdateViewTransform(graphAsset.ViewPosition, graphAsset.ViewScale);
            }
        }
 public ref ActionStateContainer GetContainer(GraphAsset graph)
 {
     if (_map.TryGetValue(graph.GetInstanceID(), out var actionStateContainer))
     {
         return(ref actionStateContainer[0]);
예제 #12
0
 void OnEnable()
 {
     _CurrentGraph = null;
 }
예제 #13
0
        public static ActionStateContainer Create(GraphAsset graph, int chunkCapacity = 5)
        {
            var container = new ActionStateContainer();
            // var builder = NativeStructMap.CreateBuilder();
            var builder = NativeStaticMapHead.CreateBuilder();
            var count   = graph.RuntimeNodes.Length;

            container._containerInfo = new NativeArray <Info>(1, Allocator.Persistent);
            var info = new Info {
                NodeCount = count
            };

            container._chunks = new NativeList <ActionStateChunk>(Allocator.Persistent);
            // container.Chunks.Add(new ActionStateChunk());
            container._nodes = new NativeArray <ActionStateNode>(count * chunkCapacity, Allocator.Persistent);
            info.ChunkCount  = 0;

            var capacity = 1000;
            var statePtr = (byte *)UnsafeUtility.Malloc(capacity, 4, Allocator.Temp);

            var offset = 0;

            for (var i = 0; i < count; i++)
            {
                var inode = graph.m_Nodes[i];// as INodeAsset;
                var node  = new ActionStateNode()
                {
                    Cycle = NodeCycle.Inactive, offset = offset
                };
                container._nodes[i] = node;

                if (inode is IStatusNode nodeObject)
                {
                    var t    = nodeObject.NodeDataType();
                    var size = UnsafeUtility.SizeOf(t);
                    if (offset + size > capacity)
                    {
                        capacity = capacity * 2;
                        var ptr = (byte *)UnsafeUtility.Malloc(capacity, 4, Allocator.Temp);
                        UnsafeUtility.MemCpy(ptr, statePtr, offset);
                        UnsafeUtility.Free(ptr, Allocator.Temp);
                        statePtr = ptr;
                    }
                    nodeObject.CreateNodeDataTo(statePtr + offset);
                    offset += size;
                }
                if (inode is IAccessBlackboard accessBlackboard)
                {
                    accessBlackboard.ToBuilder(builder);
                }
            }
            container._states = (byte *)UnsafeUtility.Malloc(offset * chunkCapacity, 4, Allocator.Persistent);
            UnsafeUtility.MemCpy(container._states, statePtr, offset);
            UnsafeUtility.Free(statePtr, Allocator.Temp);

            //var array = builder.ToNativeStructMapArray(chunkCapacity, Allocator.Persistent);
            var head       = builder.ToHead();
            var blackboard = NativeStaticMap.Create(ref head, chunkCapacity);

            //container.BlackboardArray = array;
            container._blackboard = blackboard;


            info.StatesSize             = offset;
            info.NodeCount              = count;
            info.ChunkCapacity          = chunkCapacity;
            container._containerInfo[0] = info;


            return(container);
        }