Speeding up visible location call
Deploy Promiscuity Auth API / deploy (push) Successful in 46s
Deploy Promiscuity Character API / deploy (push) Successful in 57s
Deploy Promiscuity Inventory API / deploy (push) Successful in 59s
Deploy Promiscuity Locations API / deploy (push) Successful in 58s
k8s smoke test / test (push) Successful in 8s

This commit is contained in:
2026-03-20 09:50:17 -05:00
parent 8ce6a05710
commit 038981d7b1
12 changed files with 209 additions and 41 deletions
+52 -41
View File
@@ -15,9 +15,10 @@ const INVENTORY_API_URL := "https://pinv.ranaze.com/api/inventory"
@export var tile_label_height := 0.01
@export var tile_label_color: Color = Color(1, 1, 1, 1)
@onready var _block: MeshInstance3D = $TerrainBlock
@onready var _player: RigidBody3D = $Player
@onready var _camera: Camera3D = $Player/Camera3D
@onready var _block: MeshInstance3D = $TerrainBlock
@onready var _player: RigidBody3D = $Player
@onready var _camera: Camera3D = $Player/Camera3D
@onready var _player_visual: Node3D = $Player/TestCharAnimated
var _center_coord := Vector2i.ZERO
var _tiles_root: Node3D
@@ -37,10 +38,10 @@ var _queued_locations_refresh := false
var _interact_in_flight := false
func _ready() -> void:
_tiles_root = Node3D.new()
_tiles_root.name = "GeneratedTiles"
add_child(_tiles_root)
func _ready() -> void:
_tiles_root = Node3D.new()
_tiles_root.name = "GeneratedTiles"
add_child(_tiles_root)
if _camera:
_camera_start_offset = _camera.position
@@ -50,15 +51,17 @@ func _ready() -> void:
_tracked_node = _player
var start_coord := SelectedCharacter.get_coord()
_center_coord = Vector2i(roundi(start_coord.x), roundi(start_coord.y))
_persisted_coord = _center_coord
_character_id = String(SelectedCharacter.character.get("id", SelectedCharacter.character.get("Id", ""))).strip_edges()
_block.visible = false
await _load_existing_locations()
_ensure_selected_location_exists(_center_coord)
_rebuild_tiles(_center_coord)
_move_player_to_coord(_center_coord)
_center_coord = Vector2i(roundi(start_coord.x), roundi(start_coord.y))
_persisted_coord = _center_coord
_character_id = String(SelectedCharacter.character.get("id", SelectedCharacter.character.get("Id", ""))).strip_edges()
_block.visible = false
_deactivate_player_for_load()
await _load_existing_locations()
_ensure_selected_location_exists(_center_coord)
_rebuild_tiles(_center_coord)
_move_player_to_coord(_center_coord)
_activate_player_after_load()
func _process(_delta: float) -> void:
@@ -95,12 +98,34 @@ func _coord_to_world(coord: Vector2i) -> Vector3:
return Vector3(coord.x * tile_size, block_height * 0.5, coord.y * tile_size)
func _move_player_to_coord(coord: Vector2i) -> void:
if _player == null:
return
_player.global_position = Vector3(coord.x * tile_size, player_spawn_height, coord.y * tile_size)
_player.linear_velocity = Vector3.ZERO
_player.angular_velocity = Vector3.ZERO
func _move_player_to_coord(coord: Vector2i) -> void:
if _player == null:
return
_player.global_position = Vector3(coord.x * tile_size, player_spawn_height, coord.y * tile_size)
_player.linear_velocity = Vector3.ZERO
_player.angular_velocity = Vector3.ZERO
func _deactivate_player_for_load() -> void:
if _player == null:
return
_player.freeze = true
_player.sleeping = true
_player.linear_velocity = Vector3.ZERO
_player.angular_velocity = Vector3.ZERO
if _player_visual:
_player_visual.visible = false
func _activate_player_after_load() -> void:
if _player == null:
return
_player.linear_velocity = Vector3.ZERO
_player.angular_velocity = Vector3.ZERO
_player.sleeping = false
_player.freeze = false
if _player_visual:
_player_visual.visible = true
func _rebuild_tiles(center: Vector2i) -> void:
@@ -423,7 +448,7 @@ func _load_existing_locations() -> void:
"name": location_name,
"biomeKey": String(location.get("biomeKey", "plains")).strip_edges(),
"locationObject": _parse_location_object(location.get("locationObject", {})),
"floorItems": []
"floorItems": _parse_floor_inventory_items(location.get("floorItems", []))
}
loaded_count += 1
@@ -431,11 +456,9 @@ func _load_existing_locations() -> void:
if loaded_count == 0:
push_warning("Visible locations request succeeded but returned 0 locations for character %s." % _character_id)
await _load_visible_location_inventories()
_locations_loaded = true
_locations_refresh_in_flight = false
_rebuild_tiles(_center_coord)
_locations_loaded = true
_locations_refresh_in_flight = false
_rebuild_tiles(_center_coord)
if _queued_locations_refresh:
_queued_locations_refresh = false
_queue_locations_refresh()
@@ -633,6 +656,7 @@ func _parse_floor_inventory_items(value: Variant) -> Array:
continue
var item := entry as Dictionary
items.append({
"itemId": String(item.get("itemId", item.get("id", ""))).strip_edges(),
"itemKey": String(item.get("itemKey", "")).strip_edges(),
"quantity": int(item.get("quantity", 0)),
"slot": item.get("slot", null)
@@ -640,19 +664,6 @@ func _parse_floor_inventory_items(value: Variant) -> Array:
return items
func _load_visible_location_inventories() -> void:
for coord_variant in _known_locations.keys():
var coord: Vector2i = coord_variant
var location_data: Dictionary = _known_locations[coord]
var location_id := String(location_data.get("id", "")).strip_edges()
if location_id.is_empty():
continue
var floor_items := await _fetch_location_inventory(location_id)
location_data["floorItems"] = floor_items
_known_locations[coord] = location_data
func _refresh_location_inventory(location_id: String) -> void:
if location_id.is_empty():
return