-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2585 WIP fixing/upgrading live route synchronization
- Loading branch information
Showing
22 changed files
with
235 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
17 changes: 0 additions & 17 deletions
17
resources/assets/js/custom/echo/messagehandler/listen/killzone/changed.js
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
resources/assets/js/custom/echo/messagehandler/listen/killzone/deleted.js
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class BaseModelHandler extends MessageHandler { | ||
|
||
/** | ||
* @protected | ||
* | ||
* @param echo {Echo} | ||
* @param message {String} | ||
*/ | ||
constructor(echo, message) { | ||
super(echo, message); | ||
} | ||
|
||
/** | ||
* Basic checks for if a received echo event is applicable to this model handler. | ||
* | ||
* @param e {Object} | ||
* @returns {boolean} | ||
* @protected | ||
*/ | ||
_shouldHandleEchoEvent(e) { | ||
console.assert(this instanceof BaseModelHandler, 'this is not a BaseModelHandler', this); | ||
|
||
// Do not process events that WE fired | ||
return e.user.public_key !== getState().getUser().public_key; | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @param e | ||
* @return boolean | ||
*/ | ||
onReceive(e) { | ||
super.onReceive(e); | ||
|
||
return this._shouldHandleChangedEchoEvent(e); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class KillZoneChangedHandler extends ModelChangedHandler { | ||
|
||
constructor(echo) { | ||
super(echo, KillZoneChangedMessage.getName()); | ||
|
||
} | ||
|
||
|
||
/** | ||
* | ||
* @param e {KillZoneChangedMessage} | ||
* @return boolean | ||
*/ | ||
onReceive(e) { | ||
let shouldHandle = super.onReceive(e); | ||
|
||
console.log(`KillZoneChangedHandler::onReceive:`, shouldHandle, e); | ||
if (shouldHandle) { | ||
let killZoneMapObjectGroup = this.echo.map.mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE); | ||
|
||
let mapObject = killZoneMapObjectGroup.loadMapObject(e.model, null, e.user); | ||
killZoneMapObjectGroup.setMapObjectVisibility(mapObject, true); | ||
} | ||
|
||
return shouldHandle; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class KillZoneDeletedHandler extends ModelDeletedHandler { | ||
|
||
constructor(echo) { | ||
super(echo, KillZoneDeletedMessage.getName()); | ||
} | ||
|
||
/** | ||
* | ||
* @param e {KillZoneDeletedMessage} | ||
*/ | ||
onReceive(e) { | ||
let shouldHandle = super.onReceive(e); | ||
|
||
console.log(`KillZoneDeletedHandler::onReceive: ${e.model_id} ${e.model_class}`); | ||
|
||
if (shouldHandle) { | ||
|
||
let killZoneMapObjectGroup = this.echo.map.mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE); | ||
|
||
let mapObject = killZoneMapObjectGroup.findMapObjectById(e.model_id); | ||
if (mapObject !== null) { | ||
mapObject.localDelete(); | ||
this._showDeletedFromEcho(mapObject, e.user); | ||
} | ||
} | ||
|
||
return shouldHandle; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class ModelChangedHandler extends BaseModelHandler { | ||
/** | ||
* Checks if a received _changed_ event is applicable to this map object group. | ||
* | ||
* @param e {Object} | ||
* @returns {boolean} | ||
* @private | ||
*/ | ||
_shouldHandleChangedEchoEvent(e) { | ||
console.assert(this instanceof ModelChangedHandler, 'this is not a ModelChangedHandler', this); | ||
console.assert(typeof e.model !== 'undefined', 'model was not defined in received event!', this, e); | ||
console.assert(typeof e.model.floor_id !== 'undefined', 'model.floor_id was not defined in received event!', this, e); | ||
|
||
// floor -1 means it's omnipresent (such as killzones) | ||
// @TODO support facades? | ||
return this._shouldHandleEchoEvent(e) && (e.model.floor_id === getState().getCurrentFloor().id || e.model.floor_id === -1); | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @param e {KillZoneChangedMessage} | ||
* @return boolean | ||
*/ | ||
onReceive(e) { | ||
super.onReceive(e); | ||
|
||
return this._shouldHandleChangedEchoEvent(e); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class ModelDeletedHandler extends BaseModelHandler { | ||
|
||
/** | ||
* Checks if a received _deleted_ event is applicable to this map object group. | ||
* | ||
* @param e {Object} | ||
* @returns {boolean} | ||
* @private | ||
*/ | ||
_shouldHandleDeletedEchoEvent(e) { | ||
console.assert(this instanceof ModelDeletedHandler, 'this is not a ModelDeletedHandler', this); | ||
console.assert(typeof e.model_id !== 'undefined', 'model_id was not defined in received event!', this, e); | ||
|
||
return this._shouldHandleEchoEvent(e); | ||
} | ||
|
||
/** | ||
* | ||
* @param localMapObject {MapObject} | ||
* @param user {Object} | ||
* @protected | ||
*/ | ||
_showDeletedFromEcho(localMapObject, user) { | ||
console.assert(this instanceof ModelDeletedHandler, 'this is not a ModelDeletedHandler', this); | ||
|
||
let state = getState(); | ||
if (state.isEchoEnabled() && state.getUser().public_key !== user.public_key && user.name !== null) { | ||
showInfoNotification(lang.get('messages.echo_object_deleted_notification') | ||
.replace('{object}', localMapObject.toString()) | ||
.replace('{user}', user.name)); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param e {KillZoneDeletedMessage} | ||
* @return boolean | ||
*/ | ||
onReceive(e) { | ||
super.onReceive(e); | ||
|
||
return this._shouldHandleDeletedEchoEvent(e); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
resources/assets/js/custom/echo/messagehandler/listen/npc/changed.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
resources/assets/js/custom/echo/messagehandler/listen/npc/deleted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.