Skip to content

feat: structure refactor (1): asmdefs and folder changes [MTT-2623] #668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
  •  
  •  
  •  

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using BossRoom.Scripts.Shared.Net.UnityServices.Auth;
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
using Unity.Multiplayer.Samples.BossRoom.Client;
using Unity.Multiplayer.Samples.BossRoom.Server;
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
Expand All @@ -24,6 +25,7 @@ public class ApplicationController : MonoBehaviour

LocalLobby m_LocalLobby;
LobbyServiceFacade m_LobbyServiceFacade;
IDisposable m_Subscriptions;

[SerializeField] GameObject[] m_GameObjectsThatWillBeInjectedAutomatically;

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

//these message channels are essential and persist for the lifetime of the lobby and relay services
scope.BindMessageChannelInstance<QuitGameSessionMessage>();
scope.BindMessageChannelInstance<QuitApplicationMessage>();
scope.BindMessageChannelInstance<UnityServiceErrorMessage>();
scope.BindMessageChannelInstance<ConnectStatus>();
scope.BindMessageChannelInstance<DoorStateChangedEventMessage>();
Expand Down Expand Up @@ -82,6 +86,14 @@ private void Awake()
m_LocalLobby = scope.Resolve<LocalLobby>();
m_LobbyServiceFacade = scope.Resolve<LobbyServiceFacade>();

var quitGameSessionSub = scope.Resolve<ISubscriber<QuitGameSessionMessage>>();
var quitApplicationSub = scope.Resolve<ISubscriber<QuitApplicationMessage>>();

var subHandles = new DisposableGroup();
subHandles.Add(quitGameSessionSub.Subscribe(LeaveSession));
subHandles.Add(quitApplicationSub.Subscribe(QuitGame));
m_Subscriptions = subHandles;

Application.targetFrameRate = 120;
}

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

private void OnDestroy()
{
m_Subscriptions?.Dispose();
m_LobbyServiceFacade?.EndTracking();
DIScope.RootScope.Dispose();
DIScope.RootScope = null;
Expand Down Expand Up @@ -126,11 +139,12 @@ private bool OnWantToQuit()
return canQuit;
}

