Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
phases, EntityStore world model, ~all GC/CG headers. char create/delete,
private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
token), system-option + game-option + ESC system menu, private-shop 39-grid,
party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.
Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.
Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).
ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
77 lines
2.7 KiB
GDScript
77 lines
2.7 KiB
GDScript
# atlas_test —— Atlas 大地图窗口的无资源 headless 自检。
|
|
# godot --headless --path project --script atlas_test.gd
|
|
extends SceneTree
|
|
|
|
const AtlasUI = preload("res://ui/atlas_ui.gd")
|
|
const UiManager = preload("res://ui/ui_manager.gd")
|
|
|
|
class FakeWorld extends Node:
|
|
func get_map_size_tiles() -> Vector2i: return Vector2i(2, 2)
|
|
func chunk_dir(_x: int, _y: int) -> String: return "/no-such-chunk"
|
|
func load_dds(_path: String): return null
|
|
|
|
class FakeClient extends Node:
|
|
var entities := {9: {"vid": 9, "pos": Vector3(2, 0, -2)}}
|
|
func get_party() -> Array: return [{"vid": 9, "leader": true}]
|
|
func get_entity(vid: int) -> Dictionary: return entities.get(vid, {})
|
|
func get_land_areas() -> Array:
|
|
return [{"x": 0, "y": 0, "width": 5000, "height": 5000, "guild_id": 7}]
|
|
func get_observers() -> Array:
|
|
return [{"vid": 9, "pos": Vector3(2, 0, -2)}]
|
|
func get_world_markers() -> Array:
|
|
return [{"pos": Vector3(-2, 0, 2)}]
|
|
|
|
var _fail := 0
|
|
func _ck(ok: bool, msg: String) -> void:
|
|
if not ok:
|
|
_fail += 1
|
|
printerr("FAIL: " + msg)
|
|
|
|
func _init() -> void:
|
|
await _run()
|
|
if _fail == 0:
|
|
print("PASS: atlas_test (window + drag + coordinate query)")
|
|
quit(0)
|
|
else:
|
|
printerr("%d check(s) failed" % _fail)
|
|
quit(1)
|
|
|
|
func _run() -> void:
|
|
var world := FakeWorld.new()
|
|
get_root().add_child(world)
|
|
var ui: CanvasLayer = UiManager.new()
|
|
get_root().add_child(ui)
|
|
await process_frame
|
|
var player := Node3D.new()
|
|
player.position = Vector3(128, 0, 256)
|
|
get_root().add_child(player)
|
|
var client := FakeClient.new()
|
|
get_root().add_child(client)
|
|
var atlas: Node = AtlasUI.new()
|
|
get_root().add_child(atlas)
|
|
atlas.setup(world, ui, func() -> Node3D: return player, "test_map", client)
|
|
atlas.open()
|
|
_ck(atlas.is_open(), "atlas opens")
|
|
_ck(atlas._map != null and atlas._map.size == Vector2(256, 256), "atlas builds map texture")
|
|
_ck(String(atlas._coord.text).contains("X 12800") and String(atlas._coord.text).contains("Y 25600"),
|
|
"atlas reports player server-centimetre coordinates")
|
|
atlas._overlay.queue_redraw()
|
|
_ck(atlas._overlay.is_inside_tree(), "atlas world marker overlay is live")
|
|
var old_pos: Vector2 = atlas._map.position
|
|
var down := InputEventMouseButton.new()
|
|
down.button_index = MOUSE_BUTTON_LEFT
|
|
down.pressed = true
|
|
down.position = Vector2(100, 100)
|
|
atlas._on_map_input(down)
|
|
var drag := InputEventMouseMotion.new()
|
|
drag.position = Vector2(140, 120)
|
|
atlas._on_map_input(drag)
|
|
_ck(atlas._map.position != old_pos, "atlas left drag moves map")
|
|
var reset := InputEventMouseButton.new()
|
|
reset.button_index = MOUSE_BUTTON_RIGHT
|
|
reset.pressed = true
|
|
atlas._on_map_input(reset)
|
|
_ck(atlas._map.position == atlas._map_origin, "atlas right click recenters map")
|
|
atlas.close()
|
|
_ck(not atlas.is_open(), "atlas closes")
|