Skip to content

Commit a6bb11d

Browse files
committed
Merge branch 'develop' into fix/sub-unsub-resub-msg-channels
2 parents 02e2bc6 + fc7436b commit a6bb11d

File tree

71 files changed

+525
-913
lines changed

Some content is hidden

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

71 files changed

+525
-913
lines changed

Assets/Prefabs/State/BossRoomState.prefab

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Transform:
2929
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
3030
m_LocalPosition: {x: 0, y: 0, z: 0}
3131
m_LocalScale: {x: 1, y: 1, z: 1}
32+
m_ConstrainProportionsScale: 0
3233
m_Children:
3334
- {fileID: 6319832178442273571}
3435
- {fileID: 374135395555381814}
@@ -53,7 +54,10 @@ MonoBehaviour:
5354
m_Script: {fileID: 11500000, guid: 5e631ac38df479741af592cf6a1fb553, type: 3}
5455
m_Name:
5556
m_EditorClassIdentifier:
56-
m_GameObjectsThatWillBeInjectedAutomatically: []
57+
parentReference:
58+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
59+
autoRun: 1
60+
autoInjectGameObjects: []
5761
--- !u!114 &3608714310874968837
5862
MonoBehaviour:
5963
m_ObjectHideFlags: 0
@@ -82,7 +86,10 @@ MonoBehaviour:
8286
m_Script: {fileID: 11500000, guid: 927521835ae055247b17e4abe805b4ab, type: 3}
8387
m_Name:
8488
m_EditorClassIdentifier:
85-
m_GameObjectsThatWillBeInjectedAutomatically: []
89+
parentReference:
90+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
91+
autoRun: 1
92+
autoInjectGameObjects: []
8693
m_NetworkGameStateTransform: {fileID: 11400000, guid: 07bddcdf06738e74cb79d30065ff96af, type: 2}
8794
m_PlayerPrefab: {fileID: 6009713983291384767, guid: 8237adf32a9b6de4892e6febe6b4bdef, type: 3}
8895
m_PlayerSpawnPoints:
@@ -120,6 +127,7 @@ Transform:
120127
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
121128
m_LocalPosition: {x: -1, y: 0, z: 2}
122129
m_LocalScale: {x: 1, y: 1, z: 1}
130+
m_ConstrainProportionsScale: 0
123131
m_Children: []
124132
m_Father: {fileID: 5655447013084909147}
125133
m_RootOrder: 4
@@ -150,6 +158,7 @@ Transform:
150158
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
151159
m_LocalPosition: {x: 8, y: 0, z: 2}
152160
m_LocalScale: {x: 1, y: 1, z: 1}
161+
m_ConstrainProportionsScale: 0
153162
m_Children: []
154163
m_Father: {fileID: 5655447013084909147}
155164
m_RootOrder: 7
@@ -180,6 +189,7 @@ Transform:
180189
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
181190
m_LocalPosition: {x: 4, y: 0, z: 4}
182191
m_LocalScale: {x: 1, y: 1, z: 1}
192+
m_ConstrainProportionsScale: 0
183193
m_Children: []
184194
m_Father: {fileID: 5655447013084909147}
185195
m_RootOrder: 2
@@ -210,6 +220,7 @@ Transform:
210220
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
211221
m_LocalPosition: {x: 7, y: 0, z: 4}
212222
m_LocalScale: {x: 1, y: 1, z: 1}
223+
m_ConstrainProportionsScale: 0
213224
m_Children: []
214225
m_Father: {fileID: 5655447013084909147}
215226
m_RootOrder: 3
@@ -240,6 +251,7 @@ Transform:
240251
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
241252
m_LocalPosition: {x: -2, y: 0, z: 4}
242253
m_LocalScale: {x: 1, y: 1, z: 1}
254+
m_ConstrainProportionsScale: 0
243255
m_Children: []
244256
m_Father: {fileID: 5655447013084909147}
245257
m_RootOrder: 0
@@ -270,6 +282,7 @@ Transform:
270282
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
271283
m_LocalPosition: {x: 5, y: 0, z: 2}
272284
m_LocalScale: {x: 1, y: 1, z: 1}
285+
m_ConstrainProportionsScale: 0
273286
m_Children: []
274287
m_Father: {fileID: 5655447013084909147}
275288
m_RootOrder: 6
@@ -300,6 +313,7 @@ Transform:
300313
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
301314
m_LocalPosition: {x: 1, y: 0, z: 4}
302315
m_LocalScale: {x: 1, y: 1, z: 1}
316+
m_ConstrainProportionsScale: 0
303317
m_Children: []
304318
m_Father: {fileID: 5655447013084909147}
305319
m_RootOrder: 1
@@ -330,6 +344,7 @@ Transform:
330344
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
331345
m_LocalPosition: {x: 2, y: 0, z: 2}
332346
m_LocalScale: {x: 1, y: 1, z: 1}
347+
m_ConstrainProportionsScale: 0
333348
m_Children: []
334349
m_Father: {fileID: 5655447013084909147}
335350
m_RootOrder: 5

Assets/Prefabs/State/CharSelectState.prefab

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Transform:
3030
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
3131
m_LocalPosition: {x: 0, y: 0, z: 0}
3232
m_LocalScale: {x: 1, y: 1, z: 1}
33+
m_ConstrainProportionsScale: 0
3334
m_Children: []
3435
m_Father: {fileID: 0}
3536
m_RootOrder: 0
@@ -62,6 +63,10 @@ MonoBehaviour:
6263
m_Script: {fileID: 11500000, guid: b4ae93287066a264d92939aa957cf227, type: 3}
6364
m_Name:
6465
m_EditorClassIdentifier:
66+
parentReference:
67+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
68+
autoRun: 1
69+
autoInjectGameObjects: []
6570
--- !u!114 &3565665953789623674
6671
MonoBehaviour:
6772
m_ObjectHideFlags: 0
@@ -74,6 +79,10 @@ MonoBehaviour:
7479
m_Script: {fileID: 11500000, guid: eca1f4b442326cc4d9be3975746b8cdb, type: 3}
7580
m_Name:
7681
m_EditorClassIdentifier:
82+
parentReference:
83+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
84+
autoRun: 1
85+
autoInjectGameObjects: []
7786
m_AnimationTriggerOnCharSelect: BeginRevive
7887
m_AnimationTriggerOnCharChosen: BeginRevive
7988
m_PlayerSeats:
@@ -103,6 +112,7 @@ MonoBehaviour:
103112
- Indicator: {fileID: 21300000, guid: 5e0531f7cad04b346bf05685f3b9a846, type: 3}
104113
Color: {r: 0.19215687, g: 0.03137255, b: 0.9882353, a: 1}
105114
m_NumPlayersText: {fileID: 0}
115+
m_ReadyButtonText: {fileID: 0}
106116
m_UIElementsForNoSeatChosen:
107117
- {fileID: 0}
108118
- {fileID: 0}
@@ -114,8 +124,6 @@ MonoBehaviour:
114124
m_UIElementsForFatalError:
115125
- {fileID: 0}
116126
m_ClassInfoBox: {fileID: 0}
117-
m_FatalLobbyErrorText: {fileID: 0}
118-
m_FatalErrorLobbyFullMsg: 'Error: lobby is full! You cannot play.'
119127
m_CharacterGraphicsParent: {fileID: 0}
120128
--- !u!114 &3565665953789623673
121129
MonoBehaviour:

Assets/Prefabs/State/MainMenuState.prefab

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,17 @@ MonoBehaviour:
6969
m_Script: {fileID: 11500000, guid: ab10fd7c6aa7d36438f5ac1c0ebfadbb, type: 3}
7070
m_Name:
7171
m_EditorClassIdentifier:
72-
m_GameObjectsThatWillBeInjectedAutomatically: []
72+
parentReference:
73+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
74+
autoRun: 1
75+
autoInjectGameObjects: []
7376
m_NameGenerationData: {fileID: 11400000, guid: cc0e4025ad893614a8db0d9c10bf7c4f, type: 2}
7477
m_LobbyUIMediator: {fileID: 0}
7578
m_IPUIMediator: {fileID: 0}
7679
m_LobbyButton: {fileID: 0}
7780
m_SignInSpinner: {fileID: 0}
81+
m_UIProfileSelector: {fileID: 0}
82+
m_UGSSetupTooltipDetector: {fileID: 0}
7883
--- !u!223 &2665876610389888237
7984
Canvas:
8085
m_ObjectHideFlags: 0

