Advertisement
Guest User

Node

a guest
Jul 17th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package engine.terrain;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class Node {
  7.    
  8.     private Node parent;
  9.     private List<Node> children;
  10.    
  11.     public Node() {
  12.         this.children = new ArrayList<Node>();
  13.     }
  14.    
  15.     public void update() {
  16.         for(Node child : children) {
  17.             child.update();
  18.         }
  19.     }
  20.    
  21.     public void render() {
  22.         for(Node child : children) {
  23.             child.render();
  24.         }
  25.     }
  26.    
  27.     public void addChild(Node node) {
  28.         children.add(node);
  29.         node.setParent(this);
  30.     }
  31.  
  32.     public Node getParent() {
  33.         return parent;
  34.     }
  35.  
  36.     public void setParent(Node parent) {
  37.         this.parent = parent;
  38.     }
  39.  
  40.     public List<Node> getChildren() {
  41.         return children;
  42.     }
  43.  
  44.     public void setChildren(List<Node> children) {
  45.         this.children = children;
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement