feat: adding the skin_shader_generator, and gacha base barebone
This commit is contained in:
@@ -20,6 +20,7 @@ signal avatar_changed(url: String)
|
||||
var profile: Dictionary = {}
|
||||
var stats: Dictionary = {}
|
||||
var wallet: Dictionary = {"gold": 0, "star": 0}
|
||||
var fragments: Dictionary = {} # frag_common, frag_uncommon, frag_rare
|
||||
var inventory: Array = []
|
||||
var loadout: Dictionary = {"head": "", "costume": "", "glove": "", "accessory": ""}
|
||||
var shop_catalog: Dictionary = {}
|
||||
@@ -51,6 +52,7 @@ func _on_auth_completed(success: bool, _user_data: Dictionary) -> void:
|
||||
func _on_logged_out() -> void:
|
||||
profile = {}
|
||||
stats = {}
|
||||
fragments = {}
|
||||
is_profile_loaded = false
|
||||
|
||||
# =============================================================================
|
||||
@@ -62,6 +64,7 @@ func load_profile() -> Dictionary:
|
||||
profile = {}
|
||||
stats = {}
|
||||
wallet = {"gold": 0, "star": 0}
|
||||
fragments = {}
|
||||
inventory = []
|
||||
is_profile_loaded = false
|
||||
|
||||
@@ -116,6 +119,15 @@ func load_profile() -> Dictionary:
|
||||
# Load stats
|
||||
await load_stats()
|
||||
|
||||
# Load fragments from storage
|
||||
var frag_result = await NakamaManager.client.read_storage_objects_async(
|
||||
NakamaManager.session,
|
||||
[NakamaStorageObjectId.new(PROFILE_COLLECTION, "fragments", account.user.id)]
|
||||
)
|
||||
if not frag_result.is_exception() and frag_result.objects.size() > 0:
|
||||
var fdata = JSON.parse_string(frag_result.objects[0].value)
|
||||
if fdata is Dictionary: fragments = fdata
|
||||
|
||||
is_profile_loaded = true
|
||||
emit_signal("profile_loaded", profile)
|
||||
print("[UserProfileManager] Profile loaded: ", profile.get("display_name", "Unknown"))
|
||||
@@ -391,6 +403,14 @@ func _reload_wallet() -> void:
|
||||
wallet["star"] = w_data.get("star", 0)
|
||||
emit_signal("profile_updated")
|
||||
|
||||
func save_wallet() -> void:
|
||||
"""Persist wallet deductions and fragment counts to Nakama storage."""
|
||||
if not NakamaManager.session: return
|
||||
var write_objs: Array = [
|
||||
NakamaWriteStorageObject.new(PROFILE_COLLECTION, "fragments", 1, 1, JSON.stringify(fragments), "")
|
||||
]
|
||||
await NakamaManager.client.write_storage_objects_async(NakamaManager.session, write_objs)
|
||||
|
||||
# =============================================================================
|
||||
# Stats Management
|
||||
# =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user