Skip to content

Commit

Permalink
#2585 Brushline now is synced over properly using the new system.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Nov 6, 2024
1 parent 1a54fd1 commit 215d342
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
25 changes: 15 additions & 10 deletions resources/assets/js/custom/echo/message/messagefactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -23,23 +30,13 @@ 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);
break;
case NpcDeletedMessage.getName():
result = new NpcDeletedMessage(props);
break;

// Overpulled enemies
case OverpulledEnemyChangedMessage.getName():
result = new OverpulledEnemyChangedMessage(props);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ModelChangedHandler extends BaseModelHandler {
/**
*
* @param e
* @returns {{lat: Number, lng: Number, floor_id: Number}}
* @returns {MessageCoordinate|MessageCoordinate[]}
* @protected
*/
_getCorrectLatLngFromEvent(e) {
Expand Down

0 comments on commit 215d342

Please sign in to comment.