update() {
        if (embed) return;

        if (this == simulationArea.hover) simulationArea.hover = undefined;
        this.hover = this.isHover();

        if (!simulationArea.mouseDown) {
            if (this.absX() != this.prevx || this.absY() != this.prevy) { // Connect to any node
                this.prevx = this.absX();
                this.prevy = this.absY();
                this.nodeConnect();
            }
        }

        if (this.hover) {
            simulationArea.hover = this;
        }

        if (simulationArea.mouseDown && ((this.hover && !simulationArea.selected) || simulationArea.lastSelected == this)) {
            simulationArea.selected = true;
            simulationArea.lastSelected = this;
            this.clicked = true;
        } else {
            this.clicked = false;
        }

        if (!this.wasClicked && this.clicked) {
            this.wasClicked = true;
            this.prev = 'a';
            if (this.type == NODE_INTERMEDIATE) {
                if (!simulationArea.shiftDown && simulationArea.multipleObjectSelections.contains(this)) {
                    for (var i = 0; i < simulationArea.multipleObjectSelections.length; i++) {
                        simulationArea.multipleObjectSelections[i].startDragging();
                    }
                }

                if (simulationArea.shiftDown) {
                    simulationArea.lastSelected = undefined;
                    if (simulationArea.multipleObjectSelections.contains(this)) {
                        simulationArea.multipleObjectSelections.clean(this);
                    } else {
                        simulationArea.multipleObjectSelections.push(this);
                    }
                } else {
                    simulationArea.lastSelected = this;
                }
            }
        } else if (this.wasClicked && this.clicked) {
            if (!simulationArea.shiftDown && simulationArea.multipleObjectSelections.contains(this)) {
                for (var i = 0; i < simulationArea.multipleObjectSelections.length; i++) {
                    simulationArea.multipleObjectSelections[i].drag();
                }
            }
            if (this.type == NODE_INTERMEDIATE) {
                if (this.connections.length == 1 && this.connections[0].absX() == simulationArea.mouseX && this.absX() == simulationArea.mouseX) {
                    this.y = simulationArea.mouseY - this.parent.y;
                    this.prev = 'a';
                    return;
                } if (this.connections.length == 1 && this.connections[0].absY() == simulationArea.mouseY && this.absY() == simulationArea.mouseY) {
                    this.x = simulationArea.mouseX - this.parent.x;
                    this.prev = 'a';
                    return;
                }
                if (this.connections.length == 1 && this.connections[0].absX() == this.absX() && this.connections[0].absY() == this.absY()) {
                    this.connections[0].clicked = true;
                    this.connections[0].wasClicked = true;
                    simulationArea.lastSelected = this.connections[0];
                    this.delete();
                    return;
                }
            }

            if (this.prev == 'a' && distance(simulationArea.mouseX, simulationArea.mouseY, this.absX(), this.absY()) >= 10) {
                if (Math.abs(this.x + this.parent.x - simulationArea.mouseX) > Math.abs(this.y + this.parent.y - simulationArea.mouseY)) {
                    this.prev = 'x';
                } else {
                    this.prev = 'y';
                }
            } else if (this.prev == 'x' && this.absY() == simulationArea.mouseY) {
                this.prev = 'a';
            } else if (this.prev == 'y' && this.absX() == simulationArea.mouseX) {
                this.prev = 'a';
            }
        } else if (this.wasClicked && !this.clicked) {
            this.wasClicked = false;

            if (simulationArea.mouseX == this.absX() && simulationArea.mouseY == this.absY()) {
                return; // no new node situation
            }

            var x1; var y1; var x2; var y2; var
                flag = 0;
            var n1; var
                n2;

            // (x,y) present node, (x1,y1) node 1 , (x2,y2) node 2
            // n1 - node 1, n2 - node 2
            // node 1 may or may not be there
            // flag = 0  - node 2 only
            // flag = 1  - node 1 and node 2
            x2 = simulationArea.mouseX;
            y2 = simulationArea.mouseY;
            const x = this.absX();
            const y = this.absY();

            if (x != x2 && y != y2) {
                // Rare Exception Cases
                if (this.prev == 'a' && distance(simulationArea.mouseX, simulationArea.mouseY, this.absX(), this.absY()) >= 10) {
                    if (Math.abs(this.x + this.parent.x - simulationArea.mouseX) > Math.abs(this.y + this.parent.y - simulationArea.mouseY)) {
                        this.prev = 'x';
                    } else {
                        this.prev = 'y';
                    }
                }

                flag = 1;
                if (this.prev == 'x') {
                    x1 = x2;
                    y1 = y;
                } else if (this.prev == 'y') {
                    y1 = y2;
                    x1 = x;
                }
            }

            if (flag == 1) {
                for (var i = 0; i < this.parent.scope.allNodes.length; i++) {
                    if (x1 == this.parent.scope.allNodes[i].absX() && y1 == this.parent.scope.allNodes[i].absY()) {
                        n1 = this.parent.scope.allNodes[i];
                        break;
                    }
                }

                if (n1 == undefined) {
                    n1 = new Node(x1, y1, 2, this.scope.root);
                    for (var i = 0; i < this.parent.scope.wires.length; i++) {
                        if (this.parent.scope.wires[i].checkConvergence(n1)) {
                            this.parent.scope.wires[i].converge(n1);
                            break;
                        }
                    }
                }
                this.connect(n1);
            }

            for (var i = 0; i < this.parent.scope.allNodes.length; i++) {
                if (x2 == this.parent.scope.allNodes[i].absX() && y2 == this.parent.scope.allNodes[i].absY()) {
                    n2 = this.parent.scope.allNodes[i];
                    break;
                }
            }

            if (n2 == undefined) {
                n2 = new Node(x2, y2, 2, this.scope.root);
                for (var i = 0; i < this.parent.scope.wires.length; i++) {
                    if (this.parent.scope.wires[i].checkConvergence(n2)) {
                        this.parent.scope.wires[i].converge(n2);
                        break;
                    }
                }
            }
            if (flag == 0) this.connect(n2);
            else n1.connect(n2);
            if (simulationArea.lastSelected == this) simulationArea.lastSelected = n2;
        }

        if (this.type == NODE_INTERMEDIATE && simulationArea.mouseDown == false) {
            if (this.connections.length == 2) {
                if ((this.connections[0].absX() == this.connections[1].absX()) || (this.connections[0].absY() == this.connections[1].absY())) {
                    this.connections[0].connect(this.connections[1]);
                    this.delete();
                }
            } else if (this.connections.length == 0) this.delete();
        }
    }
used to update nodes if there is a event like click or hover on the node.
many booleans are used to check if certain properties are to be updated.