Table of Contents

Barrel Level Object - Code References

Entity Kind: `Barrel`

Entity Type: Level Object (Pushable, Flammable)

Description: The Barrel is a pushable level object found throughout the dungeon. It can be pushed by the hero or mobs, and when bumped or burned, it explodes and creates LiquidFlame blobs. During Halloween events, barrels are replaced with pumpkins that have the same behavior but different visuals and text.

Java Classes

Key Implementation Details:

public class Barrel extends LevelObject {
    private boolean burned = false;
 
    public Barrel(int pos) {
        super(pos);
        textureFile = "levelObjects/barrels.png";
    }
 
    @Override
    public boolean pushable(Char hero) {
        return true;
    }
 
    @Override
    public void burn() {
        if (burned) return;
        burned = true;
        // Play burning animation
        Sample.INSTANCE.play(Assets.SND_EXPLOSION);
        LiquidFlame fire = Blob.seed(getPos(), 10, LiquidFlame.class);
        GameScene.add(fire);
    }
 
    @Override
    public void bump(Presser presser) {
        burn();
    }
 
    @Override
    public boolean flammable() {
        return true;
    }
}

Java Usage

JSON Configuration

String Resources

English (`values/strings_all.xml`):

<string name="Barrel_Name">barrel</string>
<string name="Barrel_Desc">Looks like a simple wooden barrel. But as you get closer to it, you can smell a faint hint of oil. The barrel seems to be fairly light, you might be able to push it.</string>
<string name="Barrel_Pumpkin_Name">pumpkin</string>
<string name="Barrel_Pumpkin_Desc">It is very strange and rather creepy to see a carved pumpkin lying on the dungeon floor. You clearly sense incoming danger from it. But you can always push it away, right?</string>

Russian (`values-ru/strings_all.xml`):

<string name="Barrel_Name">бочка</string>
<string name="Barrel_Desc">С виду обычная бочка. Но подходя ближе ты начинаешь чувствовать странный маслянистый запах. Похоже бочка довольно лёгкая, скорее всего ты сможешь её сдвинуть.</string>
<string name="Barrel_Pumpkin_Name">тыква</string>
<string name="Barrel_Pumpkin_Desc">Весьма странно и довольно жутко видеть резную тыкву, лежащей на полу подземелья. Ты отчётливо чувствуешь исходящую от неё опасность. Но ты всегда можешь её оттолкнуть, верно?</string>

Lua Scripts