Assets/Prefabs/State/PostGameState.prefab

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Transform:
2929
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
3030
m_LocalPosition: {x: 0, y: 0, z: 0}
3131
m_LocalScale: {x: 1, y: 1, z: 1}
32+
m_ConstrainProportionsScale: 0
3233
m_Children: []
3334
m_Father: {fileID: 0}
3435
m_RootOrder: 0
@@ -45,6 +46,10 @@ MonoBehaviour:
4546
m_Script: {fileID: 11500000, guid: a2a5cf2c4e970b64a9073f4f760322b5, type: 3}
4647
m_Name:
4748
m_EditorClassIdentifier:
49+
parentReference:
50+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
51+
autoRun: 1
52+
autoInjectGameObjects: []
4853
--- !u!114 &-1007214952234040975
4954
MonoBehaviour:
5055
m_ObjectHideFlags: 0
@@ -73,3 +78,7 @@ MonoBehaviour:
7378
m_Script: {fileID: 11500000, guid: 1cb58d1788f410740b05cace1af646d7, type: 3}
7479
m_Name:
7580
m_EditorClassIdentifier:
81+
parentReference:
82+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
83+
autoRun: 1
84+
autoInjectGameObjects: []

Assets/Scenes/BossRoom.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:3de6367e1590522862f4e215fee25c7625e74596ab09067345a67c895080139c
3-
size 508257
2+
oid sha256:e3f00d58c6349986e4c2ca3da5c3d980eeda05bd854d63e23d1f3ab33f034b71
3+
size 509756

Assets/Scenes/CharSelect.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:62bad07fe63ed3776089846d5edc5aaf84f11e4cadcbc4363ad38f03ed0c5cdd
3-
size 39570
2+
oid sha256:fe57cffed60d9bfe7f42257a90c3d6a2240755dcaa4e10ae0c745f6fb4aecd66
3+
size 45820

Assets/Scenes/MainMenu.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:79d3b1f7bd554253e1b21ba934a02c91665c3bbdbd920871291f0ceada2803b6
3-
size 64423
2+
oid sha256:f63ef21240536cea8fc653871261d274a3fe381f0bbe9a297bfb8b547fd82ae9
3+
size 67930

Assets/Scenes/PostGame.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:80f61ce50c2df8f7e43e3d365fe8d2be8e4d9893fe614390015a324a4679c873
3-
size 67071
2+
oid sha256:ddaaa366f8d07e0e8347f5cecd0d7bd6b71715365ad0458a45667ce3463f3672
3+
size 67888

Assets/Scenes/Startup.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:57ebb73c6fac9cb948a60578d22c0c76ac8980c78e51e261e867c06eeb10013e
3-
size 46492
2+
oid sha256:8e7de9f7adc74855f71578459a9045e7b306964aa10509cfe451e18afd08129c
3+
size 46516

Assets/Scripts/ApplicationLifecycle/ApplicationController.cs

Lines changed: 40 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
using Unity.Multiplayer.Samples.Utilities;
1111
using UnityEngine;
1212
using UnityEngine.SceneManagement;
13+
using VContainer;
14+
using VContainer.Unity;
1315

