Enhance school creation and map management features by updating the API to support mod packs and map layouts. Introduce a new map snapshot protocol for efficient data handling during school sessions. Revise documentation to reflect these changes, including updates to the protocol and architecture documents. Improve UI components for mod selection and map editing, ensuring a better user experience. Update tests to validate new functionalities and ensure robustness.
This commit is contained in:
@@ -276,6 +276,7 @@ internal sealed class SchoolWorker
|
||||
{
|
||||
case WorkerCommand.Open open:
|
||||
open.Client.OpenSchoolId = _id;
|
||||
SendMapSnapshot(open.Client, school);
|
||||
BroadcastClockTo(open.Client, school);
|
||||
break;
|
||||
|
||||
@@ -364,6 +365,33 @@ internal sealed class SchoolWorker
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMapSnapshot(GameClient client, School school)
|
||||
{
|
||||
if (school.Catalog is null || school.Map is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var locale = ProtocolConstants.CatalogLocale(client.Locale);
|
||||
var view = MapView.Build(school.Catalog, school.Map, locale);
|
||||
var nodes = new MapSnapshotNode[view.Count];
|
||||
for (var i = 0; i < view.Count; i++)
|
||||
{
|
||||
var node = view[i];
|
||||
nodes[i] = new MapSnapshotNode(
|
||||
(byte)node.Kind,
|
||||
node.Id,
|
||||
node.ParentId,
|
||||
node.Name,
|
||||
node.Items,
|
||||
node.Positions);
|
||||
}
|
||||
|
||||
var frame = new byte[ProtocolConstants.MaxMessageSize];
|
||||
var length = ProtocolCodec.WriteMapSnapshot(frame, new ServerMapSnapshotMessage(school.Id, nodes));
|
||||
client.TrySendReliable(frame.AsMemory(0, length));
|
||||
}
|
||||
|
||||
private static void BroadcastClockTo(GameClient client, School school)
|
||||
{
|
||||
var frame = new byte[ProtocolCodec.MaxFrameSize];
|
||||
|
||||
Reference in New Issue
Block a user