public void LeaveSession(bool UserRequested)
// TODO remove messaging for this once we have vcontainer.
private void LeaveSession(QuitGameSessionMessage msg)
{
m_LobbyServiceFacade.EndTracking();

if (UserRequested)
if (msg.UserRequested)
{
// first disconnect then return to menu
var gameNetPortal = GameNetPortal.Instance;
Expand All @@ -142,7 +156,7 @@ public void LeaveSession(bool UserRequested)
SceneLoaderWrapper.Instance.LoadScene("MainMenu", useNetworkSceneManager: false);
}

public void QuitGame()
private void QuitGame(QuitApplicationMessage msg)
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
Expand Down
8 changes: 8 additions & 0 deletions Assets/BossRoom/Scripts/ApplicationLifecycle/Messages.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System;

namespace Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages
{
public struct QuitApplicationMessage
{
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using UnityEngine;

namespace Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages
{
public struct QuitGameSessionMessage
{
public bool UserRequested;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Unity.BossRoom.ApplicationLifecycle.Messages"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Unity.BossRoom.ApplicationLifecycle",
"rootNamespace": "",
"references": [
"GUID:ed77cc04b29ffca42860b1220217e140",
"GUID:5ed68ed74b4874cce9e11f74a1f5e9ae",
"GUID:ec2e12d3de28e40839f9a0b685184f49",
"GUID:e3abc1ceb6eae4836a8ff106702e66e5",
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:e0cd26848372d4e5c891c569017e11f1",
"GUID:e9e5562f77c754b2ca364915385b3d43"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Assets/BossRoom/Scripts/Audio/Unity.BossRoom.Audio.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Unity.BossRoom.Audio",
"references":[ "GUID:ec2e12d3de28e40839f9a0b685184f49" ]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/BossRoom/Scripts/CameraController.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Unity.BossRoom.CameraController",
"rootNamespace": "",
"references": [
"GUID:4307f53044263cf4b835bd812fc161a4"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Unity.Multiplayer.Samples.BossRoom.Editor",
"name": "Unity.BossRoom.Editor",
"rootNamespace": "",
"references": [
"Unity.Netcode.Runtime",
"Unity.Multiplayer.Samples.BossRoom.Gameplay"
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:ed77cc04b29ffca42860b1220217e140"
],
"includePlatforms": [
"Editor"
Expand All @@ -16,4 +16,4 @@
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Threading.Tasks;
using Unity.Multiplayer.Samples.BossRoom.ApplicationLifecycle.Messages;
using Unity.Multiplayer.Samples.BossRoom.Shared;
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
Expand Down Expand Up @@ -30,20 +31,20 @@ public class ClientGameNetPortal : MonoBehaviour

Coroutine m_TryToReconnectCoroutine;

ApplicationController m_ApplicationController;
LobbyServiceFacade m_LobbyServiceFacade;
LocalLobby m_LocalLobby;
IPublisher<QuitGameSessionMessage> m_QuitGameSessionPub;
IPublisher<ConnectStatus> m_ConnectStatusPub;
IPublisher<ReconnectMessage> m_ReconnectMessagePub;

[Inject]
private void InjectDependencies(ApplicationController applicationController, LobbyServiceFacade lobbyServiceFacade,
LocalLobby localLobby, IPublisher<ConnectStatus> connectStatusPub, IPublisher<ReconnectMessage> reconnectMessagePub)
private void InjectDependencies(LobbyServiceFacade lobbyServiceFacade, LocalLobby localLobby, IPublisher<QuitGameSessionMessage> quitGameSessionPub, IPublisher<ConnectStatus> connectStatusPub, IPublisher<ReconnectMessage> reconnectMessagePub)
{
m_ApplicationController = applicationController;
m_QuitGameSessionPub = quitGameSessionPub;
m_LobbyServiceFacade = lobbyServiceFacade;
m_LocalLobby = localLobby;
m_ConnectStatusPub = connectStatusPub;

m_ReconnectMessagePub = reconnectMessagePub;
}

Expand Down Expand Up @@ -157,12 +158,13 @@ private void OnDisconnectOrTimeout(ulong clientID)
case ConnectStatus.HostEndedSession:
case ConnectStatus.ServerFull:
case ConnectStatus.IncompatibleBuildType:
m_ApplicationController.LeaveSession(false); // go through the normal leave flow

m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false }); // go through the normal leave flow
break;
case ConnectStatus.LoggedInAgain:
if (m_TryToReconnectCoroutine == null)
{
m_ApplicationController.LeaveSession(false); // if not trying to reconnect, go through the normal leave flow
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false }); // if not trying to reconnect, go through the normal leave flow
}
break;
case ConnectStatus.GenericDisconnect:
Expand Down Expand Up @@ -223,7 +225,7 @@ private IEnumerator TryToReconnect(string lobbyCode)

// If the coroutine has not been stopped before this, it means we failed to connect during all attempts
Debug.Log("All tries failed, returning to main menu");
m_ApplicationController.LeaveSession(false);
m_QuitGameSessionPub.Publish(new QuitGameSessionMessage() { UserRequested = false });
if (!DisconnectReason.HasTransitionReason)
{
DisconnectReason.SetDisconnectReason(ConnectStatus.GenericDisconnect);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Unity.BossRoom.DebugCheats",
"rootNamespace": "",
"references": [
"GUID:1491147abca9d7d4bb7105af628b223e",
"GUID:ec2e12d3de28e40839f9a0b685184f49",
"GUID:ed77cc04b29ffca42860b1220217e140",
"GUID:e9e5562f77c754b2ca364915385b3d43"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading