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 <[email protected]>
1 parent 3c9f73d commit cba5bdf

File tree

408 files changed

+271
-67
lines changed

Some content is hidden

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

408 files changed

+271
-67
lines changed

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/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.
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.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Unity.BossRoom.ApplicationLifecycle",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:ed77cc04b29ffca42860b1220217e140",
6+
"GUID:5ed68ed74b4874cce9e11f74a1f5e9ae",
7+
"GUID:ec2e12d3de28e40839f9a0b685184f49",
8+
"GUID:e3abc1ceb6eae4836a8ff106702e66e5",
9+
"GUID:1491147abca9d7d4bb7105af628b223e",
10+
"GUID:e0cd26848372d4e5c891c569017e11f1",
11+
"GUID:e9e5562f77c754b2ca364915385b3d43"
12+
],
13+
"includePlatforms": [],
14+
"excludePlatforms": [],
15+
"allowUnsafeCode": false,
16+
"overrideReferences": false,
17+
"precompiledReferences": [],
18+
"autoReferenced": true,
19+
"defineConstraints": [],
20+
"versionDefines": [],
21+
"noEngineReferences": false
22+
}

Assets/BossRoom/Scripts/ApplicationLifecycle/Unity.BossRoom.ApplicationLifecycle.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.

Assets/BossRoom/Scripts/Game/Client/Audio.meta renamed to Assets/BossRoom/Scripts/Audio.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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Unity.BossRoom.Audio",
3+
"references":[ "GUID:ec2e12d3de28e40839f9a0b685184f49" ]
4+
}

Assets/BossRoom/Scripts/Audio/Unity.BossRoom.Audio.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.

Assets/BossRoom/Scripts/CameraController.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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Unity.BossRoom.CameraController",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:4307f53044263cf4b835bd812fc161a4"
6+
],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

Assets/BossRoom/Scripts/CameraController/Unity.BossRoom.CameraController.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.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "Unity.Multiplayer.Samples.BossRoom.Editor",
2+
"name": "Unity.BossRoom.Editor",
33
"rootNamespace": "",
44
"references": [
5-
"Unity.Netcode.Runtime",
6-
"Unity.Multiplayer.Samples.BossRoom.Gameplay"
5+
"GUID:1491147abca9d7d4bb7105af628b223e",
6+
"GUID:ed77cc04b29ffca42860b1220217e140"
77
],
88
"includePlatforms": [
99
"Editor"
@@ -16,4 +16,4 @@
1616
"defineConstraints": [],
1717
"versionDefines": [],
1818
"noEngineReferences": false
19-
}
19+
}

Assets/BossRoom/Scripts/Game/com.unity.multiplayer.samples.bossroom.gameplay.asmdef

Lines changed: 0 additions & 29 deletions
This file was deleted.

Assets/BossRoom/Scripts/Gameplay/Client/Audio-ReplaceWithMessaging.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.

Assets/BossRoom/Scripts/Game/ConnectionManagement/ClientGameNetPortal.cs renamed to Assets/BossRoom/Scripts/Gameplay/ConnectionManagement/ClientGameNetPortal.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Threading.Tasks;
4+
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
45
using Unity.Multiplayer.Samples.BossRoom.Shared;
56
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
67
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
@@ -30,20 +31,20 @@ public class ClientGameNetPortal : MonoBehaviour
3031

3132
Coroutine m_TryToReconnectCoroutine;
3233

33-
ApplicationController m_ApplicationController;
3434
LobbyServiceFacade m_LobbyServiceFacade;
3535
LocalLobby m_LocalLobby;
36+
IPublisher<QuitGameSessionMessage> m_QuitGameSessionPub;
3637
IPublisher<ConnectStatus> m_ConnectStatusPub;
3738
IPublisher<ReconnectMessage> m_ReconnectMessagePub;
3839

3940
[Inject]
40-
private void InjectDependencies(ApplicationController applicationController, LobbyServiceFacade lobbyServiceFacade,
41-
LocalLobby localLobby, IPublisher<ConnectStatus> connectStatusPub, IPublisher<ReconnectMessage> reconnectMessagePub)
41+
private void InjectDependencies(LobbyServiceFacade lobbyServiceFacade, LocalLobby localLobby, IPublisher<QuitGameSessionMessage> quitGameSessionPub, IPublisher<ConnectStatus> connectStatusPub, IPublisher<ReconnectMessage> reconnectMessagePub)
4242
{
43-
m_ApplicationController = applicationController;
43+
m_QuitGameSessionPub = quitGameSessionPub;
4444
m_LobbyServiceFacade = lobbyServiceFacade;
4545
m_LocalLobby = localLobby;
4646
m_ConnectStatusPub = connectStatusPub;
47+
4748
m_ReconnectMessagePub = reconnectMessagePub;
4849
}
4950

@@ -157,12 +158,13 @@ private void OnDisconnectOrTimeout(ulong clientID)
157158
case ConnectStatus.HostEndedSession:
158159
case ConnectStatus.ServerFull:
159160
case ConnectStatus.IncompatibleBuildType:
160-
m_ApplicationController.LeaveSession(false); // go through the normal leave flow
161+
162+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false }); // go through the normal leave flow
161163
break;
162164
case ConnectStatus.LoggedInAgain:
163165
if (m_TryToReconnectCoroutine == null)
164166
{
165-
m_ApplicationController.LeaveSession(false); // if not trying to reconnect, go through the normal leave flow
167+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false }); // if not trying to reconnect, go through the normal leave flow
166168
}
167169
break;
168170
case ConnectStatus.GenericDisconnect:
@@ -223,7 +225,7 @@ private IEnumerator TryToReconnect(string lobbyCode)
223225

224226
// If the coroutine has not been stopped before this, it means we failed to connect during all attempts
225227
Debug.Log("All tries failed, returning to main menu");
226-
m_ApplicationController.LeaveSession(false);
228+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false });
227229
if (!DisconnectReason.HasTransitionReason)
228230
{
229231
DisconnectReason.SetDisconnectReason(ConnectStatus.GenericDisconnect);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Unity.BossRoom.DebugCheats",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:1491147abca9d7d4bb7105af628b223e",
6+
"GUID:ec2e12d3de28e40839f9a0b685184f49",
7+
"GUID:ed77cc04b29ffca42860b1220217e140",
8+
"GUID:e9e5562f77c754b2ca364915385b3d43"
9+
],
10+
"includePlatforms": [],
11+
"excludePlatforms": [],
12+
"allowUnsafeCode": false,
13+
"overrideReferences": false,
14+
"precompiledReferences": [],
15+
"autoReferenced": true,
16+
"defineConstraints": [],
17+
"versionDefines": [],
18+
"noEngineReferences": false
19+
}

Assets/BossRoom/Scripts/Gameplay/DebugCheats/Unity.BossRoom.DebugCheats.asmdef.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.

0 commit comments

Comments
 (0)