public static void Switch(Node lampNode) { Lamp lamp = (Lamp)lampNode; if(lamp.enabled) { lamp.Disable(); } else { lamp.Enable(); } }
public LampSwitch(string name, Node connectedLamps) : base(name) { this.connectedLamps = connectedLamps; lampHead = new Entity(name + "_head"); lampPost = new Entity(name + "_post"); lampHead.mesh = new Mesh(); lampPost.mesh = new Mesh(); lampHead.mesh.polygonList = Lamp.lampHeadMesh.polygonList; lampPost.mesh.polygonList = Lamp.lampPostMesh.polygonList; lampHead.mesh.material.textureName = lampPost.mesh.material.textureName = "white"; lampHead.position = new Vector3(0f, 60f, 0f); lampHead.mesh.material.baseColor = new Color4(0.9f, 0.3f, 0.3f, 1.0f); lampPost.mesh.material.baseColor = new Color4(0.6f, 0.3f, 0.3f, 1.0f); Add(lampHead); Add(lampPost); }
/// <summary> /// Delete and detach specified child. /// </summary> /// <param name="node">The child</param> public void RemoveChild(Node node) { if(children.ContainsValue(node)) { node = null; children.Remove(node.name); //TODO: performance } }
/// <summary> /// Checks if this node contains the specified node. /// </summary> /// <param name="node">The node</param> /// <returns>True if this node contains the specified node</returns> public bool HasChild(Node node) { return this == node.parent; // TODO: performance check //return children.ContainsValue(node); }
public bool Equals(Node obj) { return name == obj.name; }
/// <summary> /// Add specified node as child. /// </summary> /// <param name="node">The node to be added</param> public void Add(Node node) { if(node == this) { } else { node.parent = this; children.Add(node.name, node); } }
/// <summary> /// Add specified node as child, and rename it. /// </summary> /// <param name="node">The node to be added</param> /// <param name="newName">The new node name</param> public void Add(Node node, string newName) { node.name = newName; if(node == this) { } else { node.parent = this; children.Add(node.name, node); } }