This commit is contained in:
2026-04-03 18:10:55 +01:00
parent 35cddfc53c
commit 3d4ae43f52
3 changed files with 2 additions and 15 deletions
+1
View File
@@ -7,6 +7,7 @@ class HUDLayer
def initialize def initialize
@hud_bg = Gosu::Image.new("assets/images/hud.png", retro: true) @hud_bg = Gosu::Image.new("assets/images/hud.png", retro: true)
@hud_fg = Gosu::Image.new("assets/images/hud_fg.png", retro: true) @hud_fg = Gosu::Image.new("assets/images/hud_fg.png", retro: true)
@inventory = Inventory.new @inventory = Inventory.new
@health = HealthBar.new(100) @health = HealthBar.new(100)
@logs = GameLogger.new @logs = GameLogger.new
-15
View File
@@ -17,21 +17,6 @@ class EventBus
@events[event] << { callback: callback, owner: owner } @events[event] << { callback: callback, owner: owner }
end end
# Subscribe to an event that should only be called once
def once(event, owner = nil, &callback)
wrapper = nil
wrapper = proc do |*args|
callback.call(*args)
off(event, &wrapper)
end
on(event, owner: owner, &wrapper)
end
# Unsubscribe from an event
def off(event, &callback)
@events[event].reject! { |h| h[:callback] == callback }
end
# For events that return a value (e.g. queries), get the first non-nil response # For events that return a value (e.g. queries), get the first non-nil response
def get(event, *args) def get(event, *args)
@events[event].dup.each do |h| @events[event].dup.each do |h|
+1
View File
@@ -7,6 +7,7 @@ class MazeData
@boss_rooms = [] @boss_rooms = []
@start_room = nil @start_room = nil
@exit_room = nil
crate_rooms! crate_rooms!
carve_passages_from(0, 0) carve_passages_from(0, 0)