From 215d342d97bfd20c571ee3fa9e4bae8708c576ce Mon Sep 17 00:00:00 2001 From: Wotuu Date: Wed, 6 Nov 2024 17:08:05 +0100 Subject: [PATCH] #2585 Brushline now is synced over properly using the new system. --- .../js/custom/echo/message/messagefactory.js | 25 +++++++++++-------- .../listen/models/brushline/changed.js | 18 +++++++------ .../listen/models/modelchangedhandler.js | 2 +- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/resources/assets/js/custom/echo/message/messagefactory.js b/resources/assets/js/custom/echo/message/messagefactory.js index 4dfbf8997..cce8446fc 100644 --- a/resources/assets/js/custom/echo/message/messagefactory.js +++ b/resources/assets/js/custom/echo/message/messagefactory.js @@ -9,6 +9,13 @@ class MessageFactory { create(name, props) { let result = null; switch (name) { + // Brushline + case BrushlineChangedMessage.getName(): + result = new BrushlineChangedMessage(props); + break; + case BrushlineDeletedMessage.getName(): + result = new BrushlineDeletedMessage(props); + break; // KillZone case KillZoneChangedMessage.getName(): result = new KillZoneChangedMessage(props); @@ -23,15 +30,6 @@ class MessageFactory { case MapIconDeletedMessage.getName(): result = new MapIconDeletedMessage(props); break; - - // LiveSession - case LiveSessionInviteMessage.getName(): - result = new LiveSessionInviteMessage(props); - break; - case LiveSessionStopMessage.getName(): - result = new LiveSessionStopMessage(props); - break; - // Npc case NpcChangedMessage.getName(): result = new NpcChangedMessage(props); @@ -39,7 +37,6 @@ class MessageFactory { case NpcDeletedMessage.getName(): result = new NpcDeletedMessage(props); break; - // Overpulled enemies case OverpulledEnemyChangedMessage.getName(): result = new OverpulledEnemyChangedMessage(props); @@ -48,6 +45,14 @@ class MessageFactory { result = new OverpulledEnemyDeletedMessage(props); break; + // LiveSession + case LiveSessionInviteMessage.getName(): + result = new LiveSessionInviteMessage(props); + break; + case LiveSessionStopMessage.getName(): + result = new LiveSessionStopMessage(props); + break; + // Whisper case MousePositionMessage.getName(): result = new MousePositionMessage(props); diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/brushline/changed.js b/resources/assets/js/custom/echo/messagehandler/listen/models/brushline/changed.js index 7ad338f85..32f6175b1 100644 --- a/resources/assets/js/custom/echo/messagehandler/listen/models/brushline/changed.js +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/brushline/changed.js @@ -16,13 +16,17 @@ class BrushlineChangedHandler extends ModelChangedHandler { if (shouldHandle) { let brushlineMapObjectGroup = this.echo.map.mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_BRUSHLINE); - // // Apply the correct coordinates for our choice of facade - // let coordinates = this._getCorrectLatLngFromEvent(e); - // - // e.model = $.extend({}, e.model, coordinates); - // - // let mapObject = brushlineMapObjectGroup.loadMapObject(e.model, null, e.user); - // brushlineMapObjectGroup.setMapObjectVisibility(mapObject, mapObject.shouldBeVisible()); + // Apply the correct coordinates for our choice of facade + /** @type {MessageCoordinate[]} */ + let coordinates = this._getCorrectLatLngFromEvent(e); + + if (coordinates.length > 0) { + e.model.floor_id = coordinates[0].floor_id; + } + e.model.polyline.vertices_json = JSON.stringify(coordinates); + + let mapObject = brushlineMapObjectGroup.loadMapObject(e.model, null, e.user); + brushlineMapObjectGroup.setMapObjectVisibility(mapObject, mapObject.shouldBeVisible()); } return shouldHandle; diff --git a/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js b/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js index 7e64aff23..89de5e03c 100644 --- a/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js +++ b/resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js @@ -37,7 +37,7 @@ class ModelChangedHandler extends BaseModelHandler { /** * * @param e - * @returns {{lat: Number, lng: Number, floor_id: Number}} + * @returns {MessageCoordinate|MessageCoordinate[]} * @protected */ _getCorrectLatLngFromEvent(e) {