| | 1 | | using DCL; |
| | 2 | | using Sentry; |
| | 3 | | using System; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | namespace DCLPlugins.SentryPlugin |
| | 7 | | { |
| | 8 | | public class SentryController : IDisposable |
| | 9 | | { |
| | 10 | | private readonly DataStore_Player playerStore; |
| | 11 | | private readonly DataStore_Realm realmStore; |
| | 12 | | private readonly IHub sentryHub; |
| | 13 | |
|
| 0 | 14 | | public SentryController(DataStore_Player playerStore, DataStore_Realm realmStore, IHub sentryHub) |
| | 15 | | { |
| 0 | 16 | | this.playerStore = playerStore; |
| 0 | 17 | | this.realmStore = realmStore; |
| 0 | 18 | | this.sentryHub = sentryHub; |
| | 19 | |
|
| 0 | 20 | | this.playerStore.playerGridPosition.OnChange += PlayerGridPositionOnOnChange; |
| 0 | 21 | | this.playerStore.otherPlayers.OnAdded += OtherPlayersOnChanged; |
| 0 | 22 | | this.playerStore.otherPlayers.OnRemoved += OtherPlayersOnChanged; |
| 0 | 23 | | this.playerStore.lastTeleportPosition.OnChange += LastTeleportPositionOnOnChange; |
| 0 | 24 | | this.realmStore.realmName.OnChange += RealmNameOnOnChange; |
| 0 | 25 | | } |
| | 26 | |
|
| | 27 | | private void RealmNameOnOnChange(string current, string previous) |
| | 28 | | { |
| 0 | 29 | | sentryHub.ConfigureScope(scope => |
| | 30 | | { |
| 0 | 31 | | scope.SetTag("Current Realm", current); |
| 0 | 32 | | scope.SetTag("Previous Realm", previous); |
| 0 | 33 | | }); |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | private void LastTeleportPositionOnOnChange(Vector3 current, Vector3 previous) |
| | 37 | | { |
| 0 | 38 | | sentryHub.ConfigureScope(scope => |
| | 39 | | { |
| 0 | 40 | | scope.Contexts["Current Teleport Position"] = $"{current.x},{current.y}"; |
| 0 | 41 | | scope.Contexts["Last Teleport Position"] = $"{previous.x},{previous.y}"; |
| 0 | 42 | | }); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | private void OtherPlayersOnChanged(string _, Player __) |
| | 46 | | { |
| 0 | 47 | | sentryHub.ConfigureScope(scope => { scope.Contexts["Total Other Players"] = $"{playerStore.otherPlayers.Coun |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | private void PlayerGridPositionOnOnChange(Vector2Int current, Vector2Int previous) |
| | 51 | | { |
| 0 | 52 | | sentryHub.ConfigureScope(scope => |
| | 53 | | { |
| 0 | 54 | | scope.SetTag("Current Position", $"{current.x},{current.y}"); |
| 0 | 55 | | scope.SetTag("Previous Position", $"{previous.x},{previous.y}"); |
| 0 | 56 | | }); |
| 0 | 57 | | } |
| | 58 | |
|
| | 59 | | public void Dispose() |
| | 60 | | { |
| 0 | 61 | | playerStore.playerGridPosition.OnChange -= PlayerGridPositionOnOnChange; |
| 0 | 62 | | playerStore.otherPlayers.OnAdded -= OtherPlayersOnChanged; |
| 0 | 63 | | playerStore.otherPlayers.OnRemoved -= OtherPlayersOnChanged; |
| 0 | 64 | | playerStore.lastTeleportPosition.OnChange -= LastTeleportPositionOnOnChange; |
| 0 | 65 | | realmStore.realmName.OnChange -= RealmNameOnOnChange; |
| 0 | 66 | | } |
| | 67 | | } |
| | 68 | | } |