Compare commits
5 Commits
48216b72f7
...
ded049b61b
| Author | SHA1 | Date | |
|---|---|---|---|
| ded049b61b | |||
|
|
326ab7ce5c | ||
|
|
603e7d9fc6 | ||
|
|
e989b4adf1 | ||
|
|
6e70aac0b9 |
@@ -68,6 +68,9 @@ enum LoginMode {
|
||||
|
||||
# ============ 成员变量 ============
|
||||
|
||||
# 当前用户ID(静态变量,用于BaseLevel等场景访问)
|
||||
static var current_user_id: String = ""
|
||||
|
||||
# 登录状态
|
||||
var current_login_mode: LoginMode = LoginMode.PASSWORD
|
||||
var is_processing: bool = false
|
||||
@@ -80,10 +83,25 @@ var current_email: String = ""
|
||||
# 网络请求管理
|
||||
var active_request_ids: Array = []
|
||||
|
||||
# ============ Token 管理 ============
|
||||
|
||||
# 本地存储路径常量
|
||||
const AUTH_CONFIG_PATH: String = "user://auth.cfg"
|
||||
|
||||
# Token 存储(内存中,用于快速访问)
|
||||
var _access_token: String = "" # JWT访问令牌(短期,用于API和WebSocket)
|
||||
var _refresh_token: String = "" # JWT刷新令牌(长期,用于获取新access_token)
|
||||
var _user_info: Dictionary = {} # 用户信息
|
||||
var _token_expiry: float = 0.0 # access_token过期时间(Unix时间戳)
|
||||
|
||||
# 游戏 token(废弃,保留供旧接口)
|
||||
var _game_token: String = "" # @deprecated 使用 _access_token 替代
|
||||
|
||||
# ============ 生命周期方法 ============
|
||||
|
||||
# 初始化管理器
|
||||
func _init():
|
||||
func _init() -> void:
|
||||
_load_auth_data()
|
||||
print("AuthManager 初始化完成")
|
||||
|
||||
# 清理资源
|
||||
@@ -93,6 +111,162 @@ func cleanup():
|
||||
NetworkManager.cancel_request(request_id)
|
||||
active_request_ids.clear()
|
||||
|
||||
# ============ Token 管理 ============
|
||||
|
||||
# 保存 Token 到内存
|
||||
#
|
||||
# 参数:
|
||||
# data: Dictionary - 登录响应数据
|
||||
#
|
||||
# 功能:
|
||||
# - 从登录响应中提取 access_token 和 refresh_token
|
||||
# - 保存到内存变量中
|
||||
# - 保存用户信息
|
||||
func _save_tokens_to_memory(data: Dictionary) -> void:
|
||||
if not data.has("data"):
|
||||
push_warning("AuthManager: 登录响应中没有 data 字段")
|
||||
return
|
||||
|
||||
var token_data: Dictionary = data.data
|
||||
_access_token = token_data.get("access_token", "")
|
||||
_refresh_token = token_data.get("refresh_token", "")
|
||||
_user_info = token_data.get("user", {})
|
||||
_token_expiry = Time.get_unix_time_from_system() + float(token_data.get("expires_in", 0))
|
||||
|
||||
# 设置当前用户ID(用于BaseLevel等场景)
|
||||
if _user_info.has("id"):
|
||||
AuthManager.current_user_id = str(_user_info.id)
|
||||
|
||||
_game_token = _access_token
|
||||
|
||||
# 保存 Token 到本地(ConfigFile)
|
||||
#
|
||||
# 参数:
|
||||
# data: Dictionary - 登录响应数据
|
||||
#
|
||||
# 功能:
|
||||
# - 将 refresh_token 和用户信息保存到 ConfigFile
|
||||
# - access_token 不保存到本地,仅保存在内存中
|
||||
func _save_tokens_to_local(data: Dictionary) -> void:
|
||||
if not data.has("data"):
|
||||
return
|
||||
|
||||
var token_data: Dictionary = data.data
|
||||
var auth_data: Dictionary = {
|
||||
"refresh_token": token_data.get("refresh_token", ""),
|
||||
"user_id": token_data.get("user", {}).get("id", ""),
|
||||
"username": token_data.get("user", {}).get("username", ""),
|
||||
"saved_at": Time.get_unix_time_from_system()
|
||||
}
|
||||
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
config.load(AUTH_CONFIG_PATH)
|
||||
config.set_value("auth", "refresh_token", auth_data["refresh_token"])
|
||||
config.set_value("auth", "user_id", auth_data["user_id"])
|
||||
config.set_value("auth", "username", auth_data["username"])
|
||||
config.set_value("auth", "saved_at", auth_data["saved_at"])
|
||||
|
||||
var error: Error = config.save(AUTH_CONFIG_PATH)
|
||||
if error != OK:
|
||||
push_error("AuthManager: 保存Token到本地失败,错误码: %d" % error)
|
||||
|
||||
# 从本地加载 Token(游戏启动时调用)
|
||||
#
|
||||
# 功能:
|
||||
# - 从 ConfigFile 加载 refresh_token 和用户信息
|
||||
# - access_token 需要通过 refresh_token 刷新获取
|
||||
func _load_auth_data() -> void:
|
||||
if not FileAccess.file_exists(AUTH_CONFIG_PATH):
|
||||
return
|
||||
|
||||
var config: ConfigFile = ConfigFile.new()
|
||||
var error: Error = config.load(AUTH_CONFIG_PATH)
|
||||
|
||||
if error != OK:
|
||||
push_error("AuthManager: 加载本地认证数据失败,错误码: %d" % error)
|
||||
return
|
||||
|
||||
_refresh_token = config.get_value("auth", "refresh_token", "")
|
||||
var user_id: String = config.get_value("auth", "user_id", "")
|
||||
var username: String = config.get_value("auth", "username", "")
|
||||
|
||||
if not _refresh_token.is_empty():
|
||||
_user_info = {
|
||||
"id": user_id,
|
||||
"username": username
|
||||
}
|
||||
else:
|
||||
push_warning("AuthManager: 本地认证数据无效(没有 refresh_token)")
|
||||
|
||||
# 清除本地认证数据(登出时调用)
|
||||
#
|
||||
# 功能:
|
||||
# - 清除内存中的 Token
|
||||
# - 删除本地 ConfigFile
|
||||
func _clear_auth_data() -> void:
|
||||
_access_token = ""
|
||||
_refresh_token = ""
|
||||
_user_info = {}
|
||||
_token_expiry = 0.0
|
||||
_game_token = ""
|
||||
|
||||
if FileAccess.file_exists(AUTH_CONFIG_PATH):
|
||||
DirAccess.remove_absolute(AUTH_CONFIG_PATH)
|
||||
|
||||
# ============ Token 访问方法 ============
|
||||
|
||||
# 设置游戏 token(建议优先使用 _save_tokens_to_memory)
|
||||
#
|
||||
# 参数:
|
||||
# token: String - 游戏认证 token
|
||||
#
|
||||
# 使用场景:
|
||||
# - 登录成功后设置 token
|
||||
# - 从服务器响应中获取 token
|
||||
func set_game_token(token: String) -> void:
|
||||
_game_token = token
|
||||
_access_token = token # 同步更新 access_token
|
||||
|
||||
# 获取游戏 token
|
||||
#
|
||||
# 返回值:
|
||||
# String - access_token(如果未设置则返回空字符串)
|
||||
#
|
||||
# 使用场景:
|
||||
# - ChatManager 连接 WebSocket 时需要 token
|
||||
# - 其他需要游戏认证的场景
|
||||
func get_game_token() -> String:
|
||||
return _access_token
|
||||
|
||||
# 获取 access token
|
||||
#
|
||||
# 返回值:
|
||||
# String - JWT访问令牌
|
||||
#
|
||||
# 使用场景:
|
||||
# - API请求认证
|
||||
# - WebSocket聊天认证
|
||||
func get_access_token() -> String:
|
||||
return _access_token
|
||||
|
||||
# 获取 refresh token
|
||||
#
|
||||
# 返回值:
|
||||
# String - JWT刷新令牌
|
||||
#
|
||||
# 使用场景:
|
||||
# - 刷新过期的 access token
|
||||
func get_refresh_token() -> String:
|
||||
return _refresh_token
|
||||
|
||||
# 获取用户信息
|
||||
#
|
||||
# 返回值:
|
||||
# Dictionary - 用户信息字典
|
||||
func get_user_info() -> Dictionary:
|
||||
return _user_info
|
||||
|
||||
|
||||
# ============ 登录相关方法 ============
|
||||
|
||||
# 执行密码登录
|
||||
@@ -586,4 +760,4 @@ func _is_valid_identifier(identifier: String) -> bool:
|
||||
func _is_valid_phone(phone: String) -> bool:
|
||||
var regex = RegEx.new()
|
||||
regex.compile("^\\+?[1-9]\\d{1,14}$")
|
||||
return regex.search(phone) != null
|
||||
return regex.search(phone) != null
|
||||
|
||||
726
_Core/managers/ChatManager.gd
Normal file
@@ -0,0 +1,726 @@
|
||||
extends Node
|
||||
|
||||
# ============================================================================
|
||||
# ChatManager.gd - 聊天系统业务逻辑核心
|
||||
# ============================================================================
|
||||
# 管理聊天功能的核心业务逻辑
|
||||
#
|
||||
# 核心职责:
|
||||
# - 聊天消息发送/接收协调
|
||||
# - 客户端频率限制(10条/分钟)
|
||||
# - 消息历史管理(最多100条)
|
||||
# - Signal Up: 通过信号和 EventSystem 向上通知
|
||||
# - 整合 AuthManager 获取 token
|
||||
#
|
||||
# 使用方式:
|
||||
# ChatManager.connect_to_chat_server()
|
||||
# ChatManager.send_chat_message("Hello", "local")
|
||||
# ChatManager.chat_message_received.connect(_on_message_received)
|
||||
#
|
||||
# 注意事项:
|
||||
# - 作为自动加载单例,全局可访问
|
||||
# - 遵循 "Signal Up, Call Down" 架构
|
||||
# - 所有聊天事件通过 EventSystem 广播
|
||||
# ============================================================================
|
||||
|
||||
# ============================================================================
|
||||
# 信号定义 (Signal Up)
|
||||
# ============================================================================
|
||||
|
||||
# 聊天消息已发送信号
|
||||
# 参数:
|
||||
# message_id: String - 消息 ID
|
||||
# timestamp: float - 时间戳
|
||||
signal chat_message_sent(message_id: String, timestamp: float)
|
||||
|
||||
# 聊天消息已接收信号
|
||||
# 参数:
|
||||
# from_user: String - 发送者用户名
|
||||
# content: String - 消息内容
|
||||
# show_bubble: bool - 是否显示气泡
|
||||
# timestamp: float - 时间戳
|
||||
signal chat_message_received(from_user: String, content: String, show_bubble: bool, timestamp: float)
|
||||
|
||||
# 聊天错误发生信号
|
||||
# 参数:
|
||||
# error_code: String - 错误代码
|
||||
# message: String - 错误消息
|
||||
signal chat_error_occurred(error_code: String, message: String)
|
||||
|
||||
# 聊天连接状态变化信号
|
||||
# 参数:
|
||||
# state: int - 连接状态(0=DISCONNECTED, 1=CONNECTING, 2=CONNECTED, 3=RECONNECTING, 4=ERROR)
|
||||
signal chat_connection_state_changed(state: int)
|
||||
|
||||
# 位置更新成功信号
|
||||
# 参数:
|
||||
# stream: String - Stream 名称
|
||||
# topic: String - Topic 名称
|
||||
signal chat_position_updated(stream: String, topic: String)
|
||||
|
||||
# ============================================================================
|
||||
# 常量定义
|
||||
# ============================================================================
|
||||
|
||||
# WebSocket 服务器 URL(原生 WebSocket)
|
||||
const WEBSOCKET_URL: String = "wss://whaletownend.xinghangee.icu/game"
|
||||
|
||||
# 重连配置
|
||||
const RECONNECT_MAX_ATTEMPTS: int = 5
|
||||
const RECONNECT_BASE_DELAY: float = 3.0
|
||||
|
||||
# 频率限制配置
|
||||
const RATE_LIMIT_MESSAGES: int = 10
|
||||
const RATE_LIMIT_WINDOW: float = 60.0 # 秒
|
||||
|
||||
# 消息限制
|
||||
const MAX_MESSAGE_LENGTH: int = 1000
|
||||
|
||||
# 当前会话消息限制(当前游戏会话,超过后删除最旧的)
|
||||
const MAX_SESSION_MESSAGES: int = 100
|
||||
|
||||
# 历史消息分页大小(从 Zulip 后端每次加载的数量)
|
||||
const HISTORY_PAGE_SIZE: int = 100
|
||||
|
||||
# 错误消息映射
|
||||
const CHAT_ERROR_MESSAGES: Dictionary = {
|
||||
"AUTH_FAILED": "聊天认证失败,请重新登录",
|
||||
"RATE_LIMIT": "消息发送过于频繁,请稍后再试",
|
||||
"CONTENT_FILTERED": "消息内容包含违规内容",
|
||||
"CONTENT_TOO_LONG": "消息内容过长(最大1000字符)",
|
||||
"PERMISSION_DENIED": "您没有权限发送消息",
|
||||
"SESSION_EXPIRED": "会话已过期,请重新连接",
|
||||
"ZULIP_ERROR": "消息服务暂时不可用",
|
||||
"INTERNAL_ERROR": "服务器内部错误"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# 成员变量
|
||||
# ============================================================================
|
||||
|
||||
# WebSocket 管理器
|
||||
var _websocket_manager: ChatWebSocketManager
|
||||
|
||||
# 是否已登录
|
||||
var _is_logged_in: bool = false
|
||||
|
||||
# 消息历史记录(当前会话,最多100条,超过后删除最旧的)
|
||||
var _message_history: Array[Dictionary] = []
|
||||
|
||||
# 历史消息加载状态
|
||||
var _history_loading: bool = false
|
||||
var _has_more_history: bool = true
|
||||
var _oldest_message_timestamp: float = 0.0
|
||||
|
||||
# 消息发送时间戳(用于频率限制)
|
||||
var _message_timestamps: Array[float] = []
|
||||
|
||||
# 当前用户信息
|
||||
var _current_username: String = ""
|
||||
var _current_map: String = ""
|
||||
|
||||
# 游戏 token
|
||||
var _game_token: String = ""
|
||||
|
||||
# 发送后本地回显去重(避免服务端也回发导致重复显示)
|
||||
const SELF_ECHO_DEDUPE_WINDOW: float = 10.0
|
||||
var _pending_self_messages: Array[Dictionary] = []
|
||||
|
||||
# ============================================================================
|
||||
# 生命周期方法
|
||||
# ============================================================================
|
||||
|
||||
# 初始化
|
||||
func _ready() -> void:
|
||||
# 创建 WebSocket 管理器
|
||||
_websocket_manager = ChatWebSocketManager.new()
|
||||
add_child(_websocket_manager)
|
||||
|
||||
# 连接信号
|
||||
_connect_signals()
|
||||
|
||||
# 清理
|
||||
func _exit_tree() -> void:
|
||||
if is_instance_valid(_websocket_manager):
|
||||
_websocket_manager.queue_free()
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - Token 管理
|
||||
# ============================================================================
|
||||
|
||||
# 设置游戏 token
|
||||
#
|
||||
# 参数:
|
||||
# token: String - 游戏认证 token
|
||||
#
|
||||
# 使用示例:
|
||||
# ChatManager.set_game_token("your_game_token")
|
||||
func set_game_token(token: String) -> void:
|
||||
_game_token = token
|
||||
|
||||
# 获取游戏 token
|
||||
#
|
||||
# 返回值:
|
||||
# String - 当前游戏 token
|
||||
func get_game_token() -> String:
|
||||
return _game_token
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 连接管理
|
||||
# ============================================================================
|
||||
|
||||
# 连接到聊天服务器
|
||||
func connect_to_chat_server() -> void:
|
||||
if _websocket_manager.is_websocket_connected():
|
||||
push_warning("聊天服务器已连接")
|
||||
return
|
||||
|
||||
_websocket_manager.connect_to_game_server()
|
||||
|
||||
# 断开聊天服务器
|
||||
func disconnect_from_chat_server() -> void:
|
||||
# 发送登出消息
|
||||
if _is_logged_in:
|
||||
var logout_data := {"type": "logout"}
|
||||
_websocket_manager.send_message(JSON.stringify(logout_data))
|
||||
_is_logged_in = false
|
||||
|
||||
# 断开连接
|
||||
_websocket_manager.disconnect_websocket()
|
||||
|
||||
# 检查是否已连接
|
||||
#
|
||||
# 返回值:
|
||||
# bool - 是否已连接
|
||||
func is_chat_connected() -> bool:
|
||||
return _websocket_manager.is_websocket_connected()
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 聊天操作
|
||||
# ============================================================================
|
||||
|
||||
# 发送聊天消息
|
||||
#
|
||||
# 参数:
|
||||
# content: String - 消息内容
|
||||
# scope: String - 消息范围("local" 或具体 topic 名称)
|
||||
#
|
||||
# 使用示例:
|
||||
# ChatManager.send_chat_message("Hello, world!", "local")
|
||||
func send_chat_message(content: String, scope: String = "local") -> void:
|
||||
# 检查连接状态
|
||||
if not _websocket_manager.is_websocket_connected():
|
||||
_handle_error("NOT_CONNECTED", "未连接到聊天服务器")
|
||||
return
|
||||
|
||||
# 检查登录状态
|
||||
if not _is_logged_in:
|
||||
_handle_error("NOT_LOGGED_IN", "尚未登录聊天服务器")
|
||||
return
|
||||
|
||||
# 检查消息长度
|
||||
if content.length() > MAX_MESSAGE_LENGTH:
|
||||
_handle_error("CONTENT_TOO_LONG", "消息内容过长")
|
||||
return
|
||||
|
||||
# 检查频率限制
|
||||
if not can_send_message():
|
||||
var wait_time := get_time_until_next_message()
|
||||
_handle_error("RATE_LIMIT", "请等待 %.1f 秒后再试" % wait_time)
|
||||
return
|
||||
|
||||
# 构建消息数据
|
||||
var message_data := {
|
||||
"type": "chat",
|
||||
"content": content,
|
||||
"scope": scope
|
||||
}
|
||||
|
||||
# 发送消息(JSON 字符串)
|
||||
var json_string := JSON.stringify(message_data)
|
||||
var send_err: Error = _websocket_manager.send_message(json_string)
|
||||
if send_err != OK:
|
||||
_handle_error("SEND_FAILED", "WebSocket send failed: %s" % error_string(send_err))
|
||||
return
|
||||
|
||||
# 记录发送时间
|
||||
_record_message_timestamp()
|
||||
|
||||
# 添加到历史
|
||||
_add_message_to_history({
|
||||
"from_user": _current_username,
|
||||
"content": content,
|
||||
"timestamp": Time.get_unix_time_from_system(),
|
||||
"is_self": true
|
||||
})
|
||||
|
||||
var now_timestamp: float = Time.get_unix_time_from_system()
|
||||
|
||||
# 记录待去重的“自己消息”(如果服务端也回发 chat_render,则避免重复显示)
|
||||
_pending_self_messages.append({
|
||||
"content": content,
|
||||
"expires_at": now_timestamp + SELF_ECHO_DEDUPE_WINDOW
|
||||
})
|
||||
|
||||
# 本地回显:UI 目前只订阅 CHAT_MESSAGE_RECEIVED,所以这里也发一次 received
|
||||
chat_message_received.emit(_current_username, content, true, now_timestamp)
|
||||
EventSystem.emit_event(EventNames.CHAT_MESSAGE_RECEIVED, {
|
||||
"from_user": _current_username,
|
||||
"content": content,
|
||||
"show_bubble": true,
|
||||
"timestamp": now_timestamp,
|
||||
"is_self": true
|
||||
})
|
||||
|
||||
# 消息发送完成回调
|
||||
func _on_chat_message_sent(_request_id: String, success: bool, data: Dictionary, error_info: Dictionary) -> void:
|
||||
if success:
|
||||
var message_id: String = str(data.get("data", {}).get("id", ""))
|
||||
var timestamp: float = Time.get_unix_time_from_system()
|
||||
chat_message_sent.emit(message_id, timestamp)
|
||||
EventSystem.emit_event(EventNames.CHAT_MESSAGE_SENT, {
|
||||
"message_id": message_id,
|
||||
"timestamp": timestamp
|
||||
})
|
||||
else:
|
||||
_handle_error("SEND_FAILED", error_info.get("message", "发送失败"))
|
||||
|
||||
# 更新玩家位置
|
||||
#
|
||||
# 参数:
|
||||
# x: float - X 坐标
|
||||
# y: float - Y 坐标
|
||||
# map_id: String - 地图 ID
|
||||
#
|
||||
# 使用示例:
|
||||
# ChatManager.update_player_position(150.0, 200.0, "novice_village")
|
||||
func update_player_position(x: float, y: float, map_id: String) -> void:
|
||||
if not _websocket_manager.is_websocket_connected():
|
||||
return
|
||||
|
||||
var position_data := {
|
||||
"type": "position",
|
||||
"x": x,
|
||||
"y": y,
|
||||
"mapId": map_id
|
||||
}
|
||||
|
||||
# 发送消息(JSON 字符串)
|
||||
var json_string := JSON.stringify(position_data)
|
||||
_websocket_manager.send_message(json_string)
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 频率限制
|
||||
# ============================================================================
|
||||
|
||||
# 检查是否可以发送消息
|
||||
#
|
||||
# 返回值:
|
||||
# bool - 是否可以发送
|
||||
func can_send_message() -> bool:
|
||||
var current_time := Time.get_unix_time_from_system()
|
||||
|
||||
# 清理过期的时间戳
|
||||
var filter_func := func(timestamp: float) -> bool:
|
||||
return current_time - timestamp < RATE_LIMIT_WINDOW
|
||||
_message_timestamps = _message_timestamps.filter(filter_func)
|
||||
|
||||
# 检查数量
|
||||
return _message_timestamps.size() < RATE_LIMIT_MESSAGES
|
||||
|
||||
# 获取距离下次可发送消息的时间
|
||||
#
|
||||
# 返回值:
|
||||
# float - 等待时间(秒)
|
||||
func get_time_until_next_message() -> float:
|
||||
if _message_timestamps.is_empty():
|
||||
return 0.0
|
||||
|
||||
if _message_timestamps.size() < RATE_LIMIT_MESSAGES:
|
||||
return 0.0
|
||||
|
||||
# 找到最早的时间戳
|
||||
var earliest_timestamp: float = _message_timestamps[0]
|
||||
var current_time := Time.get_unix_time_from_system()
|
||||
var elapsed := current_time - earliest_timestamp
|
||||
|
||||
if elapsed >= RATE_LIMIT_WINDOW:
|
||||
return 0.0
|
||||
|
||||
return RATE_LIMIT_WINDOW - elapsed
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 消息历史
|
||||
# ============================================================================
|
||||
|
||||
# 获取消息历史
|
||||
#
|
||||
# 返回值:
|
||||
# Array[Dictionary] - 消息历史数组
|
||||
func get_message_history() -> Array[Dictionary]:
|
||||
return _message_history.duplicate()
|
||||
|
||||
# 清空消息历史
|
||||
func clear_message_history() -> void:
|
||||
_message_history.clear()
|
||||
|
||||
# 重置当前会话(每次登录/重连时调用)
|
||||
#
|
||||
# 功能:
|
||||
# - 清空当前会话消息缓存
|
||||
# - 重置历史消息加载状态
|
||||
# - 不影响 Zulip 后端的历史消息
|
||||
#
|
||||
# 使用场景:
|
||||
# - 用户登录成功后
|
||||
# - 重新连接到聊天服务器后
|
||||
func reset_session() -> void:
|
||||
_message_history.clear()
|
||||
_history_loading = false
|
||||
_has_more_history = true
|
||||
_oldest_message_timestamp = 0.0
|
||||
|
||||
# 加载历史消息(按需从 Zulip 后端获取)
|
||||
#
|
||||
# 参数:
|
||||
# count: int - 要加载的消息数量(默认 HISTORY_PAGE_SIZE)
|
||||
#
|
||||
# 功能:
|
||||
# - 从 Zulip 后端获取历史消息
|
||||
# - 添加到当前会话历史开头
|
||||
# - 触发 CHAT_MESSAGE_RECEIVED 事件显示消息
|
||||
#
|
||||
# 使用场景:
|
||||
# - 用户滚动到聊天窗口顶部
|
||||
# - 用户主动点击"加载历史"按钮
|
||||
#
|
||||
# 注意:
|
||||
# - 这是异步操作,需要通过 Zulip API 实现
|
||||
# - 当前实现为占位符,需要后端 API 支持
|
||||
func load_history(_count: int = HISTORY_PAGE_SIZE) -> void:
|
||||
if _history_loading:
|
||||
return
|
||||
|
||||
if not _has_more_history:
|
||||
return
|
||||
|
||||
_history_loading = true
|
||||
|
||||
# TODO: 实现从 Zulip 后端获取历史消息
|
||||
# NetworkManager.get_chat_history(_oldest_message_timestamp, count, _on_history_loaded)
|
||||
|
||||
# 历史消息加载完成回调
|
||||
func _on_history_loaded(messages: Array) -> void:
|
||||
_history_loading = false
|
||||
|
||||
if messages.is_empty():
|
||||
_has_more_history = false
|
||||
return
|
||||
|
||||
# 将历史消息插入到当前会话历史开头
|
||||
for i in range(messages.size() - 1, -1, -1):
|
||||
var message: Dictionary = messages[i]
|
||||
_message_history.push_front(message)
|
||||
|
||||
# 触发事件显示消息(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_MESSAGE_RECEIVED, {
|
||||
"from_user": message.get("from_user", ""),
|
||||
"content": message.get("content", ""),
|
||||
"show_bubble": false,
|
||||
"timestamp": message.get("timestamp", 0.0),
|
||||
"is_self": (not _current_username.is_empty() and message.get("from_user", "") == _current_username),
|
||||
"is_history": true # 标记为历史消息
|
||||
})
|
||||
|
||||
# 更新最旧消息时间戳
|
||||
var oldest: Dictionary = messages.back()
|
||||
if oldest.has("timestamp"):
|
||||
_oldest_message_timestamp = oldest.timestamp
|
||||
|
||||
# 检查是否还有更多历史
|
||||
if messages.size() < HISTORY_PAGE_SIZE:
|
||||
_has_more_history = false
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 信号连接
|
||||
# ============================================================================
|
||||
|
||||
# 连接信号
|
||||
func _connect_signals() -> void:
|
||||
# WebSocket 管理器信号
|
||||
_websocket_manager.connection_state_changed.connect(_on_connection_state_changed)
|
||||
_websocket_manager.data_received.connect(_on_data_received)
|
||||
|
||||
# 发送登录消息
|
||||
func _send_login_message() -> void:
|
||||
var login_data := {
|
||||
"type": "login",
|
||||
"token": _game_token
|
||||
}
|
||||
|
||||
var json_string := JSON.stringify(login_data)
|
||||
_websocket_manager.send_message(json_string)
|
||||
|
||||
# 连接状态变化
|
||||
func _on_connection_state_changed(state: int) -> void:
|
||||
# 发射信号
|
||||
chat_connection_state_changed.emit(state)
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_CONNECTION_STATE_CHANGED, {
|
||||
"state": state
|
||||
})
|
||||
|
||||
# 如果连接成功,发送登录消息
|
||||
if state == 2: # CONNECTED
|
||||
_send_login_message()
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 消息处理
|
||||
# ============================================================================
|
||||
|
||||
# WebSocket 数据接收
|
||||
func _on_data_received(message: String) -> void:
|
||||
# 解析 JSON 消息
|
||||
var json := JSON.new()
|
||||
var parse_result := json.parse(message)
|
||||
|
||||
if parse_result != OK:
|
||||
push_error("ChatManager: JSON 解析失败")
|
||||
return
|
||||
|
||||
var data: Dictionary = json.data
|
||||
|
||||
# 检查消息类型字段
|
||||
var message_type: String = data.get("t", "")
|
||||
|
||||
match message_type:
|
||||
"login_success":
|
||||
_handle_login_success(data)
|
||||
"login_error":
|
||||
_handle_login_error(data)
|
||||
"chat":
|
||||
_handle_chat_render(data)
|
||||
"chat_sent":
|
||||
_handle_chat_sent(data)
|
||||
"chat_error":
|
||||
_handle_chat_error(data)
|
||||
"chat_render":
|
||||
_handle_chat_render(data)
|
||||
"position_updated":
|
||||
_handle_position_updated(data)
|
||||
_:
|
||||
push_warning("ChatManager: 未处理的消息类型 %s" % message_type)
|
||||
|
||||
# 处理登录成功
|
||||
func _handle_login_success(data: Dictionary) -> void:
|
||||
_is_logged_in = true
|
||||
_current_username = data.get("username", "")
|
||||
_current_map = data.get("currentMap", "")
|
||||
|
||||
# 重置当前会话缓存(每次登录/重连都清空,重新开始接收消息)
|
||||
reset_session()
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_LOGIN_SUCCESS, {
|
||||
"username": _current_username,
|
||||
"current_map": _current_map
|
||||
})
|
||||
|
||||
# 处理登录失败
|
||||
func _handle_login_error(data: Dictionary) -> void:
|
||||
var error_message: String = data.get("message", "登录失败")
|
||||
|
||||
_is_logged_in = false
|
||||
|
||||
# 通过 EventSystem 广播错误(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_LOGIN_FAILED, {
|
||||
"error_code": "LOGIN_FAILED",
|
||||
"message": error_message
|
||||
})
|
||||
|
||||
# 处理聊天消息发送成功
|
||||
func _handle_chat_sent(data: Dictionary) -> void:
|
||||
var message_id: String = str(data.get("messageId", ""))
|
||||
var timestamp: float = data.get("timestamp", 0.0)
|
||||
|
||||
# 发射信号
|
||||
chat_message_sent.emit(message_id, timestamp)
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_MESSAGE_SENT, {
|
||||
"message_id": message_id,
|
||||
"timestamp": timestamp
|
||||
})
|
||||
|
||||
# 处理聊天消息发送失败
|
||||
func _handle_chat_error(data: Dictionary) -> void:
|
||||
var error_message: String = data.get("message", "消息发送失败")
|
||||
|
||||
# 通过 EventSystem 广播错误(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_ERROR_OCCURRED, {
|
||||
"error_code": "CHAT_SEND_FAILED",
|
||||
"message": error_message
|
||||
})
|
||||
|
||||
# 处理接收到的聊天消息
|
||||
func _handle_chat_render(data: Dictionary) -> void:
|
||||
# 兼容不同后端字段命名:
|
||||
# - chat_render: {from, txt, bubble, timestamp}
|
||||
# - chat: {content, scope, (可选 from/username/timestamp)}
|
||||
var from_user: String = data.get("from", data.get("from_user", data.get("username", "")))
|
||||
var content: String = data.get("txt", data.get("content", ""))
|
||||
var show_bubble: bool = bool(data.get("bubble", data.get("show_bubble", false)))
|
||||
|
||||
var timestamp: float = _parse_chat_timestamp_to_unix(data.get("timestamp", 0.0))
|
||||
|
||||
var is_self: bool = (not _current_username.is_empty() and from_user == _current_username)
|
||||
if is_self and _consume_pending_self_message(content):
|
||||
# 已经本地回显过,避免重复显示
|
||||
return
|
||||
|
||||
# 如果服务端没带发送者信息,但内容匹配最近自己发送的消息,则认为是自己消息
|
||||
if from_user.is_empty() and _consume_pending_self_message(content):
|
||||
from_user = _current_username
|
||||
is_self = true
|
||||
|
||||
# 添加到历史
|
||||
_add_message_to_history({
|
||||
"from_user": from_user,
|
||||
"content": content,
|
||||
"timestamp": timestamp,
|
||||
"is_self": is_self
|
||||
})
|
||||
|
||||
# 发射信号
|
||||
chat_message_received.emit(from_user, content, show_bubble, timestamp)
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_MESSAGE_RECEIVED, {
|
||||
"from_user": from_user,
|
||||
"content": content,
|
||||
"show_bubble": show_bubble,
|
||||
"timestamp": timestamp,
|
||||
"is_self": is_self
|
||||
})
|
||||
|
||||
# 解析聊天消息时间戳(兼容 unix 秒 / ISO 8601 字符串)
|
||||
func _parse_chat_timestamp_to_unix(timestamp_raw: Variant) -> float:
|
||||
if typeof(timestamp_raw) == TYPE_INT or typeof(timestamp_raw) == TYPE_FLOAT:
|
||||
var ts := float(timestamp_raw)
|
||||
return ts if ts > 0.0 else Time.get_unix_time_from_system()
|
||||
|
||||
var ts_str := str(timestamp_raw)
|
||||
if ts_str.strip_edges().is_empty():
|
||||
return Time.get_unix_time_from_system()
|
||||
|
||||
# 纯数字字符串(必须整串都是数字/小数点,避免把 ISO 字符串前缀 "2026" 误判成时间戳)
|
||||
var numeric_regex := RegEx.new()
|
||||
numeric_regex.compile("^\\s*-?\\d+(?:\\.\\d+)?\\s*$")
|
||||
if numeric_regex.search(ts_str) != null:
|
||||
var ts_num := float(ts_str)
|
||||
return ts_num if ts_num > 0.0 else Time.get_unix_time_from_system()
|
||||
|
||||
# ISO 8601: 2026-01-19T15:15:43.930Z
|
||||
var regex := RegEx.new()
|
||||
regex.compile("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})")
|
||||
var result := regex.search(ts_str)
|
||||
if result == null:
|
||||
return Time.get_unix_time_from_system()
|
||||
|
||||
var utc_dict := {
|
||||
"year": int(result.get_string(1)),
|
||||
"month": int(result.get_string(2)),
|
||||
"day": int(result.get_string(3)),
|
||||
"hour": int(result.get_string(4)),
|
||||
"minute": int(result.get_string(5)),
|
||||
"second": int(result.get_string(6))
|
||||
}
|
||||
return Time.get_unix_time_from_datetime_dict(utc_dict)
|
||||
|
||||
# 处理位置更新成功
|
||||
func _handle_position_updated(data: Dictionary) -> void:
|
||||
var stream: String = data.get("stream", "")
|
||||
var topic: String = data.get("topic", "")
|
||||
|
||||
# 发射信号
|
||||
chat_position_updated.emit(stream, topic)
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_POSITION_UPDATED, {
|
||||
"stream": stream,
|
||||
"topic": topic
|
||||
})
|
||||
|
||||
# 处理错误响应(如果需要)
|
||||
func _handle_error_response(data: Dictionary) -> void:
|
||||
var error_code: String = data.get("code", "")
|
||||
var error_message: String = data.get("message", "")
|
||||
|
||||
_handle_error(error_code, error_message)
|
||||
|
||||
# 处理 Socket 错误(如果需要)
|
||||
func _on_socket_error(error: String) -> void:
|
||||
_handle_error("SOCKET_ERROR", error)
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 工具函数
|
||||
# ============================================================================
|
||||
|
||||
# 处理错误
|
||||
func _handle_error(error_code: String, error_message: String) -> void:
|
||||
push_error("ChatManager: [%s] %s" % [error_code, error_message])
|
||||
|
||||
# 获取用户友好的错误消息
|
||||
var user_message: String = CHAT_ERROR_MESSAGES.get(error_code, error_message) as String
|
||||
|
||||
# 发射信号
|
||||
chat_error_occurred.emit(error_code, user_message)
|
||||
|
||||
# 通过 EventSystem 广播(Signal Up)
|
||||
EventSystem.emit_event(EventNames.CHAT_ERROR_OCCURRED, {
|
||||
"error_code": error_code,
|
||||
"message": user_message
|
||||
})
|
||||
|
||||
# 特殊处理认证失败
|
||||
if error_code == "AUTH_FAILED" or error_code == "SESSION_EXPIRED":
|
||||
_is_logged_in = false
|
||||
EventSystem.emit_event(EventNames.CHAT_LOGIN_FAILED, {
|
||||
"error_code": error_code
|
||||
})
|
||||
|
||||
# 记录消息发送时间戳
|
||||
func _record_message_timestamp() -> void:
|
||||
var current_time := Time.get_unix_time_from_system()
|
||||
_message_timestamps.append(current_time)
|
||||
|
||||
# 消费一个待去重的“自己消息”(允许相同内容多次发送:每次消费一个)
|
||||
func _consume_pending_self_message(content: String) -> bool:
|
||||
var now := Time.get_unix_time_from_system()
|
||||
|
||||
# 先清理过期项
|
||||
for i in range(_pending_self_messages.size() - 1, -1, -1):
|
||||
var item: Dictionary = _pending_self_messages[i]
|
||||
if float(item.get("expires_at", 0.0)) < now:
|
||||
_pending_self_messages.remove_at(i)
|
||||
|
||||
# 再匹配内容
|
||||
for i in range(_pending_self_messages.size() - 1, -1, -1):
|
||||
if str(_pending_self_messages[i].get("content", "")) == content:
|
||||
_pending_self_messages.remove_at(i)
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
# 添加消息到当前会话历史
|
||||
func _add_message_to_history(message: Dictionary) -> void:
|
||||
_message_history.append(message)
|
||||
|
||||
# 更新最旧消息时间戳(用于历史消息加载)
|
||||
if _oldest_message_timestamp == 0.0 or message.timestamp < _oldest_message_timestamp:
|
||||
_oldest_message_timestamp = message.timestamp
|
||||
|
||||
# 限制当前会话消息数量(超过后删除最旧的)
|
||||
if _message_history.size() > MAX_SESSION_MESSAGES:
|
||||
_message_history.pop_front()
|
||||
@@ -57,7 +57,6 @@ var game_version: String = "1.0.0" # 游戏版本号
|
||||
# 初始化游戏管理器
|
||||
# 在节点准备就绪时调用,设置初始状态
|
||||
func _ready():
|
||||
print("GameManager 初始化完成")
|
||||
change_state(GameState.AUTH) # 启动时进入认证状态
|
||||
|
||||
# ============ 状态管理方法 ============
|
||||
@@ -81,9 +80,6 @@ func change_state(new_state: GameState):
|
||||
previous_state = current_state
|
||||
current_state = new_state
|
||||
|
||||
# 输出状态变更日志
|
||||
print("游戏状态变更: ", GameState.keys()[previous_state], " -> ", GameState.keys()[current_state])
|
||||
|
||||
# 发送状态变更信号
|
||||
game_state_changed.emit(new_state)
|
||||
|
||||
@@ -100,7 +96,7 @@ func get_current_state() -> GameState:
|
||||
# GameState - 上一个游戏状态
|
||||
#
|
||||
# 使用场景:
|
||||
# - 从暂停状态恢复时,返回到之前的状态
|
||||
# - 从暂停状态恢复时,返回到暂停前状态
|
||||
# - 错误处理时回退到安全状态
|
||||
func get_previous_state() -> GameState:
|
||||
return previous_state
|
||||
@@ -114,14 +110,12 @@ func get_previous_state() -> GameState:
|
||||
#
|
||||
# 功能:
|
||||
# - 存储当前登录用户信息
|
||||
# - 输出用户设置日志
|
||||
#
|
||||
# 注意事项:
|
||||
# - 用户登录成功后调用此方法
|
||||
# - 用户登出时应传入空字符串
|
||||
func set_current_user(username: String):
|
||||
current_user = username
|
||||
print("当前用户设置为: ", username)
|
||||
|
||||
# 获取当前登录用户
|
||||
#
|
||||
|
||||
155
_Core/managers/LocationManager.gd
Normal file
@@ -0,0 +1,155 @@
|
||||
extends Node
|
||||
|
||||
# ============================================================================
|
||||
# LocationManager.gd - 位置同步管理器
|
||||
# ============================================================================
|
||||
# 负责与后端 WebSocket 服务进行位置同步和多人会话管理
|
||||
#
|
||||
# 协议文档: new_docs/game_architecture_design.md
|
||||
# 后端地址: wss://whaletownend.xinghangee.icu/location-broadcast
|
||||
# ============================================================================
|
||||
|
||||
signal connected_to_server()
|
||||
signal connection_closed()
|
||||
signal connection_error()
|
||||
signal session_joined(data: Dictionary)
|
||||
signal user_joined(data: Dictionary)
|
||||
signal user_left(data: Dictionary)
|
||||
signal position_updated(data: Dictionary)
|
||||
|
||||
const WS_URL = "wss://whaletownend.xinghangee.icu/location-broadcast"
|
||||
const PING_INTERVAL = 25.0 # 秒
|
||||
|
||||
var _socket: WebSocketPeer
|
||||
var _connected: bool = false
|
||||
var _ping_timer: float = 0.0
|
||||
var _auth_token: String = ""
|
||||
|
||||
func _ready():
|
||||
_socket = WebSocketPeer.new()
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS # 保证暂停时也能处理网络
|
||||
|
||||
func _process(delta):
|
||||
_socket.poll()
|
||||
var state = _socket.get_ready_state()
|
||||
|
||||
if state == WebSocketPeer.STATE_OPEN:
|
||||
if not _connected:
|
||||
_on_connected()
|
||||
|
||||
# 处理接收到的数据包
|
||||
while _socket.get_available_packet_count() > 0:
|
||||
var packet = _socket.get_packet()
|
||||
_handle_packet(packet)
|
||||
|
||||
# 心跳处理
|
||||
_ping_timer += delta
|
||||
if _ping_timer >= PING_INTERVAL:
|
||||
_send_heartbeat()
|
||||
_ping_timer = 0.0
|
||||
|
||||
elif state == WebSocketPeer.STATE_CLOSED:
|
||||
if _connected:
|
||||
_on_disconnected()
|
||||
|
||||
func connect_to_server():
|
||||
if _socket.get_ready_state() == WebSocketPeer.STATE_OPEN:
|
||||
return
|
||||
|
||||
var err = _socket.connect_to_url(WS_URL)
|
||||
if err != OK:
|
||||
push_error("LocationManager: WebSocket 连接请求失败,错误码: %d" % err)
|
||||
connection_error.emit()
|
||||
else:
|
||||
# Godot WebSocket connect is non-blocking, wait for state change in _process
|
||||
pass
|
||||
|
||||
func close_connection():
|
||||
_socket.close()
|
||||
|
||||
func set_auth_token(token: String):
|
||||
_auth_token = token
|
||||
|
||||
# ============ 协议发送 ============
|
||||
|
||||
func send_packet(event: String, data: Dictionary):
|
||||
if _socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||
return
|
||||
|
||||
var message = {
|
||||
"event": event,
|
||||
"data": data
|
||||
}
|
||||
var json_str = JSON.stringify(message)
|
||||
_socket.put_packet(json_str.to_utf8_buffer())
|
||||
|
||||
func join_session(map_id: String, initial_pos: Vector2):
|
||||
var data = {
|
||||
"sessionId": map_id,
|
||||
"initialPosition": {
|
||||
"x": initial_pos.x,
|
||||
"y": initial_pos.y,
|
||||
"mapId": map_id
|
||||
},
|
||||
"token": _auth_token
|
||||
}
|
||||
send_packet("join_session", data)
|
||||
|
||||
func leave_session(map_id: String):
|
||||
send_packet("leave_session", {"sessionId": map_id})
|
||||
|
||||
func send_position_update(map_id: String, pos: Vector2, anim_data: Dictionary = {}):
|
||||
var data = {
|
||||
"x": pos.x,
|
||||
"y": pos.y,
|
||||
"mapId": map_id,
|
||||
"metadata": anim_data
|
||||
}
|
||||
if map_id == "":
|
||||
push_warning("LocationManager: position_update 的 map_id 为空")
|
||||
send_packet("position_update", data)
|
||||
|
||||
func _send_heartbeat():
|
||||
send_packet("heartbeat", {"timestamp": Time.get_unix_time_from_system()})
|
||||
|
||||
# ============ 事件处理 ============
|
||||
|
||||
func _on_connected():
|
||||
_connected = true
|
||||
connected_to_server.emit()
|
||||
|
||||
func _on_disconnected():
|
||||
_connected = false
|
||||
connection_closed.emit()
|
||||
|
||||
func _handle_packet(packet: PackedByteArray):
|
||||
var json_str = packet.get_string_from_utf8()
|
||||
var json = JSON.new()
|
||||
var err = json.parse(json_str)
|
||||
|
||||
if err != OK:
|
||||
push_error("LocationManager: JSON 解析失败 - %s" % json.get_error_message())
|
||||
return
|
||||
|
||||
var message = json.data
|
||||
if not message is Dictionary or not message.has("event"):
|
||||
return
|
||||
|
||||
var event = message["event"]
|
||||
var data = message.get("data", {})
|
||||
|
||||
match event:
|
||||
"session_joined":
|
||||
session_joined.emit(data)
|
||||
"user_joined":
|
||||
user_joined.emit(data)
|
||||
"user_left":
|
||||
user_left.emit(data)
|
||||
"position_update":
|
||||
position_updated.emit(data)
|
||||
"heartbeat_response":
|
||||
pass # 静默处理
|
||||
"error":
|
||||
push_error("LocationManager: WebSocket 错误事件 - %s" % JSON.stringify(data))
|
||||
_:
|
||||
push_warning("LocationManager: 未处理的 WebSocket 事件 %s" % event)
|
||||
1
_Core/managers/LocationManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://biyq426f66nkb
|
||||
@@ -109,13 +109,6 @@ class RequestInfo:
|
||||
var active_requests: Dictionary = {} # 存储所有活动请求 {request_id: RequestInfo}
|
||||
var request_counter: int = 0 # 请求计数器,用于生成唯一ID
|
||||
|
||||
# ============ 生命周期方法 ============
|
||||
|
||||
# 初始化网络管理器
|
||||
# 在节点准备就绪时调用
|
||||
func _ready():
|
||||
print("NetworkManager 已初始化")
|
||||
|
||||
# ============ 公共API接口 ============
|
||||
|
||||
# 发送GET请求
|
||||
@@ -193,14 +186,6 @@ func delete_request(endpoint: String, callback: Callable = Callable(), timeout:
|
||||
#
|
||||
# 回调函数签名:
|
||||
# func callback(success: bool, data: Dictionary, error_info: Dictionary)
|
||||
#
|
||||
# 使用示例:
|
||||
# NetworkManager.login("user@example.com", "password123", func(success, data, error):
|
||||
# if success:
|
||||
# print("登录成功: ", data)
|
||||
# else:
|
||||
# print("登录失败: ", error.message)
|
||||
# )
|
||||
func login(identifier: String, password: String, callback: Callable = Callable()) -> String:
|
||||
var data = {
|
||||
"identifier": identifier,
|
||||
@@ -472,41 +457,24 @@ func send_request(endpoint: String, method: RequestType, headers: PackedStringAr
|
||||
var godot_method = _convert_to_godot_method(method)
|
||||
var error = http_request.request(full_url, headers, godot_method, body)
|
||||
|
||||
print("=== 发送网络请求 ===")
|
||||
print("请求ID: ", request_id)
|
||||
print("URL: ", full_url)
|
||||
print("方法: ", RequestType.keys()[method])
|
||||
print("Headers: ", headers)
|
||||
print("Body: ", body if body.length() < 200 else body.substr(0, 200) + "...")
|
||||
print("发送结果: ", error)
|
||||
|
||||
if error != OK:
|
||||
print("请求发送失败,错误代码: ", error)
|
||||
push_error("NetworkManager: 请求发送失败,错误码: %d" % error)
|
||||
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络请求发送失败: " + str(error))
|
||||
return ""
|
||||
|
||||
return request_id
|
||||
|
||||
# 请求完成回调
|
||||
func _on_request_completed(request_id: String, result: int, response_code: int,
|
||||
headers: PackedStringArray, body: PackedByteArray):
|
||||
print("=== 网络请求完成 ===")
|
||||
print("请求ID: ", request_id)
|
||||
print("结果: ", result)
|
||||
print("状态码: ", response_code)
|
||||
print("响应头: ", headers)
|
||||
|
||||
func _on_request_completed(request_id: String, _result: int, response_code: int,
|
||||
_headers: PackedStringArray, body: PackedByteArray):
|
||||
# 获取请求信息
|
||||
if not active_requests.has(request_id):
|
||||
print("警告: 未找到请求ID ", request_id)
|
||||
push_warning("NetworkManager: 未找到请求ID %s" % request_id)
|
||||
return
|
||||
|
||||
var _request_info = active_requests[request_id]
|
||||
var response_text = body.get_string_from_utf8()
|
||||
|
||||
print("响应体长度: ", body.size(), " 字节")
|
||||
print("响应内容: ", response_text if response_text.length() < 500 else response_text.substr(0, 500) + "...")
|
||||
|
||||
# 处理网络连接失败
|
||||
if response_code == 0:
|
||||
_handle_request_error(request_id, ErrorType.NETWORK_ERROR, "网络连接失败,请检查网络连接")
|
||||
@@ -542,13 +510,11 @@ func _handle_response(request_id: String, response_code: int, data: Dictionary):
|
||||
# 特殊情况:206测试模式 - 根据API文档,这是成功的测试模式响应
|
||||
elif response_code == 206 and error_code == "TEST_MODE_ONLY":
|
||||
is_success = true
|
||||
print("🧪 测试模式响应: ", message)
|
||||
# 201创建成功
|
||||
elif response_code == 201:
|
||||
is_success = true
|
||||
|
||||
if is_success:
|
||||
print("✅ 请求成功: ", request_id)
|
||||
# 发送成功信号
|
||||
request_completed.emit(request_id, true, data)
|
||||
|
||||
@@ -556,8 +522,6 @@ func _handle_response(request_id: String, response_code: int, data: Dictionary):
|
||||
if request_info.callback.is_valid():
|
||||
request_info.callback.call(true, data, {})
|
||||
else:
|
||||
print("❌ 请求失败: ", request_id, " - HTTP:", response_code, " 错误码:", error_code, " 消息:", message)
|
||||
|
||||
# 确定错误类型
|
||||
var error_type = _determine_error_type(response_code, error_code)
|
||||
|
||||
@@ -579,7 +543,7 @@ func _handle_response(request_id: String, response_code: int, data: Dictionary):
|
||||
|
||||
# 处理请求错误
|
||||
func _handle_request_error(request_id: String, error_type: ErrorType, message: String):
|
||||
print("❌ 请求错误: ", request_id, " - ", message)
|
||||
push_error("NetworkManager: 请求错误 %s - %s" % [request_id, message])
|
||||
|
||||
# 发送错误信号
|
||||
request_failed.emit(request_id, ErrorType.keys()[error_type], message)
|
||||
@@ -638,8 +602,6 @@ func _cleanup_request(request_id: String):
|
||||
|
||||
# 从活动请求中移除
|
||||
active_requests.erase(request_id)
|
||||
|
||||
print("🧹 清理请求: ", request_id)
|
||||
|
||||
# 转换请求方法
|
||||
func _convert_to_godot_method(method: RequestType) -> HTTPClient.Method:
|
||||
@@ -662,14 +624,12 @@ func _convert_to_godot_method(method: RequestType) -> HTTPClient.Method:
|
||||
# 取消请求
|
||||
func cancel_request(request_id: String) -> bool:
|
||||
if active_requests.has(request_id):
|
||||
print("🚫 取消请求: ", request_id)
|
||||
_cleanup_request(request_id)
|
||||
return true
|
||||
return false
|
||||
|
||||
# 取消所有请求
|
||||
func cancel_all_requests():
|
||||
print("🚫 取消所有请求")
|
||||
var request_ids = active_requests.keys()
|
||||
for request_id in request_ids:
|
||||
cancel_request(request_id)
|
||||
|
||||
@@ -128,21 +128,15 @@ func handle_send_verification_code_response(success: bool, data: Dictionary, err
|
||||
var error_code = data.get("error_code", "")
|
||||
if error_code == "TEST_MODE_ONLY":
|
||||
result.success = true
|
||||
result.message = "🧪 测试模式:验证码已生成,请查看控制台"
|
||||
result.message = "🧪 测试模式:验证码已生成"
|
||||
result.toast_type = "success"
|
||||
|
||||
# 在控制台显示验证码
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 测试模式验证码: ", data.data.verification_code)
|
||||
result.message += "\n验证码: " + str(data.data.verification_code)
|
||||
else:
|
||||
result.success = true
|
||||
result.message = "📧 验证码已发送到您的邮箱,请查收"
|
||||
result.toast_type = "success"
|
||||
|
||||
# 开发环境下显示验证码
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 开发环境验证码: ", data.data.verification_code)
|
||||
else:
|
||||
result = _handle_send_code_error(data, error_info)
|
||||
|
||||
@@ -156,18 +150,15 @@ func handle_send_login_code_response(success: bool, data: Dictionary, error_info
|
||||
var error_code = data.get("error_code", "")
|
||||
if error_code == "TEST_MODE_ONLY":
|
||||
result.success = true
|
||||
result.message = "测试模式:登录验证码已生成,请查看控制台"
|
||||
result.message = "测试模式:登录验证码已生成"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("测试模式登录验证码: ", data.data.verification_code)
|
||||
result.message += "\n验证码: " + str(data.data.verification_code)
|
||||
else:
|
||||
result.success = true
|
||||
result.message = "登录验证码已发送,请查收"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("开发环境登录验证码: ", data.data.verification_code)
|
||||
else:
|
||||
result = _handle_send_login_code_error(data, error_info)
|
||||
|
||||
@@ -214,18 +205,15 @@ func handle_resend_email_verification_response(success: bool, data: Dictionary,
|
||||
var error_code = data.get("error_code", "")
|
||||
if error_code == "TEST_MODE_ONLY":
|
||||
result.success = true
|
||||
result.message = "🧪 测试模式:验证码已重新生成,请查看控制台"
|
||||
result.message = "🧪 测试模式:验证码已重新生成"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 测试模式重新发送验证码: ", data.data.verification_code)
|
||||
result.message += "\n验证码: " + str(data.data.verification_code)
|
||||
else:
|
||||
result.success = true
|
||||
result.message = "📧 验证码已重新发送到您的邮箱,请查收"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 开发环境重新发送验证码: ", data.data.verification_code)
|
||||
else:
|
||||
result = _handle_resend_email_verification_error(data, error_info)
|
||||
|
||||
@@ -239,18 +227,15 @@ func handle_forgot_password_response(success: bool, data: Dictionary, error_info
|
||||
var error_code = data.get("error_code", "")
|
||||
if error_code == "TEST_MODE_ONLY":
|
||||
result.success = true
|
||||
result.message = "🧪 测试模式:重置验证码已生成,请查看控制台"
|
||||
result.message = "🧪 测试模式:重置验证码已生成"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 测试模式重置验证码: ", data.data.verification_code)
|
||||
result.message += "\n验证码: " + str(data.data.verification_code)
|
||||
else:
|
||||
result.success = true
|
||||
result.message = "📧 重置验证码已发送,请查收"
|
||||
result.toast_type = "success"
|
||||
|
||||
if data.has("data") and data.data.has("verification_code"):
|
||||
print("🔑 开发环境重置验证码: ", data.data.verification_code)
|
||||
else:
|
||||
result = _handle_forgot_password_error(data, error_info)
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ signal scene_change_started(scene_name: String)
|
||||
# 场景状态
|
||||
var current_scene_name: String = "" # 当前场景名称
|
||||
var is_changing_scene: bool = false # 是否正在切换场景
|
||||
var _next_scene_position: Variant = null # 下一个场景的初始位置 (Vector2 or null)
|
||||
var _next_spawn_name: String = "" # 下一个场景的出生点名称 (String)
|
||||
|
||||
# 场景路径映射表
|
||||
# 将场景名称映射到实际的文件路径
|
||||
@@ -47,16 +49,14 @@ var scene_paths: Dictionary = {
|
||||
"battle": "res://scenes/maps/battle_scene.tscn", # 战斗场景 - 战斗系统
|
||||
"inventory": "res://scenes/ui/InventoryWindow.tscn", # 背包界面
|
||||
"shop": "res://scenes/ui/ShopWindow.tscn", # 商店界面
|
||||
"settings": "res://scenes/ui/SettingsWindow.tscn" # 设置界面
|
||||
"settings": "res://scenes/ui/SettingsWindow.tscn", # 设置界面
|
||||
"square": "res://scenes/Maps/square.tscn", # 广场地图
|
||||
"room": "res://scenes/Maps/room.tscn", # 房间地图
|
||||
"fountain": "res://scenes/Maps/fountain.tscn", # 喷泉地图
|
||||
"datawhale_home": "res://scenes/Maps/datawhale_home.tscn", # 数据鲸鱼之家
|
||||
"community": "res://scenes/Maps/community.tscn" # 社区地图
|
||||
}
|
||||
|
||||
# ============ 生命周期方法 ============
|
||||
|
||||
# 初始化场景管理器
|
||||
# 在节点准备就绪时调用
|
||||
func _ready():
|
||||
print("SceneManager 初始化完成")
|
||||
|
||||
# ============ 场景切换方法 ============
|
||||
|
||||
# 切换到指定场景
|
||||
@@ -77,8 +77,6 @@ func _ready():
|
||||
#
|
||||
# 使用示例:
|
||||
# var success = SceneManager.change_scene("main", true)
|
||||
# if success:
|
||||
# print("场景切换成功")
|
||||
#
|
||||
# 注意事项:
|
||||
# - 场景切换是异步操作
|
||||
@@ -87,16 +85,15 @@ func _ready():
|
||||
func change_scene(scene_name: String, use_transition: bool = true):
|
||||
# 防止重复切换
|
||||
if is_changing_scene:
|
||||
print("场景切换中,忽略新的切换请求")
|
||||
push_warning("SceneManager: 场景切换中,忽略新的切换请求")
|
||||
return false
|
||||
|
||||
# 检查场景是否存在
|
||||
if not scene_paths.has(scene_name):
|
||||
print("错误: 未找到场景 ", scene_name)
|
||||
push_error("SceneManager: 未找到场景 %s" % scene_name)
|
||||
return false
|
||||
|
||||
var scene_path = scene_paths[scene_name]
|
||||
print("开始切换场景: ", current_scene_name, " -> ", scene_name)
|
||||
|
||||
# 设置切换状态
|
||||
is_changing_scene = true
|
||||
@@ -109,7 +106,7 @@ func change_scene(scene_name: String, use_transition: bool = true):
|
||||
# 执行场景切换
|
||||
var error = get_tree().change_scene_to_file(scene_path)
|
||||
if error != OK:
|
||||
print("场景切换失败: ", error)
|
||||
push_error("SceneManager: 场景切换失败 %s -> %s, 错误码: %d" % [current_scene_name, scene_name, error])
|
||||
is_changing_scene = false
|
||||
return false
|
||||
|
||||
@@ -122,18 +119,83 @@ func change_scene(scene_name: String, use_transition: bool = true):
|
||||
if use_transition:
|
||||
await hide_transition()
|
||||
|
||||
print("场景切换完成: ", scene_name)
|
||||
return true
|
||||
|
||||
# ============ 查询方法 ============
|
||||
|
||||
# 获取当前场景名称
|
||||
#
|
||||
#
|
||||
# 返回值:
|
||||
# String - 当前场景的名称
|
||||
func get_current_scene_name() -> String:
|
||||
return current_scene_name
|
||||
|
||||
# ============ 场景位置和出生点管理 ============
|
||||
|
||||
# 设置下一个场景的初始位置
|
||||
#
|
||||
# 参数:
|
||||
# pos: Vector2 - 玩家在下一个场景的初始位置
|
||||
#
|
||||
# 功能:
|
||||
# - 用于场景切换时传递玩家位置信息
|
||||
# - 配合 DoorTeleport 等传送机制使用
|
||||
#
|
||||
# 使用示例:
|
||||
# SceneManager.set_next_scene_position(Vector2(100, 200))
|
||||
# SceneManager.change_scene("room")
|
||||
func set_next_scene_position(pos: Vector2) -> void:
|
||||
_next_scene_position = pos
|
||||
|
||||
# 获取并清除下一个场景的初始位置
|
||||
#
|
||||
# 返回值:
|
||||
# Variant - Vector2 位置或 null(如果未设置)
|
||||
#
|
||||
# 功能:
|
||||
# - 获取预设的场景初始位置
|
||||
# - 获取后自动清除,避免影响后续场景切换
|
||||
#
|
||||
# 注意事项:
|
||||
# - 此方法会清除存储的位置,只能获取一次
|
||||
# - 如果未设置位置,返回 null
|
||||
func get_next_scene_position() -> Variant:
|
||||
var pos = _next_scene_position
|
||||
_next_scene_position = null
|
||||
return pos
|
||||
|
||||
# 设置下一个场景的出生点名称
|
||||
#
|
||||
# 参数:
|
||||
# spawn_name: String - 出生点节点的名称
|
||||
#
|
||||
# 功能:
|
||||
# - 指定玩家在下一个场景应该出现在哪个出生点
|
||||
# - 配合场景中的 Marker2D 出生点使用
|
||||
#
|
||||
# 使用示例:
|
||||
# SceneManager.set_next_spawn_name("DoorExit")
|
||||
# SceneManager.change_scene("square")
|
||||
func set_next_spawn_name(spawn_name: String) -> void:
|
||||
_next_spawn_name = spawn_name
|
||||
|
||||
# 获取并清除下一个场景的出生点名称
|
||||
#
|
||||
# 返回值:
|
||||
# String - 出生点名称(如果未设置则返回空字符串)
|
||||
#
|
||||
# 功能:
|
||||
# - 获取预设的出生点名称
|
||||
# - 获取后自动清除,避免影响后续场景切换
|
||||
#
|
||||
# 注意事项:
|
||||
# - 此方法会清除存储的名称,只能获取一次
|
||||
# - 如果未设置名称,返回空字符串
|
||||
func get_next_spawn_name() -> String:
|
||||
var name = _next_spawn_name
|
||||
_next_spawn_name = ""
|
||||
return name
|
||||
|
||||
# ============ 场景注册方法 ============
|
||||
|
||||
# 注册新场景
|
||||
@@ -150,7 +212,6 @@ func get_current_scene_name() -> String:
|
||||
# SceneManager.register_scene("boss_battle", "res://scenes/boss/boss_battle.tscn")
|
||||
func register_scene(scene_name: String, scene_path: String):
|
||||
scene_paths[scene_name] = scene_path
|
||||
print("注册场景: ", scene_name, " -> ", scene_path)
|
||||
|
||||
# ============ 过渡效果方法 ============
|
||||
|
||||
@@ -166,8 +227,7 @@ func register_scene(scene_name: String, scene_path: String):
|
||||
#
|
||||
# TODO: 实现淡入淡出、滑动等过渡效果
|
||||
func show_transition():
|
||||
# TODO: 实现场景切换过渡效果
|
||||
print("显示场景切换过渡效果")
|
||||
# TODO: 实现场景切换过渡效果(当前仅占位延时)
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
|
||||
# 隐藏场景切换过渡效果
|
||||
@@ -182,6 +242,5 @@ func show_transition():
|
||||
#
|
||||
# TODO: 实现与show_transition()对应的隐藏效果
|
||||
func hide_transition():
|
||||
# TODO: 隐藏场景切换过渡效果
|
||||
print("隐藏场景切换过渡效果")
|
||||
# TODO: 隐藏场景切换过渡效果(当前仅占位延时)
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
|
||||
@@ -40,7 +40,6 @@ var toast_counter: int = 0 # Toast计数器,用于生成
|
||||
# container: Control - Toast消息的容器节点
|
||||
func setup(container: Control):
|
||||
toast_container = container
|
||||
print("ToastManager 初始化完成")
|
||||
|
||||
# ============ 公共方法 ============
|
||||
|
||||
@@ -51,10 +50,9 @@ func setup(container: Control):
|
||||
# is_success: bool - 是否为成功消息(影响颜色)
|
||||
func show_toast(message: String, is_success: bool = true):
|
||||
if toast_container == null:
|
||||
print("错误: toast_container 节点不存在")
|
||||
push_error("ToastManager: toast_container 节点不存在")
|
||||
return
|
||||
|
||||
print("显示Toast消息: ", message, " 成功: ", is_success)
|
||||
_create_toast_instance(message, is_success)
|
||||
|
||||
# 清理所有Toast
|
||||
@@ -123,21 +121,17 @@ func _create_toast_instance(message: String, is_success: bool):
|
||||
|
||||
# 平台特定的字体处理
|
||||
if is_web:
|
||||
print("Web平台Toast字体处理")
|
||||
# Web平台使用主题文件
|
||||
var chinese_theme = load("res://assets/ui/chinese_theme.tres")
|
||||
if chinese_theme:
|
||||
text_label.theme = chinese_theme
|
||||
print("Web平台应用中文主题")
|
||||
else:
|
||||
print("Web平台中文主题加载失败")
|
||||
push_warning("ToastManager: Web平台中文主题加载失败,使用默认字体")
|
||||
else:
|
||||
print("桌面平台Toast字体处理")
|
||||
# 桌面平台直接加载中文字体
|
||||
var desktop_chinese_font = load("res://assets/fonts/msyh.ttc")
|
||||
if desktop_chinese_font:
|
||||
text_label.add_theme_font_override("font", desktop_chinese_font)
|
||||
print("桌面平台使用中文字体")
|
||||
|
||||
text_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
text_label.custom_minimum_size = Vector2(280, 0)
|
||||
@@ -231,4 +225,4 @@ func _rearrange_toasts():
|
||||
if is_instance_valid(toast):
|
||||
var tween = toast_container.create_tween()
|
||||
tween.tween_property(toast, "position:y", current_y, 0.2)
|
||||
current_y += toast.size.y + 15
|
||||
current_y += toast.size.y + 15
|
||||
|
||||
429
_Core/managers/WebSocketManager.gd
Normal file
@@ -0,0 +1,429 @@
|
||||
extends Node
|
||||
|
||||
# ============================================================================
|
||||
# WebSocketManager.gd - WebSocket 连接生命周期管理(原生 WebSocket 版本)
|
||||
# ============================================================================
|
||||
# 管理 WebSocket 连接状态、自动重连和错误恢复
|
||||
#
|
||||
# 核心职责:
|
||||
# - 连接状态管理(断开、连接中、已连接、重连中)
|
||||
# - 自动重连机制(指数退避)
|
||||
# - 连接错误恢复
|
||||
# - WebSocket 消息发送/接收
|
||||
# ============================================================================
|
||||
# 使用方式:
|
||||
# WebSocketManager.connect_to_game_server()
|
||||
# WebSocketManager.connection_state_changed.connect(_on_state_changed)
|
||||
#
|
||||
# 注意事项:
|
||||
# - 作为自动加载单例,全局可访问
|
||||
# - 自动处理连接断开和重连
|
||||
# - 通过信号通知连接状态变化
|
||||
# ============================================================================
|
||||
|
||||
class_name ChatWebSocketManager
|
||||
|
||||
# ============================================================================
|
||||
# 信号定义
|
||||
# ============================================================================
|
||||
|
||||
# 连接状态变化信号
|
||||
# 参数:
|
||||
# new_state: ConnectionState - 新的连接状态
|
||||
signal connection_state_changed(new_state: ConnectionState)
|
||||
|
||||
# 连接丢失信号
|
||||
signal connection_lost()
|
||||
|
||||
# 重连成功信号
|
||||
signal reconnection_succeeded()
|
||||
|
||||
# 重连失败信号
|
||||
# 参数:
|
||||
# attempt: int - 当前重连尝试次数
|
||||
# max_attempts: int - 最大重连次数
|
||||
signal reconnection_failed(attempt: int, max_attempts: int)
|
||||
|
||||
# WebSocket 消息接收信号
|
||||
# 参数:
|
||||
# message: String - 接收到的消息内容(JSON 字符串)
|
||||
signal data_received(message: String)
|
||||
|
||||
# ============================================================================
|
||||
# 枚举定义
|
||||
# ============================================================================
|
||||
|
||||
# 连接状态枚举
|
||||
enum ConnectionState {
|
||||
DISCONNECTED, # 未连接
|
||||
CONNECTING, # 连接中
|
||||
CONNECTED, # 已连接
|
||||
RECONNECTING, # 重连中
|
||||
ERROR # 错误状态
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# 常量定义
|
||||
# ============================================================================
|
||||
|
||||
# WebSocket 服务器 URL(原生 WebSocket)
|
||||
const WEBSOCKET_URL: String = "wss://whaletownend.xinghangee.icu/game"
|
||||
|
||||
# 默认最大重连次数
|
||||
const DEFAULT_MAX_RECONNECT_ATTEMPTS: int = 5
|
||||
|
||||
# 默认重连基础延迟(秒)
|
||||
const DEFAULT_RECONNECT_BASE_DELAY: float = 3.0
|
||||
|
||||
# 最大重连延迟(秒)
|
||||
const MAX_RECONNECT_DELAY: float = 30.0
|
||||
|
||||
# ============================================================================
|
||||
# 成员变量
|
||||
# ============================================================================
|
||||
|
||||
# WebSocket peer
|
||||
var _websocket_peer: WebSocketPeer = WebSocketPeer.new()
|
||||
|
||||
# 当前连接状态
|
||||
var _connection_state: ConnectionState = ConnectionState.DISCONNECTED
|
||||
|
||||
# 自动重连启用标志
|
||||
var _auto_reconnect_enabled: bool = true
|
||||
|
||||
# 最大重连次数
|
||||
var _max_reconnect_attempts: int = DEFAULT_MAX_RECONNECT_ATTEMPTS
|
||||
|
||||
# 重连基础延迟
|
||||
var _reconnect_base_delay: float = DEFAULT_RECONNECT_BASE_DELAY
|
||||
|
||||
# 当前重连尝试次数
|
||||
var _reconnect_attempt: int = 0
|
||||
|
||||
# 重连定时器
|
||||
var _reconnect_timer: Timer = Timer.new()
|
||||
|
||||
# 是否为正常关闭(非异常断开)
|
||||
var _clean_close: bool = true
|
||||
|
||||
# 心跳定时器
|
||||
var _heartbeat_timer: Timer = Timer.new()
|
||||
|
||||
# 心跳间隔(秒)
|
||||
const HEARTBEAT_INTERVAL: float = 30.0
|
||||
|
||||
# ============================================================================
|
||||
# 生命周期方法
|
||||
# ============================================================================
|
||||
|
||||
# 初始化
|
||||
func _ready() -> void:
|
||||
# 设置重连定时器
|
||||
_setup_reconnect_timer()
|
||||
|
||||
# 设置心跳定时器
|
||||
_setup_heartbeat_timer()
|
||||
|
||||
# 启动处理循环
|
||||
set_process(true)
|
||||
|
||||
# 处理每帧
|
||||
func _process(_delta: float) -> void:
|
||||
# 检查 WebSocket 状态变化
|
||||
_check_websocket_state()
|
||||
|
||||
var state: WebSocketPeer.State = _websocket_peer.get_ready_state()
|
||||
|
||||
if state == WebSocketPeer.STATE_OPEN:
|
||||
# 接收数据
|
||||
_websocket_peer.poll()
|
||||
|
||||
# 处理收到的数据
|
||||
while _websocket_peer.get_available_packet_count() > 0:
|
||||
var packet: PackedByteArray = _websocket_peer.get_packet()
|
||||
var message: String = packet.get_string_from_utf8()
|
||||
|
||||
# 发射消息接收信号
|
||||
data_received.emit(message)
|
||||
|
||||
# 清理
|
||||
func _exit_tree() -> void:
|
||||
_disconnect()
|
||||
|
||||
if is_instance_valid(_reconnect_timer):
|
||||
_reconnect_timer.stop()
|
||||
_reconnect_timer.queue_free()
|
||||
|
||||
if is_instance_valid(_heartbeat_timer):
|
||||
_heartbeat_timer.stop()
|
||||
_heartbeat_timer.queue_free()
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 连接管理
|
||||
# ============================================================================
|
||||
|
||||
# 连接到游戏服务器
|
||||
func connect_to_game_server() -> void:
|
||||
if _connection_state == ConnectionState.CONNECTED or _connection_state == ConnectionState.CONNECTING:
|
||||
push_warning("已经在连接或已连接状态")
|
||||
return
|
||||
|
||||
_set_connection_state(ConnectionState.CONNECTING)
|
||||
_clean_close = true
|
||||
_reconnect_attempt = 0
|
||||
|
||||
var err: Error = _websocket_peer.connect_to_url(WEBSOCKET_URL)
|
||||
if err != OK:
|
||||
push_error("WebSocketManager: 连接失败 - %s" % error_string(err))
|
||||
_set_connection_state(ConnectionState.ERROR)
|
||||
return
|
||||
|
||||
# 启动心跳
|
||||
_start_heartbeat()
|
||||
|
||||
# 断开 WebSocket 连接
|
||||
func disconnect_websocket() -> void:
|
||||
_disconnect()
|
||||
|
||||
# 断开连接(内部方法)
|
||||
func _disconnect() -> void:
|
||||
_clean_close = true
|
||||
|
||||
# 停止重连定时器
|
||||
_reconnect_timer.stop()
|
||||
|
||||
# 停止心跳
|
||||
_heartbeat_timer.stop()
|
||||
|
||||
# 关闭 WebSocket
|
||||
if _websocket_peer.get_ready_state() == WebSocketPeer.STATE_OPEN:
|
||||
_websocket_peer.close()
|
||||
|
||||
_set_connection_state(ConnectionState.DISCONNECTED)
|
||||
|
||||
# 检查 WebSocket 是否已连接
|
||||
#
|
||||
# 返回值:
|
||||
# bool - WebSocket 是否已连接
|
||||
func is_websocket_connected() -> bool:
|
||||
return _connection_state == ConnectionState.CONNECTED
|
||||
|
||||
# 获取当前连接状态
|
||||
#
|
||||
# 返回值:
|
||||
# ConnectionState - 当前连接状态
|
||||
func get_connection_state() -> ConnectionState:
|
||||
return _connection_state
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 消息发送
|
||||
# ============================================================================
|
||||
|
||||
# 发送 WebSocket 消息
|
||||
#
|
||||
# 参数:
|
||||
# message: String - 要发送的消息内容(JSON 字符串)
|
||||
#
|
||||
# 返回值:
|
||||
# Error - 错误码,OK 表示成功
|
||||
func send_message(message: String) -> Error:
|
||||
if _websocket_peer.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||
push_warning("WebSocketManager: 未连接,无法发送消息")
|
||||
return ERR_UNCONFIGURED
|
||||
|
||||
var err: Error = _websocket_peer.send_text(message)
|
||||
if err != OK:
|
||||
push_error("WebSocketManager: 发送消息失败 - %s" % error_string(err))
|
||||
return err
|
||||
|
||||
return OK
|
||||
|
||||
# ============================================================================
|
||||
# 公共 API - 自动重连
|
||||
# ============================================================================
|
||||
|
||||
# 启用/禁用自动重连
|
||||
#
|
||||
# 参数:
|
||||
# enabled: bool - 是否启用自动重连
|
||||
# max_attempts: int - 最大重连次数(默认 5)
|
||||
# base_delay: float - 基础重连延迟,秒(默认 3.0)
|
||||
#
|
||||
# 使用示例:
|
||||
# WebSocketManager.enable_auto_reconnect(true, 5, 3.0)
|
||||
func enable_auto_reconnect(enabled: bool, max_attempts: int = DEFAULT_MAX_RECONNECT_ATTEMPTS, base_delay: float = DEFAULT_RECONNECT_BASE_DELAY) -> void:
|
||||
_auto_reconnect_enabled = enabled
|
||||
_max_reconnect_attempts = max_attempts
|
||||
_reconnect_base_delay = base_delay
|
||||
|
||||
# 获取重连信息
|
||||
#
|
||||
# 返回值:
|
||||
# Dictionary - 重连信息 {enabled, attempt, max_attempts, delay}
|
||||
func get_reconnect_info() -> Dictionary:
|
||||
return {
|
||||
"enabled": _auto_reconnect_enabled,
|
||||
"attempt": _reconnect_attempt,
|
||||
"max_attempts": _max_reconnect_attempts,
|
||||
"next_delay": _calculate_reconnect_delay() if _connection_state == ConnectionState.RECONNECTING else 0.0
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 连接状态管理
|
||||
# ============================================================================
|
||||
|
||||
# 设置连接状态
|
||||
func _set_connection_state(new_state: ConnectionState) -> void:
|
||||
if _connection_state == new_state:
|
||||
return
|
||||
|
||||
_connection_state = new_state
|
||||
|
||||
# 发射信号
|
||||
connection_state_changed.emit(new_state)
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - WebSocket 状态监控
|
||||
# ============================================================================
|
||||
|
||||
# 检查 WebSocket 状态变化
|
||||
func _check_websocket_state() -> void:
|
||||
# 必须先 poll 才能获取最新状态
|
||||
_websocket_peer.poll()
|
||||
|
||||
var state: WebSocketPeer.State = _websocket_peer.get_ready_state()
|
||||
|
||||
match state:
|
||||
WebSocketPeer.STATE_CONNECTING:
|
||||
# 正在连接
|
||||
if _connection_state != ConnectionState.CONNECTING and _connection_state != ConnectionState.RECONNECTING:
|
||||
_set_connection_state(ConnectionState.CONNECTING)
|
||||
|
||||
WebSocketPeer.STATE_OPEN:
|
||||
# 连接成功
|
||||
if _connection_state != ConnectionState.CONNECTED:
|
||||
_on_websocket_connected()
|
||||
|
||||
WebSocketPeer.STATE_CLOSING:
|
||||
# 正在关闭
|
||||
pass
|
||||
|
||||
WebSocketPeer.STATE_CLOSED:
|
||||
# 连接关闭
|
||||
var code: int = _websocket_peer.get_close_code()
|
||||
_on_websocket_closed(code != 0) # code=0 表示正常关闭
|
||||
|
||||
# WebSocket 连接成功处理
|
||||
func _on_websocket_connected() -> void:
|
||||
# 如果是重连,发射重连成功信号
|
||||
if _connection_state == ConnectionState.RECONNECTING:
|
||||
_reconnect_attempt = 0
|
||||
reconnection_succeeded.emit()
|
||||
|
||||
_set_connection_state(ConnectionState.CONNECTED)
|
||||
|
||||
# WebSocket 连接关闭处理
|
||||
func _on_websocket_closed(clean_close: bool) -> void:
|
||||
_clean_close = clean_close
|
||||
|
||||
# 如果是异常断开且启用了自动重连
|
||||
if not clean_close and _auto_reconnect_enabled:
|
||||
connection_lost.emit()
|
||||
_attempt_reconnect()
|
||||
else:
|
||||
_set_connection_state(ConnectionState.DISCONNECTED)
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 重连机制
|
||||
# ============================================================================
|
||||
|
||||
# 设置重连定时器
|
||||
func _setup_reconnect_timer() -> void:
|
||||
_reconnect_timer = Timer.new()
|
||||
_reconnect_timer.one_shot = true
|
||||
_reconnect_timer.autostart = false
|
||||
add_child(_reconnect_timer)
|
||||
|
||||
_reconnect_timer.timeout.connect(_on_reconnect_timeout)
|
||||
|
||||
# 尝试重连
|
||||
func _attempt_reconnect() -> void:
|
||||
# 检查是否超过最大重连次数
|
||||
if _reconnect_attempt >= _max_reconnect_attempts:
|
||||
push_error("WebSocketManager: 达到最大重连次数 (%d),停止重连" % _max_reconnect_attempts)
|
||||
reconnection_failed.emit(_reconnect_attempt, _max_reconnect_attempts)
|
||||
_set_connection_state(ConnectionState.ERROR)
|
||||
return
|
||||
|
||||
_reconnect_attempt += 1
|
||||
_set_connection_state(ConnectionState.RECONNECTING)
|
||||
|
||||
# 计算重连延迟(指数退避)
|
||||
var delay: float = _calculate_reconnect_delay()
|
||||
|
||||
# 启动重连定时器
|
||||
_reconnect_timer.start(delay)
|
||||
|
||||
# 计算重连延迟(指数退避)
|
||||
func _calculate_reconnect_delay() -> float:
|
||||
# 指数退避: base_delay * 2^(attempt-1)
|
||||
var delay: float = _reconnect_base_delay * pow(2.0, _reconnect_attempt - 1)
|
||||
|
||||
# 限制最大延迟
|
||||
return min(delay, MAX_RECONNECT_DELAY)
|
||||
|
||||
# 重连定时器超时处理
|
||||
func _on_reconnect_timeout() -> void:
|
||||
_clean_close = false
|
||||
connect_to_game_server()
|
||||
|
||||
# ============================================================================
|
||||
# 内部方法 - 心跳机制
|
||||
# ============================================================================
|
||||
|
||||
# 设置心跳定时器
|
||||
func _setup_heartbeat_timer() -> void:
|
||||
_heartbeat_timer = Timer.new()
|
||||
_heartbeat_timer.wait_time = HEARTBEAT_INTERVAL
|
||||
_heartbeat_timer.one_shot = false
|
||||
_heartbeat_timer.autostart = false
|
||||
add_child(_heartbeat_timer)
|
||||
|
||||
_heartbeat_timer.timeout.connect(_on_heartbeat)
|
||||
|
||||
# 启动心跳
|
||||
func _start_heartbeat() -> void:
|
||||
_heartbeat_timer.start()
|
||||
|
||||
# 停止心跳
|
||||
func _stop_heartbeat() -> void:
|
||||
_heartbeat_timer.stop()
|
||||
|
||||
# 心跳超时处理
|
||||
func _on_heartbeat() -> void:
|
||||
# 不发送心跳,避免服务器返回 "消息格式错误"
|
||||
# 如果需要心跳,服务器应该支持特定格式
|
||||
pass
|
||||
|
||||
# ============================================================================
|
||||
# 工具方法
|
||||
# ============================================================================
|
||||
|
||||
# 获取连接状态描述
|
||||
#
|
||||
# 返回值:
|
||||
# String - 连接状态描述
|
||||
func get_state_description() -> String:
|
||||
match _connection_state:
|
||||
ConnectionState.DISCONNECTED:
|
||||
return "未连接"
|
||||
ConnectionState.CONNECTING:
|
||||
return "连接中"
|
||||
ConnectionState.CONNECTED:
|
||||
return "已连接"
|
||||
ConnectionState.RECONNECTING:
|
||||
return "重连中 (%d/%d)" % [_reconnect_attempt, _max_reconnect_attempts]
|
||||
ConnectionState.ERROR:
|
||||
return "错误"
|
||||
_:
|
||||
return "未知状态"
|
||||
@@ -27,13 +27,6 @@ extends Node
|
||||
# 结构: {event_name: [{"callback": Callable, "target": Node}, ...]}
|
||||
var event_listeners: Dictionary = {}
|
||||
|
||||
# ============ 生命周期方法 ============
|
||||
|
||||
# 初始化事件系统
|
||||
# 在节点准备就绪时调用
|
||||
func _ready():
|
||||
print("EventSystem 初始化完成")
|
||||
|
||||
# ============ 事件监听器管理 ============
|
||||
|
||||
# 注册事件监听器
|
||||
@@ -59,6 +52,11 @@ func connect_event(event_name: String, callback: Callable, target: Node = null):
|
||||
if not event_listeners.has(event_name):
|
||||
event_listeners[event_name] = []
|
||||
|
||||
# 避免重复注册同一个监听器
|
||||
for listener in event_listeners[event_name]:
|
||||
if listener.callback == callback and listener.target == target:
|
||||
return
|
||||
|
||||
# 创建监听器信息
|
||||
var listener_info = {
|
||||
"callback": callback,
|
||||
@@ -67,7 +65,6 @@ func connect_event(event_name: String, callback: Callable, target: Node = null):
|
||||
|
||||
# 添加到监听器列表
|
||||
event_listeners[event_name].append(listener_info)
|
||||
print("注册事件监听器: ", event_name, " -> ", callback)
|
||||
|
||||
# 移除事件监听器
|
||||
#
|
||||
@@ -93,7 +90,6 @@ func disconnect_event(event_name: String, callback: Callable, target: Node = nul
|
||||
# 匹配callback和target
|
||||
if listener.callback == callback and listener.target == target:
|
||||
listeners.remove_at(i)
|
||||
print("移除事件监听器: ", event_name, " -> ", callback)
|
||||
break
|
||||
|
||||
# ============ 事件发送 ============
|
||||
@@ -117,13 +113,11 @@ func disconnect_event(event_name: String, callback: Callable, target: Node = nul
|
||||
# - 事件发送是同步的,所有监听器会立即执行
|
||||
# - 如果监听器执行出错,不会影响其他监听器
|
||||
func emit_event(event_name: String, data: Variant = null):
|
||||
print("发送事件: ", event_name, " 数据: ", data)
|
||||
|
||||
# 检查是否有监听器
|
||||
if not event_listeners.has(event_name):
|
||||
return
|
||||
|
||||
var listeners = event_listeners[event_name]
|
||||
var listeners = event_listeners[event_name].duplicate()
|
||||
for listener_info in listeners:
|
||||
var target = listener_info.target
|
||||
var callback = listener_info.callback
|
||||
@@ -161,7 +155,6 @@ func cleanup_invalid_listeners():
|
||||
# 如果目标节点无效,移除监听器
|
||||
if target != null and not is_instance_valid(target):
|
||||
listeners.remove_at(i)
|
||||
print("清理无效监听器: ", event_name)
|
||||
|
||||
# ============ 查询方法 ============
|
||||
|
||||
@@ -192,4 +185,3 @@ func get_listener_count(event_name: String) -> int:
|
||||
# - 使用前请确保所有模块都能正确处理监听器丢失
|
||||
func clear_all_listeners():
|
||||
event_listeners.clear()
|
||||
print("清空所有事件监听器")
|
||||
|
||||
@@ -131,13 +131,14 @@ static func get_grid_rect(grid_pos: Vector2i) -> Rect2:
|
||||
var world_pos = grid_to_world(grid_pos)
|
||||
return Rect2(world_pos, Vector2(GRID_SIZE, GRID_SIZE))
|
||||
|
||||
# 打印网格信息(调试用)
|
||||
static func print_grid_info(world_pos: Vector2) -> void:
|
||||
# 获取网格信息(调试辅助)
|
||||
static func print_grid_info(world_pos: Vector2) -> Dictionary:
|
||||
var grid_pos = world_to_grid(world_pos)
|
||||
var snapped_pos = snap_to_grid(world_pos)
|
||||
var center_pos = grid_to_world_center(grid_pos)
|
||||
|
||||
print("世界坐标: ", world_pos)
|
||||
print("网格坐标: ", grid_pos)
|
||||
print("吸附位置: ", snapped_pos)
|
||||
print("网格中心: ", center_pos)
|
||||
return {
|
||||
"world_position": world_pos,
|
||||
"grid_position": grid_pos,
|
||||
"snapped_position": snapped_pos,
|
||||
"center_position": center_pos
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class_name StringUtils
|
||||
#
|
||||
# 使用示例:
|
||||
# if StringUtils.is_valid_email("user@example.com"):
|
||||
# print("邮箱格式正确")
|
||||
# # 邮箱格式正确
|
||||
static func is_valid_email(email: String) -> bool:
|
||||
var regex = RegEx.new()
|
||||
regex.compile("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$")
|
||||
@@ -60,7 +60,7 @@ static func is_valid_email(email: String) -> bool:
|
||||
#
|
||||
# 使用示例:
|
||||
# if StringUtils.is_valid_username("user_123"):
|
||||
# print("用户名格式正确")
|
||||
# # 用户名格式正确
|
||||
static func is_valid_username(username: String) -> bool:
|
||||
# 检查长度
|
||||
if username.is_empty() or username.length() > 50:
|
||||
@@ -92,7 +92,7 @@ static func is_valid_username(username: String) -> bool:
|
||||
# 使用示例:
|
||||
# var result = StringUtils.validate_password_strength("MyPass123!")
|
||||
# if result.valid:
|
||||
# print("密码强度: ", result.message)
|
||||
# # 可按需展示 result.message
|
||||
static func validate_password_strength(password: String) -> Dictionary:
|
||||
var result = {"valid": false, "message": "", "strength": 0}
|
||||
|
||||
@@ -383,4 +383,4 @@ static func get_relative_time_until(utc_time_str: String) -> String:
|
||||
if minutes > 0:
|
||||
return "%d小时%d分钟后" % [hours, minutes]
|
||||
else:
|
||||
return "%d小时后" % hours
|
||||
return "%d小时后" % hours
|
||||
|
||||
BIN
assets/characters/npc_286_241.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
40
assets/characters/npc_286_241.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://brko2ik6t6ib5"
|
||||
path="res://.godot/imported/npc_286_241.png-dfe6daef11d0f27f7902e69d6057828f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/characters/npc_286_241.png"
|
||||
dest_files=["res://.godot/imported/npc_286_241.png-dfe6daef11d0f27f7902e69d6057828f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/characters/payer_44_30.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
40
assets/characters/payer_44_30.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://krfed1r4qmnp"
|
||||
path="res://.godot/imported/payer_44_30.png-100395b4756c93dec9ce9baa5c5df0f3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/characters/payer_44_30.png"
|
||||
dest_files=["res://.godot/imported/payer_44_30.png-100395b4756c93dec9ce9baa5c5df0f3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/characters/player_spritesheet.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
40
assets/characters/player_spritesheet.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cghab1hkx5lg5"
|
||||
path="res://.godot/imported/player_spritesheet.png-7e76f97a17946ec512358d45f2527da8.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/characters/player_spritesheet.png"
|
||||
dest_files=["res://.godot/imported/player_spritesheet.png-7e76f97a17946ec512358d45f2527da8.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/characters/player_spritesheet_backup.png
Normal file
|
After Width: | Height: | Size: 856 KiB |
40
assets/characters/player_spritesheet_backup.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dyimi462hj6r2"
|
||||
path="res://.godot/imported/player_spritesheet_backup.png-6d8c966a56b0ced39cf1ecf0c772847f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/characters/player_spritesheet_backup.png"
|
||||
dest_files=["res://.godot/imported/player_spritesheet_backup.png-6d8c966a56b0ced39cf1ecf0c772847f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/materials/NoticeBoard.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
40
assets/materials/NoticeBoard.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dw7lapxn4m8ry"
|
||||
path="res://.godot/imported/NoticeBoard.png-038eefee12f116fb9502ed755594cede.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/materials/NoticeBoard.png"
|
||||
dest_files=["res://.godot/imported/NoticeBoard.png-038eefee12f116fb9502ed755594cede.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
BIN
assets/materials/WelcomeBoard.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
40
assets/materials/WelcomeBoard.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c5y8qxm3jn2wv"
|
||||
path="res://.godot/imported/WelcomeBoard.png-bcff7f9bf968cb5d7630e2ad47f2fb42.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/materials/WelcomeBoard.png"
|
||||
dest_files=["res://.godot/imported/WelcomeBoard.png-bcff7f9bf968cb5d7630e2ad47f2fb42.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
BIN
assets/sprites/environment/board.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
40
assets/sprites/environment/board.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c7jx40leuy6q1"
|
||||
path="res://.godot/imported/board.png-4f7a101e7a1b1cbdc8a75666c78e8907.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/board.png"
|
||||
dest_files=["res://.godot/imported/board.png-4f7a101e7a1b1cbdc8a75666c78e8907.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/community.png
Normal file
|
After Width: | Height: | Size: 5.6 MiB |
40
assets/sprites/environment/community.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://7j3n0nhg8atb"
|
||||
path="res://.godot/imported/community.png-a8c4bd53b7eaad8a751801ba0eb4ea69.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/community.png"
|
||||
dest_files=["res://.godot/imported/community.png-a8c4bd53b7eaad8a751801ba0eb4ea69.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/community_512_512.png
Normal file
|
After Width: | Height: | Size: 458 KiB |
40
assets/sprites/environment/community_512_512.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cle66our01dq1"
|
||||
path="res://.godot/imported/community_512_512.png-fa162180b6884ce89074ec9b8b445a11.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/community_512_512.png"
|
||||
dest_files=["res://.godot/imported/community_512_512.png-fa162180b6884ce89074ec9b8b445a11.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_256_111.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
40
assets/sprites/environment/deck_256_111.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bxk7qx15ks23n"
|
||||
path="res://.godot/imported/deck_256_111.png-1f5516606f281e4ce47eda14a0f195f6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_256_111.png"
|
||||
dest_files=["res://.godot/imported/deck_256_111.png-1f5516606f281e4ce47eda14a0f195f6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_256_93.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
40
assets/sprites/environment/deck_256_93.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cuoondqo7wpvm"
|
||||
path="res://.godot/imported/deck_256_93.png-53cc7596920e943ad680f551cecde9c5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_256_93.png"
|
||||
dest_files=["res://.godot/imported/deck_256_93.png-53cc7596920e943ad680f551cecde9c5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_2784_1536.png
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
40
assets/sprites/environment/deck_2784_1536.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dth4pwye1huv1"
|
||||
path="res://.godot/imported/deck_2784_1536.png-7209e3c01bcb29b96850c5bfe2118eb5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_2784_1536.png"
|
||||
dest_files=["res://.godot/imported/deck_2784_1536.png-7209e3c01bcb29b96850c5bfe2118eb5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_384_167.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
40
assets/sprites/environment/deck_384_167.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d3w3fncsm32oi"
|
||||
path="res://.godot/imported/deck_384_167.png-f28a21a5574e4d3fa7c0565d6c292757.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_384_167.png"
|
||||
dest_files=["res://.godot/imported/deck_384_167.png-f28a21a5574e4d3fa7c0565d6c292757.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_512_164.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
40
assets/sprites/environment/deck_512_164.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://j0twhfkpj15i"
|
||||
path="res://.godot/imported/deck_512_164.png-c98703495d73d104671911f6dada9aca.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_512_164.png"
|
||||
dest_files=["res://.godot/imported/deck_512_164.png-c98703495d73d104671911f6dada9aca.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_512_282.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
40
assets/sprites/environment/deck_512_282.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://blre1srim52hs"
|
||||
path="res://.godot/imported/deck_512_282.png-ec2cdd543ebb499e3623cd89dff86aa4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_512_282.png"
|
||||
dest_files=["res://.godot/imported/deck_512_282.png-ec2cdd543ebb499e3623cd89dff86aa4.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/deck_512_512.png
Normal file
|
After Width: | Height: | Size: 570 KiB |
40
assets/sprites/environment/deck_512_512.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://drdfggxi5ecw7"
|
||||
path="res://.godot/imported/deck_512_512.png-14cca0360b4e43a84ff23febdf688dce.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/deck_512_512.png"
|
||||
dest_files=["res://.godot/imported/deck_512_512.png-14cca0360b4e43a84ff23febdf688dce.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/e2f5aff78fae12f979d3456eca0896b4.jpg
Normal file
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ci5myym3wxvej"
|
||||
path="res://.godot/imported/e2f5aff78fae12f979d3456eca0896b4.jpg-09ffb25e15f901ba90adc883741736d3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/e2f5aff78fae12f979d3456eca0896b4.jpg"
|
||||
dest_files=["res://.godot/imported/e2f5aff78fae12f979d3456eca0896b4.jpg-09ffb25e15f901ba90adc883741736d3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/fountain_256_192.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
40
assets/sprites/environment/fountain_256_192.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dujutnr03apoj"
|
||||
path="res://.godot/imported/fountain_256_192.png-6fb4e69b74642a426b29631ef7156f53.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/fountain_256_192.png"
|
||||
dest_files=["res://.godot/imported/fountain_256_192.png-6fb4e69b74642a426b29631ef7156f53.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/grass_128_128.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
40
assets/sprites/environment/grass_128_128.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://h1kqvkvshfxo"
|
||||
path="res://.godot/imported/grass_128_128.png-f99428f7721484fc94b70ea8f73a140d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/grass_128_128.png"
|
||||
dest_files=["res://.godot/imported/grass_128_128.png-f99428f7721484fc94b70ea8f73a140d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/grass_256_256.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
40
assets/sprites/environment/grass_256_256.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dwlnclqw6lsa7"
|
||||
path="res://.godot/imported/grass_256_256.png-480baf97b2b792db085b32018ac813a5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/grass_256_256.png"
|
||||
dest_files=["res://.godot/imported/grass_256_256.png-480baf97b2b792db085b32018ac813a5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/ground.png
Normal file
|
After Width: | Height: | Size: 2.7 MiB |
40
assets/sprites/environment/ground.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ccqxsarxnnf4e"
|
||||
path="res://.godot/imported/ground.png-2205e043de9d3b8a38f01788dff375d3.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/ground.png"
|
||||
dest_files=["res://.godot/imported/ground.png-2205e043de9d3b8a38f01788dff375d3.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/house_256_192.png
Normal file
|
After Width: | Height: | Size: 71 KiB |
40
assets/sprites/environment/house_256_192.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dtev6yddbjtvp"
|
||||
path="res://.godot/imported/house_256_192.png-939b43001a6826dd2fb03b0e500d6b91.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/house_256_192.png"
|
||||
dest_files=["res://.godot/imported/house_256_192.png-939b43001a6826dd2fb03b0e500d6b91.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/house_384_256.png
Normal file
|
After Width: | Height: | Size: 125 KiB |
40
assets/sprites/environment/house_384_256.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bxmbnywn7pd35"
|
||||
path="res://.godot/imported/house_384_256.png-9c21ec19000d397cf04e3d4c46d9fd67.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/house_384_256.png"
|
||||
dest_files=["res://.godot/imported/house_384_256.png-9c21ec19000d397cf04e3d4c46d9fd67.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/house_384_288.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
40
assets/sprites/environment/house_384_288.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://drl6vecqinsgw"
|
||||
path="res://.godot/imported/house_384_288.png-2c4bb2980ec70d9c801e9d8f5c9da5e2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/house_384_288.png"
|
||||
dest_files=["res://.godot/imported/house_384_288.png-2c4bb2980ec70d9c801e9d8f5c9da5e2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/river.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
40
assets/sprites/environment/river.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c7v86fkrcb4go"
|
||||
path="res://.godot/imported/river.png-5a4acbf78dd4e08f27a3192f37afc708.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/river.png"
|
||||
dest_files=["res://.godot/imported/river.png-5a4acbf78dd4e08f27a3192f37afc708.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/river2_256_256.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
40
assets/sprites/environment/river2_256_256.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://df3klfat72qro"
|
||||
path="res://.godot/imported/river2_256_256.png-4b34411e3a9844aea328c2b5fdd9f6d7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/river2_256_256.png"
|
||||
dest_files=["res://.godot/imported/river2_256_256.png-4b34411e3a9844aea328c2b5fdd9f6d7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/river2_512_512.png
Normal file
|
After Width: | Height: | Size: 207 KiB |
40
assets/sprites/environment/river2_512_512.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://5r75q24ww18f"
|
||||
path="res://.godot/imported/river2_512_512.png-af87f8da62bcadc69167d888dc2932d0.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/river2_512_512.png"
|
||||
dest_files=["res://.godot/imported/river2_512_512.png-af87f8da62bcadc69167d888dc2932d0.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/river_256_256.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
40
assets/sprites/environment/river_256_256.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://devfvbybifga6"
|
||||
path="res://.godot/imported/river_256_256.png-9a57f752ac6003da70cffda69b91371a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/river_256_256.png"
|
||||
dest_files=["res://.godot/imported/river_256_256.png-9a57f752ac6003da70cffda69b91371a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/river_512_512.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
40
assets/sprites/environment/river_512_512.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b4wt8paqrevg2"
|
||||
path="res://.godot/imported/river_512_512.png-218f1dc6fae57e80762824a68b0c08f6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/river_512_512.png"
|
||||
dest_files=["res://.godot/imported/river_512_512.png-218f1dc6fae57e80762824a68b0c08f6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/room_512_384.png
Normal file
|
After Width: | Height: | Size: 255 KiB |
40
assets/sprites/environment/room_512_384.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bjcij2ncikeyw"
|
||||
path="res://.godot/imported/room_512_384.png-339d4ab4d8dc5972ef1c8a09d0380694.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/room_512_384.png"
|
||||
dest_files=["res://.godot/imported/room_512_384.png-339d4ab4d8dc5972ef1c8a09d0380694.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/standard_brick.png.png
Normal file
|
After Width: | Height: | Size: 569 KiB |
40
assets/sprites/environment/standard_brick.png.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://icto1uyw4hj1"
|
||||
path="res://.godot/imported/standard_brick.png.png-f806a78b5dfedf81aa2e413ced30aa6a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/standard_brick.png.png"
|
||||
dest_files=["res://.godot/imported/standard_brick.png.png-f806a78b5dfedf81aa2e413ced30aa6a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/standard_brick_128_128.jpg
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
40
assets/sprites/environment/standard_brick_128_128.jpg.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://baa5wkuyqouh6"
|
||||
path="res://.godot/imported/standard_brick_128_128.jpg-0dc76f792db60d64e5610aa75364c4ef.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/standard_brick_128_128.jpg"
|
||||
dest_files=["res://.godot/imported/standard_brick_128_128.jpg-0dc76f792db60d64e5610aa75364c4ef.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/sprites/environment/water.png
Normal file
|
After Width: | Height: | Size: 3.9 MiB |
40
assets/sprites/environment/water.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://balpojbve2n4f"
|
||||
path="res://.godot/imported/water.png-28a245d0248e5e7513f6a266dcca901f.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/environment/water.png"
|
||||
dest_files=["res://.godot/imported/water.png-28a245d0248e5e7513f6a266dcca901f.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -22,6 +22,11 @@ SceneManager="*res://_Core/managers/SceneManager.gd"
|
||||
EventSystem="*res://_Core/systems/EventSystem.gd"
|
||||
NetworkManager="*res://_Core/managers/NetworkManager.gd"
|
||||
ResponseHandler="*res://_Core/managers/ResponseHandler.gd"
|
||||
<<<<<<< HEAD
|
||||
ChatManager="*res://_Core/managers/ChatManager.gd"
|
||||
LocationManager="*res://_Core/managers/LocationManager.gd"
|
||||
=======
|
||||
>>>>>>> main
|
||||
|
||||
[debug]
|
||||
|
||||
@@ -29,10 +34,15 @@ gdscript/warnings/treat_warnings_as_errors=false
|
||||
|
||||
[display]
|
||||
|
||||
<<<<<<< HEAD
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1440
|
||||
=======
|
||||
window/size/viewport_width=1376
|
||||
window/size/viewport_height=768
|
||||
>>>>>>> main
|
||||
window/size/mode=2
|
||||
window/stretch/mode="canvas_items"
|
||||
window/stretch/mode="viewport"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[gui]
|
||||
@@ -85,6 +95,8 @@ locale/test="zh_CN"
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
2d/snap/snap_2d_transforms_to_pixel=true
|
||||
2d/snap/snap_2d_vertices_to_pixel=true
|
||||
fonts/dynamic_fonts/use_oversampling=true
|
||||
debug/disable_vsync=false
|
||||
debug/settings/stdout/print_fps=false
|
||||
|
||||
@@ -75,7 +75,6 @@ func show_main_game():
|
||||
main_game_ui.visible = true
|
||||
user_label.text = "当前用户: " + current_user
|
||||
update_player_status()
|
||||
print("进入主游戏界面")
|
||||
|
||||
func update_player_status():
|
||||
level_label.text = "等级: " + str(player_level)
|
||||
@@ -86,34 +85,66 @@ func update_player_status():
|
||||
func _on_login_success(username: String):
|
||||
# 登录成功后的处理
|
||||
current_user = username
|
||||
print("用户 ", username, " 登录成功!")
|
||||
show_main_game()
|
||||
|
||||
# 连接到聊天服务器(在进入游戏界面之前)
|
||||
# 注意:token 已在 AuthScene._on_controller_login_success 中设置
|
||||
ChatManager.connect_to_chat_server()
|
||||
|
||||
# 连接到位置同步服务器
|
||||
LocationManager.connect_to_server()
|
||||
|
||||
# 直接进入游戏地图(不显示MainGameUI)
|
||||
_setup_game_environment()
|
||||
|
||||
func _on_logout_pressed():
|
||||
# 登出处理
|
||||
current_user = ""
|
||||
|
||||
# 断开聊天服务器连接
|
||||
ChatManager.disconnect_from_chat_server()
|
||||
|
||||
show_auth_scene()
|
||||
|
||||
# 游戏功能按钮处理
|
||||
func _on_explore_pressed():
|
||||
print("探索小镇功能")
|
||||
show_game_message("🗺️ 探索功能开发中...")
|
||||
|
||||
func _on_inventory_pressed():
|
||||
print("背包功能")
|
||||
show_game_message("🎒 背包功能开发中...")
|
||||
|
||||
func _on_shop_pressed():
|
||||
print("商店功能")
|
||||
show_game_message("🏪 商店功能开发中...")
|
||||
|
||||
func _on_friends_pressed():
|
||||
print("好友功能")
|
||||
show_game_message("👥 好友功能开发中...")
|
||||
|
||||
func show_game_message(message: String):
|
||||
print("游戏消息: ", message)
|
||||
# 这里可以添加UI提示框显示消息
|
||||
func show_game_message(_message: String):
|
||||
# TODO: 用 Toast 或游戏内提示框替代占位实现
|
||||
pass
|
||||
|
||||
# 设置游戏环境(登录后直接加载地图)
|
||||
func _setup_game_environment():
|
||||
# 防止登录切场景时输入状态残留导致角色“卡移动键”
|
||||
_release_movement_actions()
|
||||
|
||||
# 1. 隐藏UI
|
||||
current_state = GameState.MAIN_GAME
|
||||
auth_scene.visible = false
|
||||
main_game_ui.visible = false
|
||||
|
||||
# 2. 隐藏聊天框(需要按Enter才显示)
|
||||
if is_instance_valid(chat_ui) and chat_ui.has_method("hide_chat"):
|
||||
chat_ui.hide_chat()
|
||||
|
||||
# 3. 使用 SceneManager 切换到广场地图
|
||||
SceneManager.change_scene("square", false) # false = 不使用过渡效果
|
||||
|
||||
func _release_movement_actions() -> void:
|
||||
Input.action_release("move_left")
|
||||
Input.action_release("move_right")
|
||||
Input.action_release("move_up")
|
||||
Input.action_release("move_down")
|
||||
Input.flush_buffered_events()
|
||||
|
||||
# 处理全局输入
|
||||
func _input(event):
|
||||
|
||||
287
scenes/Maps/BaseLevel.gd
Normal file
@@ -0,0 +1,287 @@
|
||||
class_name BaseLevel
|
||||
extends Node2D
|
||||
|
||||
# 基础关卡脚本
|
||||
# 负责处理通用的关卡逻辑,如玩家生成
|
||||
const CHAT_UI_SCENE: PackedScene = preload("res://scenes/ui/ChatUI.tscn")
|
||||
const CHAT_UI_NODE_NAME: String = "ChatUI"
|
||||
const UI_LAYER_NODE_NAME: String = "UILayer"
|
||||
const UI_LAYER_ORDER: int = 10
|
||||
|
||||
func _ready():
|
||||
_ensure_chat_ui()
|
||||
|
||||
# 延时一帧确保所有子节点就绪
|
||||
call_deferred("_spawn_player")
|
||||
|
||||
# 连接到多人会话
|
||||
# 获取当前场景名字作为 Session ID
|
||||
_current_session_id = SceneManager.get_current_scene_name()
|
||||
if _current_session_id == "":
|
||||
_current_session_id = "square"
|
||||
|
||||
# 如果是私人场景,生成唯一的 Session ID (e.g., room_123)
|
||||
if _current_session_id in PRIVATE_SCENES:
|
||||
_current_session_id = _current_session_id + "_" + str(AuthManager.current_user_id)
|
||||
|
||||
# 如果 WebSocket 已连接,直接加入
|
||||
if LocationManager._socket.get_ready_state() == WebSocketPeer.STATE_OPEN:
|
||||
|
||||
_join_session_with_player(_current_session_id)
|
||||
else:
|
||||
# 否则等待连接成功信号
|
||||
LocationManager.connected_to_server.connect(func(): _join_session_with_player(_current_session_id))
|
||||
|
||||
# 连接远程玩家相关信号
|
||||
LocationManager.session_joined.connect(_on_session_joined)
|
||||
LocationManager.user_joined.connect(_on_user_joined)
|
||||
LocationManager.user_left.connect(_on_user_left)
|
||||
LocationManager.position_updated.connect(_on_position_updated)
|
||||
|
||||
func _ensure_chat_ui() -> void:
|
||||
var ui_layer := get_node_or_null(UI_LAYER_NODE_NAME) as CanvasLayer
|
||||
if ui_layer == null:
|
||||
ui_layer = CanvasLayer.new()
|
||||
ui_layer.name = UI_LAYER_NODE_NAME
|
||||
ui_layer.layer = UI_LAYER_ORDER
|
||||
add_child(ui_layer)
|
||||
|
||||
var chat_ui := ui_layer.get_node_or_null(CHAT_UI_NODE_NAME)
|
||||
if chat_ui == null:
|
||||
chat_ui = CHAT_UI_SCENE.instantiate()
|
||||
chat_ui.name = CHAT_UI_NODE_NAME
|
||||
ui_layer.add_child(chat_ui)
|
||||
|
||||
if chat_ui.has_method("hide_chat"):
|
||||
chat_ui.call_deferred("hide_chat")
|
||||
|
||||
var remote_players: Dictionary = {} # userId -> RemotePlayer instance
|
||||
var remote_player_scene = preload("res://scenes/characters/remote_player.tscn")
|
||||
var _player_spawned: bool = false # Track if local player has been spawned
|
||||
var _local_player: Node = null # Reference to the local player node
|
||||
var _position_update_timer: float = 0.0 # Throttle timer for position updates
|
||||
var _current_session_id: String = "" # Cache session ID to avoid race condition on exit
|
||||
const POSITION_UPDATE_INTERVAL: float = 0.125 # Send at most 8 times per second
|
||||
const PRIVATE_SCENES = ["room"] # List of scenes that should be private instances
|
||||
|
||||
func _on_session_joined(data: Dictionary):
|
||||
# 对账远程玩家列表,使用 position.mapId 过滤
|
||||
if not data.has("users"):
|
||||
return
|
||||
|
||||
var current_map = _current_session_id
|
||||
if current_map == "":
|
||||
current_map = SceneManager.get_current_scene_name()
|
||||
if current_map == "":
|
||||
current_map = "square"
|
||||
|
||||
# 1. 收集服务器返回的、且 mapId 匹配当前场景的用户ID
|
||||
var valid_user_ids: Array = []
|
||||
var valid_users: Dictionary = {} # userId -> user data
|
||||
|
||||
for user in data.users:
|
||||
if not user.has("userId") or str(user.userId) == str(AuthManager.current_user_id):
|
||||
continue
|
||||
|
||||
# 检查 position.mapId 是否匹配当前场景
|
||||
var user_map_id = ""
|
||||
if user.has("position") and user.position != null:
|
||||
if typeof(user.position) == TYPE_DICTIONARY and user.position.has("mapId"):
|
||||
user_map_id = str(user.position.mapId)
|
||||
|
||||
if user_map_id == current_map:
|
||||
var uid = str(user.userId)
|
||||
valid_user_ids.append(uid)
|
||||
valid_users[uid] = user
|
||||
|
||||
# 2. 清理幽灵:移除本地有但不在有效列表中的玩家
|
||||
var local_user_ids = remote_players.keys()
|
||||
for user_id in local_user_ids:
|
||||
if str(user_id) not in valid_user_ids:
|
||||
_remove_remote_player(user_id)
|
||||
|
||||
# 3. 添加或更新有效的玩家
|
||||
for uid in valid_user_ids:
|
||||
var user = valid_users[uid]
|
||||
if remote_players.has(uid):
|
||||
# 已存在,更新位置
|
||||
_update_remote_player_position(user)
|
||||
else:
|
||||
_add_remote_player(user)
|
||||
|
||||
func _on_user_joined(data: Dictionary):
|
||||
var user = data.get("user", {})
|
||||
if user.has("userId"):
|
||||
if user.userId == AuthManager.current_user_id:
|
||||
return
|
||||
|
||||
# 将 position 数据合并到 user 字典中,以便 _add_remote_player 统一处理
|
||||
if data.has("position"):
|
||||
user["position"] = data.position
|
||||
|
||||
_add_remote_player(user)
|
||||
|
||||
func _on_user_left(data: Dictionary):
|
||||
var user_id = data.get("userId")
|
||||
if user_id:
|
||||
_remove_remote_player(user_id)
|
||||
|
||||
func _on_position_updated(data: Dictionary):
|
||||
var user_id = data.get("userId")
|
||||
|
||||
if user_id and remote_players.has(user_id):
|
||||
var player = remote_players[user_id]
|
||||
# 数据可能直接是位置(扁平)或者包含在 position 字段中
|
||||
# 根据后端协议: { userId:..., position: {x,y...}, ... }
|
||||
var pos_data = data.get("position", {})
|
||||
if pos_data.is_empty():
|
||||
pos_data = data
|
||||
|
||||
# 检查 mapId 是否匹配当前场景
|
||||
if pos_data.has("mapId") and str(pos_data.mapId) != "":
|
||||
var current_map = _current_session_id
|
||||
if current_map == "":
|
||||
current_map = "square"
|
||||
|
||||
if str(pos_data.mapId) != current_map:
|
||||
_remove_remote_player(user_id)
|
||||
return
|
||||
|
||||
if player.has_method("update_position") and pos_data.has("x") and pos_data.has("y"):
|
||||
player.update_position(Vector2(pos_data.x, pos_data.y))
|
||||
|
||||
func _add_remote_player(user_data: Dictionary):
|
||||
var user_id = str(user_data.get("userId", ""))
|
||||
if user_id == "":
|
||||
return
|
||||
|
||||
# 防止重复创建
|
||||
if remote_players.has(user_id):
|
||||
return
|
||||
|
||||
var remote_player = remote_player_scene.instantiate()
|
||||
|
||||
# 使用统一的 setup 方法
|
||||
if remote_player.has_method("setup"):
|
||||
remote_player.setup(user_data)
|
||||
else:
|
||||
# 回退到手动设置位置
|
||||
remote_player.position = Vector2.ZERO
|
||||
if user_data.has("position"):
|
||||
var p = user_data.position
|
||||
if p.has("x") and p.has("y"):
|
||||
remote_player.position = Vector2(p.x, p.y)
|
||||
|
||||
# 添加到场景玩家容器
|
||||
if has_node("Objects/Players"):
|
||||
$Objects/Players.add_child(remote_player)
|
||||
else:
|
||||
add_child(remote_player)
|
||||
|
||||
remote_players[user_id] = remote_player
|
||||
|
||||
func _remove_remote_player(user_id):
|
||||
var uid = str(user_id)
|
||||
if remote_players.has(uid):
|
||||
var player = remote_players[uid]
|
||||
if is_instance_valid(player):
|
||||
player.queue_free()
|
||||
remote_players.erase(uid)
|
||||
|
||||
func _update_remote_player_position(user: Dictionary):
|
||||
var user_id = str(user.get("userId", ""))
|
||||
var player = remote_players.get(user_id)
|
||||
if not player or not is_instance_valid(player):
|
||||
return
|
||||
if user.has("position"):
|
||||
var pos = user.position
|
||||
if pos.has("x") and pos.has("y") and player.has_method("update_position"):
|
||||
player.update_position(Vector2(pos.x, pos.y))
|
||||
|
||||
func _join_session_with_player(session_id: String):
|
||||
# 检查是否有Token,如果没有则等待
|
||||
if LocationManager._auth_token == "":
|
||||
# 轮询等待Token就绪 (简单重试机制)
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
_join_session_with_player(session_id)
|
||||
return
|
||||
|
||||
# 等待玩家生成完毕
|
||||
if not _player_spawned or not _local_player:
|
||||
await get_tree().process_frame
|
||||
_join_session_with_player(session_id)
|
||||
return
|
||||
|
||||
var pos = _local_player.global_position if is_instance_valid(_local_player) else Vector2.ZERO
|
||||
|
||||
LocationManager.join_session(session_id, pos)
|
||||
|
||||
# 进入会话后立即同步一次位置
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
LocationManager.send_position_update(session_id, pos)
|
||||
|
||||
func _process(delta):
|
||||
# 发送位置更新 (节流机制)
|
||||
if not _player_spawned or not _local_player:
|
||||
return # Wait for player to be spawned
|
||||
|
||||
if LocationManager._socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
|
||||
return # WebSocket not connected
|
||||
|
||||
if not is_instance_valid(_local_player):
|
||||
return # Player was freed
|
||||
|
||||
# 检查 velocity 属性
|
||||
if not "velocity" in _local_player:
|
||||
return
|
||||
|
||||
# 只有在移动时才更新计时器和发送
|
||||
if _local_player.velocity.length() > 0:
|
||||
_position_update_timer += delta
|
||||
if _position_update_timer >= POSITION_UPDATE_INTERVAL:
|
||||
_position_update_timer = 0.0
|
||||
var map_id = _current_session_id if _current_session_id != "" else "square"
|
||||
LocationManager.send_position_update(map_id, _local_player.global_position)
|
||||
|
||||
func _spawn_player():
|
||||
# 1. 确定出生位置
|
||||
var spawn_pos = Vector2.ZERO
|
||||
var spawn_name = SceneManager.get_next_spawn_name()
|
||||
|
||||
# 查找逻辑:优先查找名为 spawn_name 的节点,其次找 DefaultSpawn
|
||||
var target_node_name = spawn_name if spawn_name != "" else "DefaultSpawn"
|
||||
var marker_node = null
|
||||
|
||||
# 策略 A: 在 SpawnPoints 容器中查找
|
||||
if has_node("SpawnPoints"):
|
||||
marker_node = $SpawnPoints.get_node_or_null(target_node_name)
|
||||
|
||||
# 策略 B: 如果没找到,在当前节点(根节点)下查找
|
||||
if marker_node == null:
|
||||
marker_node = get_node_or_null(target_node_name)
|
||||
|
||||
# 如果找到了标记点,使用其位置
|
||||
if marker_node:
|
||||
spawn_pos = marker_node.global_position
|
||||
else:
|
||||
# 策略 C: 检查 SceneManager 是否有备用坐标
|
||||
var pos_param = SceneManager.get_next_scene_position()
|
||||
if pos_param != null:
|
||||
spawn_pos = pos_param
|
||||
else:
|
||||
push_warning("BaseLevel: 出生点 '%s' 不存在,使用默认坐标 (0, 0)" % target_node_name)
|
||||
|
||||
# 2. 实例化玩家
|
||||
var player_scene = preload("res://scenes/characters/player.tscn")
|
||||
var player = player_scene.instantiate()
|
||||
player.global_position = spawn_pos
|
||||
|
||||
# 添加到场景
|
||||
# 如果有Objects/Players容器则添加进去,否则直接添加到当前节点
|
||||
if has_node("Objects/Players"):
|
||||
$Objects/Players.add_child(player)
|
||||
else:
|
||||
add_child(player)
|
||||
|
||||
_local_player = player
|
||||
_player_spawned = true
|
||||
1
scenes/Maps/BaseLevel.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b43tvo8cykfrq
|
||||
29
scenes/Maps/DoorTeleport.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends Area2D
|
||||
|
||||
# 场景名称
|
||||
@export var target_scene_name: String = ""
|
||||
@export var target_position: Vector2 = Vector2.ZERO # 目标场景的生成位置 (Vector2.ZERO 表示不设置)
|
||||
@export var target_spawn_name: String = "" # 目标场景的 Marker2D 名称 (例如 "FromSquare")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
# 连接 body_entered 信号
|
||||
body_entered.connect(_on_body_entered)
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
# 检查进入对象是否为玩家
|
||||
if body.has_method("_handle_movement"):
|
||||
_teleport_player()
|
||||
|
||||
func _teleport_player() -> void:
|
||||
if target_scene_name == "":
|
||||
push_error("DoorTeleport: target_scene_name 为空")
|
||||
return
|
||||
|
||||
# 设置参数
|
||||
if target_spawn_name != "":
|
||||
SceneManager.set_next_spawn_name(target_spawn_name)
|
||||
elif target_position != Vector2.ZERO:
|
||||
SceneManager.set_next_scene_position(target_position)
|
||||
|
||||
SceneManager.change_scene(target_scene_name)
|
||||
1
scenes/Maps/DoorTeleport.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://rlkavptfhr4y
|
||||
14
scenes/Maps/community.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dscbaqkb1klwl"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cle66our01dq1" path="res://assets/sprites/environment/community_512_512.png" id="1_jrtph"]
|
||||
|
||||
[node name="Community" type="StaticBody2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(4.7683716e-07, -336)
|
||||
scale = Vector2(1.28125, 1.28125)
|
||||
texture = ExtResource("1_jrtph")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2(152, 16)
|
||||
polygon = PackedVector2Array(-456, -48, -192, -48, -192, -112, -120, -112, -120, -56, 168, -48, 168, -696, -472, -688, -472, -48)
|
||||
13
scenes/Maps/datawhale_home.tscn
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bvfyllcy5fi8o"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bxmbnywn7pd35" path="res://assets/sprites/environment/house_384_256.png" id="1_xrxds"]
|
||||
|
||||
[node name="DataWhaleHome" type="StaticBody2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(16, -160)
|
||||
scale = Vector2(1.2916666, 1.2812501)
|
||||
texture = ExtResource("1_xrxds")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PackedVector2Array(-216, -96, -216, -96, 200, -96, 200, -32, 192, -32, 192, 0, 72, 0, 72, -16, 48, -16, 48, -32, 48, -40, -40, -40, -48, -24, -64, -16, -72, -16, -80, 0, -200, 0, -200, -32, -216, -32)
|
||||
14
scenes/Maps/fountain.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://vq5qgk3k6t7e"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dujutnr03apoj" path="res://assets/sprites/environment/fountain_256_192.png" id="1_utxq6"]
|
||||
|
||||
[node name="Fountain" type="StaticBody2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -128)
|
||||
scale = Vector2(1.3125001, 1.3061225)
|
||||
texture = ExtResource("1_utxq6")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
position = Vector2(-8, 16)
|
||||
polygon = PackedVector2Array(-64, -80, -104, -112, -112, -152, -96, -192, -88, -216, -64, -216, -24, -224, -16, -256, 32, -248, 24, -216, 32, -216, 40, -240, 56, -224, 72, -232, 72, -208, 96, -216, 104, -208, 120, -160, 128, -128, 96, -96, 80, -112, 0, -88, -48, -104, -64, -88)
|
||||
727
scenes/Maps/room.tscn
Normal file
29
scenes/characters/NPCController.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
signal interaction_happened(text)
|
||||
|
||||
@export var npc_name: String = "NPC"
|
||||
@export var dialogue: String = "欢迎来到WhaleTown,我是镇长范鲸晶"
|
||||
|
||||
func _ready():
|
||||
$Sprite2D.texture = preload("res://assets/characters/npc_286_241.png")
|
||||
$Sprite2D.hframes = 4
|
||||
$Sprite2D.vframes = 4
|
||||
|
||||
# Start Idle Animation
|
||||
if has_node("AnimationPlayer"):
|
||||
$AnimationPlayer.play("idle")
|
||||
|
||||
# Ensure interaction layer
|
||||
collision_layer = 3 # Layer 1 & 2 (Blocking)
|
||||
collision_mask = 3
|
||||
|
||||
func interact():
|
||||
show_bubble(dialogue)
|
||||
interaction_happened.emit(dialogue)
|
||||
return null
|
||||
|
||||
func show_bubble(text):
|
||||
var bubble = preload("res://scenes/ui/ChatBubble.tscn").instantiate()
|
||||
add_child(bubble)
|
||||
bubble.set_text(text)
|
||||
1
scenes/characters/NPCController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dy3uf1rlu4h1u
|
||||
116
scenes/characters/PlayerController.gd
Normal file
@@ -0,0 +1,116 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
# 信号定义
|
||||
signal player_moved(position: Vector2)
|
||||
|
||||
# 常量定义
|
||||
const MOVE_SPEED = 200.0
|
||||
|
||||
# 节点引用
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var sprite: Sprite2D = $Sprite2D
|
||||
@onready var ray_cast: RayCast2D = $RayCast2D
|
||||
|
||||
var last_direction := "down"
|
||||
|
||||
func _ready() -> void:
|
||||
_reset_movement_input_state()
|
||||
|
||||
# 检查是否有初始位置设置
|
||||
call_deferred("_check_spawn_position")
|
||||
|
||||
# 播放初始动画
|
||||
if animation_player.has_animation("idle"):
|
||||
animation_player.play("idle")
|
||||
|
||||
# Initialize RayCast
|
||||
ray_cast.add_exception(self) # Ignore local player
|
||||
ray_cast.enabled = true
|
||||
ray_cast.target_position = Vector2(0, 60)
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_APPLICATION_FOCUS_IN:
|
||||
_reset_movement_input_state()
|
||||
|
||||
func _reset_movement_input_state() -> void:
|
||||
Input.action_release("move_left")
|
||||
Input.action_release("move_right")
|
||||
Input.action_release("move_up")
|
||||
Input.action_release("move_down")
|
||||
Input.flush_buffered_events()
|
||||
|
||||
func _check_spawn_position() -> void:
|
||||
var spawn_pos = SceneManager.get_next_scene_position()
|
||||
if spawn_pos != null:
|
||||
global_position = spawn_pos
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
_handle_movement(delta)
|
||||
_handle_interaction()
|
||||
|
||||
func _handle_interaction() -> void:
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
if ray_cast.is_colliding():
|
||||
var collider = ray_cast.get_collider()
|
||||
if collider and collider.has_method("interact"):
|
||||
collider.interact()
|
||||
|
||||
func _handle_movement(_delta: float) -> void:
|
||||
# 输入框获得焦点时禁止移动,避免聊天/表单输入影响角色
|
||||
if _is_text_input_focused():
|
||||
velocity = Vector2.ZERO
|
||||
_play_idle_animation()
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
# 获取移动向量 (参考 docs/02-开发规范/输入映射配置.md)
|
||||
var direction := Input.get_vector(
|
||||
"move_left", "move_right",
|
||||
"move_up", "move_down"
|
||||
)
|
||||
|
||||
# 应用移动
|
||||
if direction != Vector2.ZERO:
|
||||
velocity = direction * MOVE_SPEED
|
||||
_update_animation_state(direction)
|
||||
else:
|
||||
velocity = Vector2.ZERO
|
||||
_play_idle_animation()
|
||||
|
||||
move_and_slide()
|
||||
|
||||
# 发送移动事件 (如果位置发生明显变化)
|
||||
if velocity.length() > 0:
|
||||
EventSystem.emit_event(EventNames.PLAYER_MOVED, {
|
||||
"position": global_position
|
||||
})
|
||||
|
||||
func _update_animation_state(direction: Vector2) -> void:
|
||||
if not animation_player:
|
||||
return
|
||||
|
||||
# Determine primary direction
|
||||
if abs(direction.x) > abs(direction.y):
|
||||
if direction.x > 0:
|
||||
last_direction = "right"
|
||||
ray_cast.target_position = Vector2(60, 0)
|
||||
else:
|
||||
last_direction = "left"
|
||||
ray_cast.target_position = Vector2(-60, 0)
|
||||
else:
|
||||
if direction.y > 0:
|
||||
last_direction = "down"
|
||||
ray_cast.target_position = Vector2(0, 60)
|
||||
else:
|
||||
last_direction = "up"
|
||||
ray_cast.target_position = Vector2(0, -60)
|
||||
|
||||
animation_player.play("walk_" + last_direction)
|
||||
|
||||
func _play_idle_animation() -> void:
|
||||
if animation_player:
|
||||
animation_player.play("idle_" + last_direction)
|
||||
|
||||
func _is_text_input_focused() -> bool:
|
||||
var focus_owner: Control = get_viewport().gui_get_focus_owner()
|
||||
return focus_owner is LineEdit or focus_owner is TextEdit
|
||||
1
scenes/characters/PlayerController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://fdswi18nel8n
|
||||
82
scenes/characters/RemotePlayer.gd
Normal file
@@ -0,0 +1,82 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
# 远程玩家脚本
|
||||
# 负责处理位置同步和动画播放
|
||||
# 严格遵循 Visual Only 原则:无输入处理,无物理碰撞
|
||||
|
||||
# 公共属性 (snake_case)
|
||||
var user_id: String = ""
|
||||
var target_position: Vector2 = Vector2.ZERO
|
||||
|
||||
# 内部状态
|
||||
var last_direction: String = "down"
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var sprite: Sprite2D = $Sprite2D
|
||||
|
||||
func _ready():
|
||||
# 初始化时确保无物理处理
|
||||
set_physics_process(false)
|
||||
# 初始位置设为当前位置
|
||||
target_position = global_position
|
||||
|
||||
# 确保禁用物理碰撞 (双重保险)
|
||||
if has_node("CollisionShape2D"):
|
||||
$CollisionShape2D.disabled = true
|
||||
|
||||
func _process(delta: float):
|
||||
# 1. 平滑移动插值
|
||||
var current_pos = global_position
|
||||
var dist = current_pos.distance_to(target_position)
|
||||
|
||||
if dist > 1.0:
|
||||
# 简单的线性插值,速度系数 10.0 可根据需要调整
|
||||
var new_pos = current_pos.lerp(target_position, 10.0 * delta)
|
||||
|
||||
# 计算移动向量用于动画朝向
|
||||
var move_vec = new_pos - current_pos
|
||||
_update_animation(move_vec)
|
||||
|
||||
global_position = new_pos
|
||||
else:
|
||||
# 距离很近时直接吸附并播放待机动画
|
||||
global_position = target_position
|
||||
_play_idle_animation()
|
||||
|
||||
# 统一初始化方法
|
||||
# data: 包含 camelCase 字段的字典 (userId, username, position 等)
|
||||
func setup(data: Dictionary):
|
||||
if data.has("userId"):
|
||||
user_id = data.userId
|
||||
|
||||
if data.has("position"):
|
||||
var pos_data = data.position
|
||||
if pos_data.has("x") and pos_data.has("y"):
|
||||
var new_pos = Vector2(pos_data.x, pos_data.y)
|
||||
global_position = new_pos
|
||||
target_position = new_pos
|
||||
|
||||
# 更新目标位置
|
||||
func update_position(new_pos: Vector2):
|
||||
target_position = new_pos
|
||||
|
||||
func _update_animation(move_vec: Vector2):
|
||||
if not animation_player:
|
||||
return
|
||||
|
||||
# 确定主方向
|
||||
if abs(move_vec.x) > abs(move_vec.y):
|
||||
if move_vec.x > 0:
|
||||
last_direction = "right"
|
||||
else:
|
||||
last_direction = "left"
|
||||
else:
|
||||
if move_vec.y > 0:
|
||||
last_direction = "down"
|
||||
else:
|
||||
last_direction = "up"
|
||||
|
||||
animation_player.play("walk_" + last_direction)
|
||||
|
||||
func _play_idle_animation():
|
||||
if animation_player:
|
||||
animation_player.play("idle_" + last_direction)
|
||||
1
scenes/characters/RemotePlayer.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtbajfsljdht5
|
||||
64
scenes/characters/npc.tscn
Normal file
@@ -0,0 +1,64 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://npc2282a2new"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://brko2ik6t6ib5" path="res://assets/characters/npc_286_241.png" id="1_2r34a"]
|
||||
[ext_resource type="Script" uid="uid://dy3uf1rlu4h1u" path="res://scenes/characters/NPCController.gd" id="1_script"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_npc"]
|
||||
size = Vector2(48, 24)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2r34a"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle"]
|
||||
resource_name = "idle"
|
||||
length = 1.2
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.26666665, 0.4666667, 0.8, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [2, 1, 0, 4, 5]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_npc"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_2r34a"),
|
||||
&"idle": SubResource("Animation_idle")
|
||||
}
|
||||
|
||||
[node name="NPC" type="CharacterBody2D"]
|
||||
position = Vector2(-8, 0)
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_2r34a")
|
||||
hframes = 4
|
||||
vframes = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
light_mask = 5
|
||||
visibility_layer = 5
|
||||
shape = SubResource("RectangleShape2D_npc")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_npc")
|
||||
}
|
||||
1
scenes/characters/player.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://btka26hrcvgen
|
||||
179
scenes/characters/player.tscn
Normal file
@@ -0,0 +1,179 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://b2f8e24plwqgj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://fdswi18nel8n" path="res://scenes/characters/PlayerController.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://cghab1hkx5lg5" path="res://assets/characters/player_spritesheet.png" id="2_texture"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_1"]
|
||||
radius = 21.0
|
||||
height = 48.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_down"]
|
||||
resource_name = "idle_down"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_left"]
|
||||
resource_name = "idle_left"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [12]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_right"]
|
||||
resource_name = "idle_right"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [8]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_up"]
|
||||
resource_name = "idle_up"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_down"]
|
||||
resource_name = "walk_down"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_left"]
|
||||
resource_name = "walk_left"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [12, 13, 14, 15]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_right"]
|
||||
resource_name = "walk_right"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [8, 9, 10, 11]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_up"]
|
||||
resource_name = "walk_up"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [4, 5, 6, 7]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1"]
|
||||
_data = {
|
||||
&"idle_down": SubResource("Animation_idle_down"),
|
||||
&"idle_left": SubResource("Animation_idle_left"),
|
||||
&"idle_right": SubResource("Animation_idle_right"),
|
||||
&"idle_up": SubResource("Animation_idle_up"),
|
||||
&"walk_down": SubResource("Animation_walk_down"),
|
||||
&"walk_left": SubResource("Animation_walk_left"),
|
||||
&"walk_right": SubResource("Animation_walk_right"),
|
||||
&"walk_up": SubResource("Animation_walk_up")
|
||||
}
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(1.5000005, -24.5)
|
||||
texture = ExtResource("2_texture")
|
||||
hframes = 4
|
||||
vframes = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(2, -24)
|
||||
shape = SubResource("CapsuleShape2D_1")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_1")
|
||||
}
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
zoom = Vector2(2, 2)
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||
175
scenes/characters/remote_player.tscn
Normal file
@@ -0,0 +1,175 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://chb8mcqhfnkkr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dtbajfsljdht5" path="res://scenes/characters/RemotePlayer.gd" id="1_mu86i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cghab1hkx5lg5" path="res://assets/characters/player_spritesheet.png" id="2_7oc7u"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_1"]
|
||||
radius = 21.0
|
||||
height = 48.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_down"]
|
||||
resource_name = "idle_down"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_left"]
|
||||
resource_name = "idle_left"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [12]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_right"]
|
||||
resource_name = "idle_right"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [8]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_idle_up"]
|
||||
resource_name = "idle_up"
|
||||
length = 0.1
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [4]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_down"]
|
||||
resource_name = "walk_down"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_left"]
|
||||
resource_name = "walk_left"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [12, 13, 14, 15]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_right"]
|
||||
resource_name = "walk_right"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [8, 9, 10, 11]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_walk_up"]
|
||||
resource_name = "walk_up"
|
||||
length = 0.8
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [4, 5, 6, 7]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1"]
|
||||
_data = {
|
||||
&"idle_down": SubResource("Animation_idle_down"),
|
||||
&"idle_left": SubResource("Animation_idle_left"),
|
||||
&"idle_right": SubResource("Animation_idle_right"),
|
||||
&"idle_up": SubResource("Animation_idle_up"),
|
||||
&"walk_down": SubResource("Animation_walk_down"),
|
||||
&"walk_left": SubResource("Animation_walk_left"),
|
||||
&"walk_right": SubResource("Animation_walk_right"),
|
||||
&"walk_up": SubResource("Animation_walk_up")
|
||||
}
|
||||
|
||||
[node name="RemotePlayer" type="CharacterBody2D"]
|
||||
script = ExtResource("1_mu86i")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(1.5000005, -24.5)
|
||||
texture = ExtResource("2_7oc7u")
|
||||
hframes = 4
|
||||
vframes = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(2, -24)
|
||||
shape = SubResource("CapsuleShape2D_1")
|
||||
disabled = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_1")
|
||||
}
|
||||