Exemplo n.º 1
0
    public static List <TriangleMeshNode> GetAllNodesInRadius(Vector3 origin, float radius)
    {
        //float radiusSquared = radius * radius;

        TriangleMeshNode root = AStarPathfindingUtils.GetNearestNodeOnNavMesh(origin);

        List <TriangleMeshNode> validNodes = new List <TriangleMeshNode>();

        EB.Collections.Queue <TriangleMeshNode> toCheck = new EB.Collections.Queue <TriangleMeshNode>();
        HashSet <TriangleMeshNode> visited = new HashSet <TriangleMeshNode>();

        toCheck.Enqueue(root);
        while (toCheck.Count > 0)
        {
            TriangleMeshNode curNode = toCheck.Dequeue();

            if (SphereXZTriangleIntersect(origin, radius, (Vector3)curNode.GetVertex(0), (Vector3)curNode.GetVertex(1), (Vector3)curNode.GetVertex(2)))
            {
                validNodes.Add(curNode);
                for (int i = 0; i < curNode.connections.Length; i++)
                {
                    TriangleMeshNode connection = curNode.connections[i] as TriangleMeshNode;
                    if (!visited.Contains(connection))
                    {
                        toCheck.Enqueue(connection);
                    }
                }
            }

            visited.Add(curNode);
        }

        return(validNodes);
    }
Exemplo n.º 2
0
 public void SetMovementTargetQueue(EB.Collections.Queue <Vector3> movePosQue, System.Action onEndCallback)
 {
     _movePosQue           = movePosQue;
     _onMoveEndActionByQue = onEndCallback;
     GlobalUtils.CallStaticHotfix("Hotfix_LT.UI.AlliancesManager", "RecordTransferPointFromILRWithCallback", _movePosQue.Count - 1);
     SetMovementTarget(_movePosQue.Dequeue(), false, true, false, true);
 }
Exemplo n.º 3
0
    // recursively fine the transform include inRoot and the whole hierarchy under the inRoot, this also include the object that is deactivate
    public static Transform SearchHierarchyForBone(Transform inRoot, string inName, bool ignoreDisabled = false)
    {
        if (inRoot == null || inName.Length <= 0)
        {
            return(null);
        }
        // check if the current bone is the bone we're looking for, if so return it
        if (inRoot.name.Equals(inName))
        {
            return(inRoot);
        }

        EB.Collections.Queue <Transform> queue = new EB.Collections.Queue <Transform>(16);
        Transform result = null;

        queue.Enqueue(inRoot);
        while (queue.Count > 0)
        {
            Transform it = queue.Dequeue();
            result = it.Find(inName);
            if (result && (!ignoreDisabled || result.gameObject.activeInHierarchy))
            {
                return(result);
            }

            int childCount = it.childCount;
            for (int i = 0; i < childCount; ++i)
            {
                queue.Enqueue(it.GetChild(i));
            }
        }
        return(null);
    }
Exemplo n.º 4
0
    public static Dictionary <int, GameObject> FindIndexedComponents(Transform root)
    {
        Dictionary <int, GameObject> allComponents = new Dictionary <int, GameObject>();

        EB.Collections.Queue <Transform> queue = new EB.Collections.Queue <Transform>(16);
        queue.Enqueue(root);
        while (queue.Count > 0)
        {
            Transform            it      = queue.Dequeue();
            IndexedZoneComponent indexer = it.GetComponent <IndexedZoneComponent>();

            if (indexer != null)
            {
                allComponents.Add(indexer.Index, indexer.gameObject);
            }

            int childCount = it.childCount;
            for (int i = 0; i < childCount; ++i)
            {
                queue.Enqueue(it.GetChild(i));
            }
        }

        return(allComponents);
    }
Exemplo n.º 5
0
    /// <summary>
    /// 让指定的ui队列中移除
    /// </summary>
    /// <param name="ui"></param>
    public void Dequeue(IStackableUI ui)
    {
        EB.Collections.Queue <IStackableUI> tmpQueue = new EB.Collections.Queue <IStackableUI>();

        while (_toEnstackWhenPossible.Count > 0)
        {
            IStackableUI q = _toEnstackWhenPossible.Dequeue();
            if (q == ui)
            {
                break;
            }

            tmpQueue.Enqueue(q);
        }

        while (_toEnstackWhenPossible.Count > 0)
        {
            tmpQueue.Enqueue(_toEnstackWhenPossible.Dequeue());
        }

        _toEnstackWhenPossible = tmpQueue;
    }
Exemplo n.º 6
0
    private IDebuggable[] GetAllSystemsFromPath(string systemPath, IDebuggable parent = null)
    {
        if (systemPath == null)
        {
            return(new IDebuggable[0]);
        }

        string[] names = systemPath.Split('/');
        if (names.Length == 0)
        {
            return(new IDebuggable[0]);
        }

        EB.Collections.Queue <IDebuggable> currents = new EB.Collections.Queue <IDebuggable>();
        foreach (IDebuggable sys in GetAllSystemsFromName(names[0]))
        {
            if (_gameSystems[sys].parent == parent && _gameSystems[sys].systemName == names[0])
            {
                currents.Enqueue(sys);
            }
        }

        for (int i = 1; i < names.Length; i++)
        {
            while (currents.Count > 0 && _gameSystems[currents.Peek()].systemName == names[i - 1])
            {
                foreach (IDebuggable sub in _gameSystems[currents.Dequeue()].subSystems)
                {
                    if (_gameSystems[sub].systemName == names[i])
                    {
                        currents.Enqueue(sub);
                    }
                }
            }
        }

        return(currents.ToArray());
    }