Projectiles+
This commit is contained in:
@@ -21,6 +21,10 @@ signal recipe_discovered(recipe: Dictionary)
|
||||
signal stash_updated(stash_data: Dictionary)
|
||||
signal stash_result(result: Dictionary)
|
||||
signal dungeon_tiles_updated(tiles: Array)
|
||||
signal projectile_spawned(projectile_data: Dictionary)
|
||||
signal projectile_hit(hit_data: Dictionary)
|
||||
signal projectile_expired(expired_data: Dictionary)
|
||||
signal damage_number(damage_data: Dictionary)
|
||||
|
||||
# Use constants instead of enum to avoid type issues
|
||||
const STATE_AUTH = 0
|
||||
@@ -175,6 +179,14 @@ func _on_message_received(opcode: int, data: Dictionary):
|
||||
_handle_stash_state(data)
|
||||
OpCodes.STASH_RESULT:
|
||||
_handle_stash_result(data)
|
||||
OpCodes.EVENT_PROJECTILE_SPAWNED:
|
||||
_handle_projectile_spawned(data)
|
||||
OpCodes.EVENT_PROJECTILE_HIT:
|
||||
_handle_projectile_hit(data)
|
||||
OpCodes.EVENT_PROJECTILE_EXPIRED:
|
||||
_handle_projectile_expired(data)
|
||||
OpCodes.EVENT_DAMAGE_NUMBER:
|
||||
_handle_damage_number(data)
|
||||
_:
|
||||
print("[GameState] Unhandled opcode: ", opcode)
|
||||
|
||||
@@ -398,7 +410,25 @@ func _handle_dungeon_state(data: Dictionary):
|
||||
for lc in lchests:
|
||||
var lcid = lc.get("id", lc.get("Id"))
|
||||
loot_chests[lcid] = lc
|
||||
|
||||
|
||||
# Parse events (damage, deaths, projectile hits/expires)
|
||||
var events = data.get("events")
|
||||
if events:
|
||||
# Handle damage events - spawn floating damage numbers
|
||||
var damage_events = events.get("damage", [])
|
||||
for dmg_event in damage_events:
|
||||
damage_number.emit(dmg_event)
|
||||
|
||||
# Handle projectile hit events - remove projectile from client
|
||||
var projectile_hits = events.get("projectileHits", [])
|
||||
for hit_event in projectile_hits:
|
||||
projectile_hit.emit(hit_event)
|
||||
|
||||
# Handle projectile expired events - remove projectile from client
|
||||
var proj_expired = events.get("projectileExpired", [])
|
||||
for expire_event in proj_expired:
|
||||
projectile_expired.emit(expire_event)
|
||||
|
||||
dungeon_state_updated.emit()
|
||||
|
||||
func _handle_inventory_state(data: Dictionary):
|
||||
@@ -491,6 +521,9 @@ func send_move(dx: float, dy: float, aim_angle: float):
|
||||
func send_attack(aim_angle: float):
|
||||
Network.send_message(OpCodes.INPUT_ATTACK, {"AimAngle": aim_angle})
|
||||
|
||||
func send_fire_projectile(direction_x: float, direction_y: float):
|
||||
Network.send_message(OpCodes.INPUT_FIRE_PROJECTILE, {"DirectionX": direction_x, "DirectionY": direction_y})
|
||||
|
||||
func send_enter_dungeon(tier: int):
|
||||
Network.send_message(OpCodes.DUNGEON_ENTER, {"Tier": tier})
|
||||
|
||||
@@ -731,5 +764,21 @@ func _handle_tile_update(data: Dictionary):
|
||||
|
||||
if not found:
|
||||
dungeon.visual_tiles.tiles.append(tile)
|
||||
|
||||
|
||||
dungeon_tiles_updated.emit(tiles)
|
||||
|
||||
func _handle_projectile_spawned(data: Dictionary):
|
||||
print("[GameState] Projectile spawned: ", data.get("id", -1))
|
||||
projectile_spawned.emit(data)
|
||||
|
||||
func _handle_projectile_hit(data: Dictionary):
|
||||
print("[GameState] Projectile hit: ", data)
|
||||
projectile_hit.emit(data)
|
||||
|
||||
func _handle_projectile_expired(data: Dictionary):
|
||||
print("[GameState] Projectile expired: ", data.get("id", -1))
|
||||
projectile_expired.emit(data)
|
||||
|
||||
func _handle_damage_number(data: Dictionary):
|
||||
# Emit damage number for floating damage text
|
||||
damage_number.emit(data)
|
||||
|
||||
Reference in New Issue
Block a user