1416
namespace Unity.Multiplayer.Samples.BossRoom.Shared
1517
{
18+
1619
/// <summary>
1720
/// An entry point to the application, where we bind all the common dependencies to the root DI scope.
1821
/// </summary>
19-
public class ApplicationController : MonoBehaviour
22+
public class ApplicationController : LifetimeScope
2023
{
2124
[SerializeField] UpdateRunner m_UpdateRunner;
2225
[SerializeField] GameNetPortal m_GameNetPortal;
@@ -25,89 +28,78 @@ public class ApplicationController : MonoBehaviour
2528

2629
LocalLobby m_LocalLobby;
2730
LobbyServiceFacade m_LobbyServiceFacade;
28-
IDisposable m_Subscriptions;
2931

30-
[SerializeField] GameObject[] m_GameObjectsThatWillBeInjectedAutomatically;
32+
IDisposable m_Subscriptions;
3133

32-
private void Awake()
34+
protected override void Configure(IContainerBuilder builder)
3335
{
34-
Application.wantsToQuit += OnWantToQuit;
35-
36-
DontDestroyOnLoad(gameObject);
37-
DontDestroyOnLoad(m_UpdateRunner.gameObject);
38-
39-
var scope = DIScope.RootScope;
40-
41-
scope.BindInstanceAsSingle(this);
42-
scope.BindInstanceAsSingle(m_UpdateRunner);
43-
scope.BindInstanceAsSingle(m_GameNetPortal);
44-
scope.BindInstanceAsSingle(m_ClientNetPortal);
45-
scope.BindInstanceAsSingle(m_ServerGameNetPortal);
36+
base.Configure(builder);
37+
builder.RegisterComponent(m_UpdateRunner);
38+
builder.RegisterComponent(m_GameNetPortal);
39+
builder.RegisterComponent(m_ClientNetPortal);
40+
builder.RegisterComponent(m_ServerGameNetPortal);
4641

4742
//the following singletons represent the local representations of the lobby that we're in and the user that we are
4843
//they can persist longer than the lifetime of the UI in MainMenu where we set up the lobby that we create or join
49-
scope.BindAsSingle<LocalLobbyUser>();
50-
scope.BindAsSingle<LocalLobby>();
44+
builder.Register<LocalLobbyUser>(Lifetime.Singleton);
45+
builder.Register<LocalLobby>(Lifetime.Singleton);
5146

52-
scope.BindAsSingle<ProfileManager>();
47+
builder.Register<ProfileManager>(Lifetime.Singleton);
5348

5449
//these message channels are essential and persist for the lifetime of the lobby and relay services
55-
scope.BindMessageChannelInstance<QuitGameSessionMessage>();
56-
scope.BindMessageChannelInstance<QuitApplicationMessage>();
57-
scope.BindMessageChannelInstance<UnityServiceErrorMessage>();
58-
scope.BindMessageChannelInstance<ConnectStatus>();
59-
scope.BindMessageChannelInstance<DoorStateChangedEventMessage>();
50+
// Registering as instance to prevent code stripping on iOS
51+
builder.RegisterInstance(new MessageChannel<QuitGameSessionMessage>()).AsImplementedInterfaces();
52+
builder.RegisterInstance(new MessageChannel<QuitApplicationMessage>()).AsImplementedInterfaces();
53+
builder.RegisterInstance(new MessageChannel<UnityServiceErrorMessage>()).AsImplementedInterfaces();
54+
builder.RegisterInstance(new MessageChannel<ConnectStatus>()).AsImplementedInterfaces();
55+
builder.RegisterInstance(new MessageChannel<DoorStateChangedEventMessage>()).AsImplementedInterfaces();
6056

6157
//these message channels are essential and persist for the lifetime of the lobby and relay services
6258
//they are networked so that the clients can subscribe to those messages that are published by the server
63-
scope.BindNetworkedMessageChannelInstance<LifeStateChangedEventMessage>();
64-
scope.BindNetworkedMessageChannelInstance<ConnectionEventMessage>();
59+
builder.RegisterInstance(new NetworkedMessageChannel<LifeStateChangedEventMessage>()).AsImplementedInterfaces();
60+
builder.RegisterInstance(new NetworkedMessageChannel<ConnectionEventMessage>()).AsImplementedInterfaces();
6561
#if UNITY_EDITOR || DEVELOPMENT_BUILD
66-
scope.BindNetworkedMessageChannelInstance<CheatUsedMessage>();
62+
builder.RegisterInstance(new NetworkedMessageChannel<CheatUsedMessage>()).AsImplementedInterfaces();
6763
#endif
6864

6965
//this message channel is essential and persists for the lifetime of the lobby and relay services
70-
scope.BindMessageChannelInstance<ReconnectMessage>();
66+
builder.RegisterInstance(new MessageChannel<ReconnectMessage>()).AsImplementedInterfaces();
7167

7268
//buffered message channels hold the latest received message in buffer and pass to any new subscribers
73-
scope.BindBufferedMessageChannelInstance<LobbyListFetchedMessage>();
69+
builder.RegisterInstance(new BufferedMessageChannel<LobbyListFetchedMessage>()).AsImplementedInterfaces();
7470

7571
//all the lobby service stuff, bound here so that it persists through scene loads
76-
scope.BindAsSingle<AuthenticationServiceFacade>(); //a manager entity that allows us to do anonymous authentication with unity services
77-
scope.BindAsSingle<LobbyServiceFacade>();
72+
builder.Register<AuthenticationServiceFacade>(Lifetime.Singleton); //a manager entity that allows us to do anonymous authentication with unity services
7873

79-
scope.FinalizeScopeConstruction();
80-
81-
foreach (var o in m_GameObjectsThatWillBeInjectedAutomatically)
82-
{
83-
scope.InjectIn(o);
84-
}
74+
//LobbyServiceFacade is registered as entrypoint because it wants a callback after container is built to do it's initialization
75+
builder.RegisterEntryPoint<LobbyServiceFacade>(Lifetime.Singleton).AsSelf();
76+
}
8577

86-
m_LocalLobby = scope.Resolve<LocalLobby>();
87-
m_LobbyServiceFacade = scope.Resolve<LobbyServiceFacade>();
78+
private void Start()
79+
{
80+
m_LocalLobby = Container.Resolve<LocalLobby>();
81+
m_LobbyServiceFacade = Container.Resolve<LobbyServiceFacade>();
8882

89-
var quitGameSessionSub = scope.Resolve<ISubscriber<QuitGameSessionMessage>>();
90-
var quitApplicationSub = scope.Resolve<ISubscriber<QuitApplicationMessage>>();
83+
var quitGameSessionSub = Container.Resolve<ISubscriber<QuitGameSessionMessage>>();
84+
var quitApplicationSub = Container.Resolve<ISubscriber<QuitApplicationMessage>>();
9185

9286
var subHandles = new DisposableGroup();
9387
subHandles.Add(quitGameSessionSub.Subscribe(LeaveSession));
9488
subHandles.Add(quitApplicationSub.Subscribe(QuitGame));
9589
m_Subscriptions = subHandles;
9690

91+
Application.wantsToQuit += OnWantToQuit;
92+
DontDestroyOnLoad(gameObject);
93+
DontDestroyOnLoad(m_UpdateRunner.gameObject);
9794
Application.targetFrameRate = 120;
98-
}
99-
100-
private void Start()
101-
{
10295
SceneManager.LoadScene("MainMenu");
10396
}
10497

105-
private void OnDestroy()
98+
protected override void OnDestroy()
10699
{
107100
m_Subscriptions?.Dispose();
108101
m_LobbyServiceFacade?.EndTracking();
109-
DIScope.RootScope.Dispose();
110-
DIScope.RootScope = null;
102+
base.OnDestroy();
111103
}
112104

113105
/// <summary>
@@ -139,7 +131,6 @@ private bool OnWantToQuit()
139131
return canQuit;
140132
}
141133

142-
// TODO remove messaging for this once we have vcontainer.
143134
private void LeaveSession(QuitGameSessionMessage msg)
144135
{
145136
m_LobbyServiceFacade.EndTracking();
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
{
2-
"name": "Unity.BossRoom.ApplicationLifecycle.Messages"
3-
}
2+
"name": "Unity.BossRoom.ApplicationLifecycle.Messages",
3+
"rootNamespace": "",
4+
"references": [],
5+
"includePlatforms": [],
6+
"excludePlatforms": [],
7+
"allowUnsafeCode": false,
8+
"overrideReferences": false,
9+
"precompiledReferences": [],
10+
"autoReferenced": true,
11+
"defineConstraints": [],
12+
"versionDefines": [],
13+
"noEngineReferences": false
14+
}

0 commit comments

Comments
 (0)