Skip to content

Commit cba5bdf

Browse files
feat: structure refactor (1): asmdefs and folder changes [MTT-2623] (#668)
* Moved files, created new asmdefs, decoupled systems via messaging * switched all asmdefs to use GUIDs for better durability when refactoring * simplified very long asmdef names * code standards pass * code standards # * uniform Unity.BossRoom._ naming for asmdefs * folder rearrangement and rename * Update Assets/BossRoom/Scripts/ApplicationLifecycle/ApplicationController.cs Co-authored-by: Sam Bellomo <71790295+SamuelBellomo@users.noreply.github.com>
1 parent 3c9f73d commit cba5bdf

408 files changed

Lines changed: 271 additions & 67 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/BossRoom/Scripts/Game/Client/Game.meta renamed to Assets/BossRoom/Scripts/ApplicationLifecycle.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/BossRoom/Scripts/Game/ApplicationController.cs renamed to Assets/BossRoom/Scripts/ApplicationLifecycle/ApplicationController.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using BossRoom.Scripts.Shared.Net.UnityServices.Auth;
4+
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
45
using Unity.Multiplayer.Samples.BossRoom.Client;
56
using Unity.Multiplayer.Samples.BossRoom.Server;
67
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
@@ -24,6 +25,7 @@ public class ApplicationController : MonoBehaviour
2425

2526
LocalLobby m_LocalLobby;
2627
LobbyServiceFacade m_LobbyServiceFacade;
28+
IDisposable m_Subscriptions;
2729

2830
[SerializeField] GameObject[] m_GameObjectsThatWillBeInjectedAutomatically;
2931

@@ -50,6 +52,8 @@ private void Awake()
5052
scope.BindAsSingle<ProfileManager>();
5153

5254
//these message channels are essential and persist for the lifetime of the lobby and relay services
55+
scope.BindMessageChannelInstance<QuitGameSessionMessage>();
56+
scope.BindMessageChannelInstance<QuitApplicationMessage>();
5357
scope.BindMessageChannelInstance<UnityServiceErrorMessage>();
5458
scope.BindMessageChannelInstance<ConnectStatus>();
5559
scope.BindMessageChannelInstance<DoorStateChangedEventMessage>();
@@ -82,6 +86,14 @@ private void Awake()
8286
m_LocalLobby = scope.Resolve<LocalLobby>();
8387
m_LobbyServiceFacade = scope.Resolve<LobbyServiceFacade>();
8488

89+
var quitGameSessionSub = scope.Resolve<ISubscriber<QuitGameSessionMessage>>();
90+
var quitApplicationSub = scope.Resolve<ISubscriber<QuitApplicationMessage>>();
91+
92+
var subHandles = new DisposableGroup();
93+
subHandles.Add(quitGameSessionSub.Subscribe(LeaveSession));
94+
subHandles.Add(quitApplicationSub.Subscribe(QuitGame));
95+
m_Subscriptions = subHandles;
96+
8597
Application.targetFrameRate = 120;
8698
}
8799

@@ -92,6 +104,7 @@ private void Start()
92104

93105
private void OnDestroy()
94106
{
107+
m_Subscriptions?.Dispose();
95108
m_LobbyServiceFacade?.EndTracking();
96109
DIScope.RootScope.Dispose();
97110
DIScope.RootScope = null;
@@ -126,11 +139,12 @@ private bool OnWantToQuit()
126139
return canQuit;
127140
}
128141

129-
public void LeaveSession(bool UserRequested)
142+
// TODO remove messaging for this once we have vcontainer.
143+
private void LeaveSession(QuitGameSessionMessage msg)
130144
{
131145
m_LobbyServiceFacade.EndTracking();
132146

133-
if (UserRequested)
147+
if (msg.UserRequested)
134148
{
135149
// first disconnect then return to menu
136150
var gameNetPortal = GameNetPortal.Instance;
@@ -142,7 +156,7 @@ public void LeaveSession(bool UserRequested)
142156
SceneLoaderWrapper.Instance.LoadScene("MainMenu", useNetworkSceneManager: false);
143157
}
144158

145-
public void QuitGame()
159+
private void QuitGame(QuitApplicationMessage msg)
146160
{
147161
#if UNITY_EDITOR
148162
UnityEditor.EditorApplication.isPlaying = false;

Assets/BossRoom/Scripts/Game/ApplicationController.cs.meta renamed to Assets/BossRoom/Scripts/ApplicationLifecycle/ApplicationController.cs.meta

File renamed without changes.

Assets/BossRoom/Scripts/ApplicationLifecycle/Messages.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages
4+
{
5+
public struct QuitApplicationMessage
6+
{
7+
}
8+
}

Assets/BossRoom/Scripts/ApplicationLifecycle/Messages/QuitApplicationMessage.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using UnityEngine;
2+
3+
namespace Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages
4+
{
5+
public struct QuitGameSessionMessage
6+
{
7+
public bool UserRequested;
8+
}
9+
}

Assets/BossRoom/Scripts/ApplicationLifecycle/Messages/QuitGameSessionMessage.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Unity.BossRoom.ApplicationLifecycle.Messages"
3+
}

Assets/BossRoom/Scripts/ApplicationLifecycle/Messages/Unity.BossRoom.ApplicationLifecycle.Messages.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)