Browser seems good to go!

This commit is contained in:
dingo
2026-01-31 10:06:08 -05:00
parent 54ed27b97a
commit a0ee3deeca
6 changed files with 248 additions and 8 deletions
+58
View File
@@ -53,6 +53,8 @@ var attack_cooldown: float = 0.5 # Default attack cooldown in seconds
var _last_move_sent_time_ms: int = 0
var _last_move_vec: Vector2 = Vector2.ZERO
var _last_aim_sent: float = 0.0
var _prefetched_mob_paths: Dictionary = {}
var _mob_prefetch_in_progress: bool = false
func _ready():
# Add to group for HUD to access
@@ -474,6 +476,7 @@ func _on_state_updated():
if player_scene and players_container:
_update_entities(players_container, GameState.players, player_scene)
if mob_scene and mobs_container:
await _prefetch_mob_textures_if_needed()
_update_entities(mobs_container, GameState.mobs, mob_scene)
if chest_scene and chests_container:
_update_entities(chests_container, GameState.chests, chest_scene)
@@ -484,6 +487,61 @@ func _on_state_updated():
if loot_chest_scene and loot_chests_container:
_update_loot_chests()
func _collect_mob_sprite_paths(mobs: Dictionary) -> Array:
var paths: Array = []
for id in mobs:
var mob_data = mobs[id]
var sprite_config = mob_data.get("spriteConfig", mob_data.get("SpriteConfig", null))
if sprite_config == null or not (sprite_config is Dictionary):
continue
# New format (sheets)
if sprite_config.has("sheets"):
var sheets = sprite_config.get("sheets", {})
for sheet_key in sheets:
var sheet_info = sheets[sheet_key]
var path = sheet_info.get("path", "")
if path != "" and not paths.has(path):
paths.append(path)
continue
# Legacy format (sprites)
var sprites = sprite_config.get("sprites", {})
for anim_name in sprites:
var sprite_path = sprites[anim_name]
if sprite_path != "" and not paths.has(sprite_path):
paths.append(sprite_path)
return paths
func _prefetch_mob_textures_if_needed() -> void:
if not UpdateManager or not UpdateManager._is_web:
return
if _mob_prefetch_in_progress:
return
var paths = _collect_mob_sprite_paths(GameState.mobs)
if paths.is_empty():
return
var missing: Array = []
for path in paths:
if _prefetched_mob_paths.has(path):
continue
if UpdateManager.has_file(path):
_prefetched_mob_paths[path] = true
continue
missing.append(path)
if missing.is_empty():
return
_mob_prefetch_in_progress = true
await UpdateManager.prefetch_files(missing)
for path in missing:
_prefetched_mob_paths[path] = true
_mob_prefetch_in_progress = false
func _update_entities(container: Node2D, data: Dictionary, scene: PackedScene):
if scene == null or container == null:
return