Skip to content

Commit 815effe

Browse files
registration of components to the scene state context builder
1 parent d75a01f commit 815effe

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
lines changed

Assets/Prefabs/State/PostGameState.prefab

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ MonoBehaviour:
4747
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
4848
m_Name:
4949
m_EditorClassIdentifier:
50-
GlobalObjectIdHash: 4221458659
50+
GlobalObjectIdHash: 2751448866
5151
InScenePlacedSourceGlobalObjectIdHash: 2795900295
5252
DeferredDespawnTick: 0
5353
Ownership: 1
@@ -79,7 +79,8 @@ MonoBehaviour:
7979
- {fileID: 0}
8080
- {fileID: 0}
8181
m_NetcodeHooks: {fileID: 6576822806953781696}
82-
networkPostGame: {fileID: 6889826313803109754}
82+
m_NetworkPostGame: {fileID: 6889826313803109754}
83+
m_PostGameUI: {fileID: 0}
8384
--- !u!114 &6576822806953781696
8485
MonoBehaviour:
8586
m_ObjectHideFlags: 0

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:9f6d043b0d737b156218d82153c0068bda1b8af7cf40d1acdf13adc7356e6ae8
3-
size 34859
2+
oid sha256:7e534777638d85f5d4ae6fb3694efe209e4e7208e38811cd2479d1aacbc8029e
3+
size 36125

Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ public class NetworkPostGame : NetworkBehaviour
1414

1515
[Inject]
1616
PersistentGameState m_PersistentGameState;
17-
18-
[Inject]
19-
public void Construct(PersistentGameState persistentGameState, PostGameUI postGameUI)
20-
{
21-
m_PostGameUI = postGameUI;
22-
m_PersistentGameState = persistentGameState;
23-
}
2417

2518
public override void OnNetworkSpawn()
2619
{

Assets/Scripts/Gameplay/GameState/ServerPostGameState.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System;
22
using Unity.BossRoom.ConnectionManagement;
33
using Unity.BossRoom.Gameplay.Actions;
4+
using Unity.BossRoom.Gameplay.UI;
45
using Unity.Multiplayer.Samples.BossRoom;
56
using Unity.Multiplayer.Samples.Utilities;
67
using Unity.Netcode;
78
using UnityEngine;
8-
using UnityEngine.Serialization;
99
using VContainer;
10+
using VContainer.Unity;
1011

1112
namespace Unity.BossRoom.Gameplay.GameState
1213
{
@@ -16,10 +17,12 @@ public class ServerPostGameState : GameStateBehaviour
1617
[SerializeField]
1718
NetcodeHooks m_NetcodeHooks;
1819

19-
[FormerlySerializedAs("synchronizedStateData")]
2020
[SerializeField]
21-
NetworkPostGame networkPostGame;
22-
public NetworkPostGame NetworkPostGame => networkPostGame;
21+
NetworkPostGame m_NetworkPostGame;
22+
public NetworkPostGame NetworkPostGame => m_NetworkPostGame;
23+
24+
[SerializeField]
25+
PostGameUI m_PostGameUI;
2326

2427
public override GameState ActiveState { get { return GameState.PostGame; } }
2528

@@ -35,6 +38,13 @@ protected override void Awake()
3538

3639
m_NetcodeHooks.OnNetworkSpawnHook += OnNetworkSpawn;
3740
}
41+
42+
protected override void Configure(IContainerBuilder builder)
43+
{
44+
base.Configure(builder);
45+
builder.RegisterComponent(m_NetworkPostGame);
46+
builder.RegisterComponent(m_PostGameUI);
47+
}
3848

3949
void OnNetworkSpawn()
4050
{
@@ -45,7 +55,6 @@ void OnNetworkSpawn()
4555
else
4656
{
4757
SessionManager<SessionPlayerData>.Instance.OnSessionEnded();
48-
networkPostGame.WinState.Value = m_PersistentGameState.WinState;
4958
}
5059
}
5160

Assets/Scripts/Gameplay/UI/PostGameUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class PostGameUI : MonoBehaviour
3030
Color m_WinLightColor;
3131
Color m_LoseLightColor;*/
3232

33-
void OnEnable()
33+
void Awake()
3434
{
3535
var root = m_PostGameUIDocument.rootVisualElement;
3636

Assets/Scripts/Gameplay/UI/UIQuitPanel.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ enum QuitMode
2323

2424
[Inject]
2525
IPublisher<QuitApplicationMessage> m_QuitApplicationPub;
26-
27-
void Awake()
28-
{
29-
if (m_ConnectionManager == null)
30-
{
31-
Debug.LogError("ConnectionManager is null! Ensure that dependency injection is set up correctly.");
32-
}
33-
else
34-
{
35-
Debug.Log("ConnectionManager successfully injected into UIQuitPanel.");
36-
}
37-
}
3826

3927
public void Quit()
4028
{

0 commit comments

Comments
 (0)