Search in sources :

Example 1 with ScriptedActor

use of com.nyrds.pixeldungeon.mechanics.actors.ScriptedActor in project pixel-dungeon-remix by NYRDS.

the class Level method activateScripts.

public void activateScripts() {
    for (ScriptedActor scriptedActor : scripts) {
        Actor.add(scriptedActor);
        scriptedActor.activate();
    }
}
Also used : ScriptedActor(com.nyrds.pixeldungeon.mechanics.actors.ScriptedActor)

Example 2 with ScriptedActor

use of com.nyrds.pixeldungeon.mechanics.actors.ScriptedActor in project pixel-dungeon-remix by NYRDS.

the class Level method restoreFromBundle.

@Override
public void restoreFromBundle(Bundle bundle) {
    scripts = new HashSet<>();
    mobs = new HashSet<>();
    heaps = new SparseArray<>();
    blobs = new HashMap<>();
    plants = new SparseArray<>();
    // old levels compat
    width = bundle.optInt(WIDTH, 32);
    height = bundle.optInt(HEIGHT, 32);
    initSizeDependentStuff();
    map = bundle.getIntArray(MAP);
    for (LayerId layerId : LayerId.values()) {
        int[] layer = bundle.getIntArray(layerId.name());
        if (layer.length == map.length) {
            customLayers.put(layerId, layer);
        }
    }
    visited = bundle.getBooleanArray(VISITED);
    mapped = bundle.getBooleanArray(MAPPED);
    entrance = bundle.getInt(ENTRANCE);
    compassTarget = bundle.optInt(COMPASS_TARGET, INVALID_CELL);
    int[] exits = bundle.getIntArray(EXIT);
    if (exits.length > 0) {
        for (int i = 0; i < exits.length; ++i) {
            setExit(exits[i], i);
        }
    } else {
        setExit(bundle.getInt(EXIT), 0);
        int secondaryExit = bundle.optInt(SECONDARY_EXIT, INVALID_CELL);
        if (cellValid(secondaryExit)) {
            setExit(secondaryExit, 1);
        }
    }
    weakFloorCreated = false;
    for (Heap heap : bundle.getCollection(HEAPS, Heap.class)) {
        heaps.put(heap.pos, heap);
    }
    for (Plant plant : bundle.getCollection(PLANTS, Plant.class)) {
        plants.put(plant.pos, plant);
    }
    for (LevelObject object : bundle.getCollection(OBJECTS, LevelObject.class)) {
        putLevelObject(object);
    }
    for (Mob mob : bundle.getCollection(MOBS, Mob.class)) {
        if (mob != null && mob.getPos() != INVALID_CELL) {
            mobs.add(mob);
        }
    }
    for (Blob blob : bundle.getCollection(BLOBS, Blob.class)) {
        blobs.put(blob.getClass(), blob);
    }
    for (ScriptedActor actor : bundle.getCollection(SCRIPTS, ScriptedActor.class)) {
        addScriptedActor(actor);
    }
    buildFlagMaps();
    cleanWalls();
}
Also used : Mob(com.watabou.pixeldungeon.actors.mobs.Mob) ScriptedActor(com.nyrds.pixeldungeon.mechanics.actors.ScriptedActor) Plant(com.watabou.pixeldungeon.plants.Plant) Blob(com.watabou.pixeldungeon.actors.blobs.Blob) LevelObject(com.nyrds.pixeldungeon.levels.objects.LevelObject) Heap(com.watabou.pixeldungeon.items.Heap)

Aggregations

ScriptedActor (com.nyrds.pixeldungeon.mechanics.actors.ScriptedActor)2 LevelObject (com.nyrds.pixeldungeon.levels.objects.LevelObject)1 Blob (com.watabou.pixeldungeon.actors.blobs.Blob)1 Mob (com.watabou.pixeldungeon.actors.mobs.Mob)1 Heap (com.watabou.pixeldungeon.items.Heap)1 Plant (com.watabou.pixeldungeon.plants.Plant)1