CommandProcessor ref problem - CaffeineCoderz/Fungorium GitHub Wiki

    public void breakTekton(CommandProcessor commandProcessor) {
        log.stepIn("Going through all insect in 'insects'");
        for (int i = insects.size() - 1; i >= 0; i--) {
            Insect insect = insects.get(i);
            log.stepIn("insect.deadInsect()");
            // insect.deadInsect(); ITT EZ már nem szükséges mert a commandProcessor
            // fogja elvégezni a törlést
            // Keressük meg a kulcsot, ami az Insect-hez tartozik
            String foundKey = commandProcessor.findByObject(insect);
            // Ha megtaláltuk a kulcsot, akkor töröljük az objektumot a commandProcessor-ból
            commandProcessor.process("/kill " + foundKey);
            log.stepOut("insect.deadInsect()", null);
        }

        log.stepOut("End Cycle", null);
        log.stepIn("Going through all thread in 'threads'");
        for (FungusThread ft : threads) {
            log.stepIn("ft.setIsDying(true)");
            // ft.setIsDying(true);
            String foundKey = commandProcessor.findByObject(ft);
            commandProcessor.process("/set " + foundKey + " isDying true");
            log.stepOut("ft.setIsDying(true)", null);
            log.stepIn("ft.getSpecies().destroyThread(ft)");
            // ! erre nincs command még!!!!! kell egyeltalán?
            // ft.getSpecies().destroyThread(ft);
            String foundKey2 = commandProcessor.findByObject(ft.getSpecies());
            commandProcessor.process("/set " + foundKey2 + " deletethread " + foundKey);
            commandProcessor.process("/delete " + foundKey);

            log.stepOut("ft.getSpecies().destroyThread(ft)", null);
        }
        log.stepOut("End Cycle", null);
        log.stepIn("Going through all spore in 'spores'");
        for (int i = spores.size() - 1; i >= 0; i--) {
            Spore spore = spores.get(i);
            log.stepIn("spore.absorbed()");
            spore.absorbed();
            log.stepOut("spore.absorbed()", null);
        }
        log.stepOut("End Cycle", null);
        log.stepIn("body.getSpecies().destroyBody(body)");
        body.getSpecies().destroyBody(body);
        log.stepOut("body.getSpecies().destroyBody(body)", null);
        log.askQ("Create Tekton: t1", false);
        Tekton t1 = new Tekton(this);
        log.askQ("Create Tekton: t2", false);
        Tekton t2 = new Tekton(this);

        log.stepIn("Going through all neigbouring tekton");
        for (Tekton tekton : neighbours) {
            log.stepIn("tekton.removeNeighbour(this)");
            tekton.removeNeighbour(this);
            log.stepOut("tekton.removeNeighbour(this)", null);

            log.stepIn("tekton.addNeighbour(t1)");
            tekton.addNeighbour(t1);
            log.stepOut("tekton.addNeighbour(t1)", null);

            log.stepIn("tekton.addNeighbour(t2)");
            tekton.addNeighbour(t2);
            log.stepOut("tekton.addNeighbour(t2)", null);
        }
        log.stepOut("End Cycle", null);

        log.stepIn("t1.addNeighbour(t2)");
        t1.addNeighbour(t2);
        log.stepOut("t1.addNeighbour(t2)", null);

        log.stepIn("t2.addNeighbour(t1)");
        t2.addNeighbour(t1);
        log.stepOut("t2.addNeighbour(t1)", null);
    }