Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function recursiveNodeTraversalVisibility(_nodeIndex:Int) {
- node_visited[_nodeIndex] = true;
- trace(_nodeIndex);
- var node = nodes[_nodeIndex];
- var fronsubsec:Bool = false;
- var backsubsec:Bool = false;
- //Check if we've gone down both nodes
- if (node_visited[node.frontChildID] && node_visited[node.backChildID]) {
- if (node.parent == -1) {
- trace("I didn't continue, top of tree, both visited!");
- return;
- }
- trace("Both nodes visited, visiting my mama!");
- recursiveNodeTraversalVisibility(node.parent);
- return;
- }
- if (node_visited[node.frontChildID]) {
- fronsubsec = true;
- trace("Front was visited"); //<- Won't continue past here if met
- }
- if (node_visited[node.backChildID]) {
- backsubsec = true;
- trace("back was visited"); //<- Won't continue past here if met
- }
- if (fronsubsec == true && backsubsec == true) {
- recursiveNodeTraversalVisibility(node.parent);
- trace("I went back up!");
- return;
- } else {
- if (node.frontChildID & Node.SUBSECTORIDENTIFIER > 0) {
- fronsubsec = true;
- subsectorVisibilityCheck(node.frontChildID & (~Node.SUBSECTORIDENTIFIER));
- trace("Front side is a node!");
- }
- if (node.backChildID & Node.SUBSECTORIDENTIFIER > 0) {
- backsubsec = true;
- subsectorVisibilityCheck(node.backChildID & (~Node.SUBSECTORIDENTIFIER));
- trace("Back side is a node!");
- }
- }
- //Do we need to keep searching down the tree?
- if (fronsubsec == true && backsubsec == false) {
- recursiveNodeTraversalVisibility(node.backChildID);
- trace("I went down front, but not back");
- return;
- }
- if (fronsubsec == false && backsubsec == true) {
- recursiveNodeTraversalVisibility(node.frontChildID);
- trace("I went down back, but not front");
- return;
- }
- if (fronsubsec == true && backsubsec == true) {
- recursiveNodeTraversalVisibility(node.parent);
- trace("Let's visit papa just in case");
- return;
- }
- //neither have been visited, neither are subsectors, so which one is closer?
- var isOnBack:Bool = isPointOnBackSide(actors_players[0].xpos, actors_players[0].ypos, _nodeIndex);
- trace(isOnBack);
- if (isOnBack) {
- trace("Back was closer, so I went that way");
- recursiveNodeTraversalVisibility(node.backChildID);
- } else {
- trace("Front was closer, so I went that way");
- recursiveNodeTraversalVisibility(node.frontChildID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement