Exemple #1
0
        public static SerializedNavigationLink New(int p_startNode, int p_endNode)
        {
            SerializedNavigationLink thiz = new SerializedNavigationLink();

            thiz.StartNode = p_startNode;
            thiz.EndNode   = p_endNode;
            return(thiz);
        }
Exemple #2
0
 private void OnNavigationNodeLinkRemoved(NavigationNodeEditorComponentLink p_NavigationNodeEditorComponentLink)
 {
     for (int i = 0; i < m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks.Count; i++)
     {
         SerializedNavigationLink l_serializedNavigationLink = m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks[i];
         if (l_serializedNavigationLink.StartNode == m_serializedNavigationNodeId && l_serializedNavigationLink.EndNode == p_NavigationNodeEditorComponentLink.TargetNodeID)
         {
             m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks.RemoveAt(i);
             EditorUtility.SetDirty(m_navigationGraphEditorReference.NavigationGraphAsset);
             RefreshLinks();
             break;
         }
     }
 }
Exemple #3
0
 private void RefreshLinks()
 {
     if (m_lastFrameSelection.Get())
     {
         NavigationNodeEditorComponentLinks.NavigationNodeEditorComponentLink.Clear();
         for (int i = 0; i < m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks.Count; i++)
         {
             SerializedNavigationLink l_serializedNavigationLink = m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks[i];
             if (l_serializedNavigationLink.StartNode == m_serializedNavigationNodeId)
             {
                 NavigationNodeEditorComponentLinks.NavigationNodeEditorComponentLink.Add(NavigationNodeEditorComponentLink.New(l_serializedNavigationLink.EndNode, OnNavigationNodeLinkRemoved));
             }
         }
     }
 }
Exemple #4
0
        private void OnNavigationLinkCreation()
        {
            RefreshLinks();
            for (int i = 0; i < m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks.Count; i++)
            {
                SerializedNavigationLink l_serializedNavigationLink = m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks[i];
                if (l_serializedNavigationLink.StartNode == m_serializedNavigationNodeId && l_serializedNavigationLink.EndNode == m_navigationLinkCreation_endNode)
                {
                    return;
                }
            }

            m_navigationGraphEditorReference.NavigationGraphAsset.NavigationLinks.Add(SerializedNavigationLink.New(m_serializedNavigationNodeId, m_navigationLinkCreation_endNode));
            EditorUtility.SetDirty(m_navigationGraphEditorReference.NavigationGraphAsset);
            RefreshLinks();
        }
Exemple #5
0
        private void CalculateLinkTravelCosts()
        {
            if (NavigationGraphAsset != null)
            {
                for (int i = 0; i < NavigationGraphAsset.NavigationLinks.Count; i++)
                {
                    SerializedNavigationLink l_navigationLink      = NavigationGraphAsset.NavigationLinks[i];
                    SerializedNavigationNode l_startNodeSerialized = NavigationGraphAsset.NavigationNodes[l_navigationLink.StartNode];
                    SerializedNavigationNode l_endNodeSerialized   = NavigationGraphAsset.NavigationNodes[l_navigationLink.EndNode];
                    float l_travelCost = Vector3.Distance(l_startNodeSerialized.LocalPosition, l_endNodeSerialized.LocalPosition);
                    l_navigationLink.TravelCost             = l_travelCost;
                    NavigationGraphAsset.NavigationLinks[i] = l_navigationLink;
                }

                EditorUtility.SetDirty(NavigationGraphAsset);
            }
        }
Exemple #6
0
        public void RemoveNodeAndItsLinks(int p_nodeID)
        {
            if (NavigationGraphAsset != null)
            {
                if (NavigationGraphAsset.NavigationNodes.ContainsKey(p_nodeID))
                {
                    NavigationGraphAsset.NavigationNodes.Remove(p_nodeID);

                    for (int i = NavigationGraphAsset.NavigationLinks.Count - 1; i >= 0; i--)
                    {
                        SerializedNavigationLink l_navigationLink = NavigationGraphAsset.NavigationLinks[i];
                        if (l_navigationLink.StartNode == p_nodeID || l_navigationLink.EndNode == p_nodeID)
                        {
                            NavigationGraphAsset.NavigationLinks.RemoveAt(i);
                        }
                    }
                }

                EditorUtility.SetDirty(NavigationGraphAsset);
            }
        }