Skip to content

Commit 22ab650

Browse files
committed
Moved files, created new asmdefs, decoupled systems via messaging
1 parent ee7e376 commit 22ab650

File tree

390 files changed

+197
-24
lines changed

Some content is hidden

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

390 files changed

+197
-24
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: 16 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,11 @@ private bool OnWantToQuit()
126139
return canQuit;
127140
}
128141

129-
public void LeaveSession(bool UserRequested)
142+
private void LeaveSession(QuitGameSessionMessage msg)
130143
{
131144
m_LobbyServiceFacade.EndTracking();
132145

133-
if (UserRequested)
146+
if (msg.UserRequested)
134147
{
135148
// first disconnect then return to menu
136149
var gameNetPortal = GameNetPortal.Instance;
@@ -142,7 +155,7 @@ public void LeaveSession(bool UserRequested)
142155
SceneLoaderWrapper.Instance.LoadScene("MainMenu", useNetworkSceneManager: false);
143156
}
144157

145-
public void QuitGame()
158+
private void QuitGame(QuitApplicationMessage msg)
146159
{
147160
#if UNITY_EDITOR
148161
UnityEditor.EditorApplication.isPlaying = false;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "BossRoom.ApplicationLifecycle",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:ed77cc04b29ffca42860b1220217e140",
6+
"GUID:5ed68ed74b4874cce9e11f74a1f5e9ae",
7+
"GUID:ec2e12d3de28e40839f9a0b685184f49",
8+
"GUID:e3abc1ceb6eae4836a8ff106702e66e5",
9+
"GUID:1491147abca9d7d4bb7105af628b223e",
10+
"GUID:e9e5562f77c754b2ca364915385b3d43",
11+
"GUID:e0cd26848372d4e5c891c569017e11f1"
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/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/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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "BossRoom.ApplicationLifecycle.Messages"
3+
}

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

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": "BossRoom.Audio",
3+
"references":[ "GUID:ec2e12d3de28e40839f9a0b685184f49" ]
4+
}

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

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

@@ -156,12 +157,13 @@ private void OnDisconnectOrTimeout(ulong clientID)
156157
case ConnectStatus.UserRequestedDisconnect:
157158
case ConnectStatus.HostEndedSession:
158159
case ConnectStatus.ServerFull:
159-
m_ApplicationController.LeaveSession(false); // go through the normal leave flow
160+
161+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage(){UserRequested = false}); // go through the normal leave flow
160162
break;
161163
case ConnectStatus.LoggedInAgain:
162164
if (m_TryToReconnectCoroutine == null)
163165
{
164-
m_ApplicationController.LeaveSession(false); // if not trying to reconnect, go through the normal leave flow
166+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage(){UserRequested = false}); // if not trying to reconnect, go through the normal leave flow
165167
}
166168
break;
167169
case ConnectStatus.GenericDisconnect:
@@ -222,7 +224,7 @@ private IEnumerator TryToReconnect(string lobbyCode)
222224

223225
// If the coroutine has not been stopped before this, it means we failed to connect during all attempts
224226
Debug.Log("All tries failed, returning to main menu");
225-
m_ApplicationController.LeaveSession(false);
227+
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage(){UserRequested = false});
226228
if (!DisconnectReason.HasTransitionReason)
227229
{
228230
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": "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/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)