enhance chest object handling and save/load functionality

This commit is contained in:
2026-03-23 19:19:20 +01:00
parent 5dbf7fcf1f
commit 70a250f775
6 changed files with 83 additions and 10 deletions

View File

@@ -8,13 +8,10 @@ import de.miaurizius.jgame2d.entity.Entity;
public class ChestObj extends Entity {
GamePanel panel;
Entity loot;
boolean opened;
public ChestObj(GamePanel panel, Entity loot) {
public ChestObj(GamePanel panel) {
super(panel);
this.panel = panel;
this.loot = loot;
type = EntityType.OBSTACLE;
name = "chest";
@@ -31,11 +28,16 @@ public class ChestObj extends Entity {
solidAreaDefaultY = solidArea.y;
}
@Override
public void setLoot(Entity loot) {
this.loot = loot;
}
@Override
public void interact() {
panel.gameState = GameState.DIALOGUE;
if(opened) {
if(this.opened) {
panel.ui.currentDialogue = "It's already empty...";
return;
}