Closed f8122dac91 closed 1 year ago
Had to work around the lack of serialization/deserialization mechanism for PackedScene
by using PackedScene._bundled: Dictionary
.
Serialization: use var_to_bytes_with_objects()
with PackedScene._bundled
dictionary
Deserialization: initialize an empty PackedScene
instance and assign the result of bytes_to_var_with_objects()
to its _bundled
property.
https://github.com/igneous-labs/telegram-space/pull/22#issuecomment-1422349273
details for the implementation
Realized that world has to have the concept of (world) instance in order for multiple levels to exists. Currently, neither player state nor world state have any information about which level a player is in.
We can introduce Instance
that identifies an instance of world and has associated level (identified by level_id
) and add instance_id
to player state data.
Conceptually, Instance
is just a shallow association from a group of players to a level, and with this we can logically separate level (data, i.e. blueprint of world) and world (an instance).
We can introduce
Instance
that identifies an instance of world and has associated level (identified bylevel_id
) and addinstance_id
to player state data.
Ended up implementing it with a different approach (in 2fdcb747ba815e940812f53ec686734408f7a80c):
HashMap<ClientId, PlayerStateData>
Instance
keeps some metadata (last_updated_at
and last_synced_at
) to facilitate syncing behaviorWorldState
is the collection of all Instance
sWorldState
has client_instance: HashMap<ClientId, InstanceId>
used to resolve a given client_id
to current instance_id
PlayerStateData
is left alone and does not contain information about instanceThe reasoning behind the implementation is that partitioning the whole world_state
into each instance has to be performed every single time the server needs to sync instances, and this is way too expensive to perform at sync time which is close to the frame rate.
To tackle #6 and eventually #14, we need to come up with a level syncing mechanism.
For now we can just use godot's native resource format (
.tres
for text.res
for binary) as a testbed.This issue should implement:
RequestLevel
(client -> server) andLevelData
(server -> client) message in protocolPlayerInstance
(client -> server) andPlayerInstanceAcknowledge
(server -> client) message in protocolLevelService
to serve levelsPackedScene
LevelDataManager
singleton_ready()
)