Skip to content

Commit 4031e5d

Browse files
committed
Merge branch 'develop' into sam/feat/dedicated-server-support
* develop: feat/fix: NetcodeHooks added to restore previous isserver/isclient logic gating [MTT-4054] [MTT-4056] (#691) # Conflicts: # Assets/Prefabs/State/CharSelectState.prefab # Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs # Assets/Scripts/Gameplay/GameState/ServerCharSelectState.cs # Assets/Scripts/Gameplay/GameState/ServerPostGameState.cs # Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs # Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs.meta
2 parents 5d957fc + eb52c45 commit 4031e5d

File tree

11 files changed

+169
-107
lines changed

11 files changed

+169
-107
lines changed

Assets/Prefabs/State/BossRoomState.prefab

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ GameObject:
99
serializedVersion: 6
1010
m_Component:
1111
- component: {fileID: 5655447013084909147}
12-
- component: {fileID: -1764033382396218637}
1312
- component: {fileID: 3608714310874968837}
13+
- component: {fileID: -1764033382396218637}
1414
- component: {fileID: 5762482089640033414}
15+
- component: {fileID: 1290852967062359934}
1516
m_Layer: 0
1617
m_Name: BossRoomState
1718
m_TagString: Untagged
@@ -42,7 +43,7 @@ Transform:
4243
m_Father: {fileID: 0}
4344
m_RootOrder: 0
4445
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
45-
--- !u!114 &-1764033382396218637
46+
--- !u!114 &3608714310874968837
4647
MonoBehaviour:
4748
m_ObjectHideFlags: 0
4849
m_CorrespondingSourceObject: {fileID: 0}
@@ -51,14 +52,14 @@ MonoBehaviour:
5152
m_GameObject: {fileID: 297185343939699586}
5253
m_Enabled: 1
5354
m_EditorHideFlags: 0
54-
m_Script: {fileID: 11500000, guid: 5e631ac38df479741af592cf6a1fb553, type: 3}
55+
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
5556
m_Name:
5657
m_EditorClassIdentifier:
57-
parentReference:
58-
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
59-
autoRun: 1
60-
autoInjectGameObjects: []
61-
--- !u!114 &3608714310874968837
58+
GlobalObjectIdHash: 951099334
59+
AlwaysReplicateAsRoot: 0
60+
DontDestroyWithOwner: 0
61+
AutoObjectParentSync: 1
62+
--- !u!114 &-1764033382396218637
6263
MonoBehaviour:
6364
m_ObjectHideFlags: 0
6465
m_CorrespondingSourceObject: {fileID: 0}
@@ -67,13 +68,13 @@ MonoBehaviour:
6768
m_GameObject: {fileID: 297185343939699586}
6869
m_Enabled: 1
6970
m_EditorHideFlags: 0
70-
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
71+
m_Script: {fileID: 11500000, guid: 5e631ac38df479741af592cf6a1fb553, type: 3}
7172
m_Name:
7273
m_EditorClassIdentifier:
73-
GlobalObjectIdHash: 951099334
74-
AlwaysReplicateAsRoot: 0
75-
DontDestroyWithOwner: 0
76-
AutoObjectParentSync: 1
74+
parentReference:
75+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
76+
autoRun: 1
77+
autoInjectGameObjects: []
7778
--- !u!114 &5762482089640033414
7879
MonoBehaviour:
7980
m_ObjectHideFlags: 0
@@ -90,6 +91,7 @@ MonoBehaviour:
9091
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
9192
autoRun: 1
9293
autoInjectGameObjects: []
94+
m_NetcodeHooks: {fileID: 1290852967062359934}
9395
m_NetworkGameStateTransform: {fileID: 11400000, guid: 07bddcdf06738e74cb79d30065ff96af, type: 2}
9496
m_PlayerPrefab: {fileID: 6009713983291384767, guid: 8237adf32a9b6de4892e6febe6b4bdef, type: 3}
9597
m_PlayerSpawnPoints:
@@ -101,6 +103,18 @@ MonoBehaviour:
101103
- {fileID: 6314369147267609336}
102104
- {fileID: 8725901042666772653}
103105
- {fileID: 7239491272522478247}
106+
--- !u!114 &1290852967062359934
107+
MonoBehaviour:
108+
m_ObjectHideFlags: 0
109+
m_CorrespondingSourceObject: {fileID: 0}
110+
m_PrefabInstance: {fileID: 0}
111+
m_PrefabAsset: {fileID: 0}
112+
m_GameObject: {fileID: 297185343939699586}
113+
m_Enabled: 1
114+
m_EditorHideFlags: 0
115+
m_Script: {fileID: 11500000, guid: 6aedfcf74b3f4f248897af16490caa9d, type: 3}
116+
m_Name:
117+
m_EditorClassIdentifier:
104118
--- !u!1 &1088799320945899822
105119
GameObject:
106120
m_ObjectHideFlags: 0

Assets/Prefabs/State/CharSelectState.prefab

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ GameObject:
1212
- component: {fileID: 1092063945021251778}
1313
- component: {fileID: 3565665953789623675}
1414
- component: {fileID: 3565665953789623673}
15+
- component: {fileID: 8494646029522094751}
1516
m_Layer: 0
1617
m_Name: CharSelectState
1718
m_TagString: Untagged
@@ -87,3 +88,15 @@ MonoBehaviour:
8788
- {fileID: 11400000, guid: f49fc0646d4e9554f88a31ac496afd19, type: 2}
8889
- {fileID: 11400000, guid: 70d299733c76b0649852336624091fca, type: 2}
8990
- {fileID: 11400000, guid: 9cc69a593b6ff1b4b95bf7330ec5ab46, type: 2}
91+
--- !u!114 &8494646029522094751
92+
MonoBehaviour:
93+
m_ObjectHideFlags: 0
94+
m_CorrespondingSourceObject: {fileID: 0}
95+
m_PrefabInstance: {fileID: 0}
96+
m_PrefabAsset: {fileID: 0}
97+
m_GameObject: {fileID: 3565665953789623672}
98+
m_Enabled: 1
99+
m_EditorHideFlags: 0
100+
m_Script: {fileID: 11500000, guid: 6aedfcf74b3f4f248897af16490caa9d, type: 3}
101+
m_Name:
102+
m_EditorClassIdentifier:

Assets/Prefabs/State/PostGameState.prefab

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ GameObject:
99
serializedVersion: 6
1010
m_Component:
1111
- component: {fileID: 7475764267130300179}
12-
- component: {fileID: 7475764267130300178}
1312
- component: {fileID: -1007214952234040975}
13+
- component: {fileID: 7475764267130300178}
1414
- component: {fileID: 4223400095609434710}
15+
- component: {fileID: 6576822806953781696}
1516
m_Layer: 0
1617
m_Name: PostGameState
1718
m_TagString: Untagged
@@ -34,7 +35,7 @@ Transform:
3435
m_Father: {fileID: 0}
3536
m_RootOrder: 0
3637
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
37-
--- !u!114 &7475764267130300178
38+
--- !u!114 &-1007214952234040975
3839
MonoBehaviour:
3940
m_ObjectHideFlags: 0
4041
m_CorrespondingSourceObject: {fileID: 0}
@@ -43,14 +44,14 @@ MonoBehaviour:
4344
m_GameObject: {fileID: 7475764267130300177}
4445
m_Enabled: 1
4546
m_EditorHideFlags: 0
46-
m_Script: {fileID: 11500000, guid: a2a5cf2c4e970b64a9073f4f760322b5, type: 3}
47+
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
4748
m_Name:
4849
m_EditorClassIdentifier:
49-
parentReference:
50-
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
51-
autoRun: 1
52-
autoInjectGameObjects: []
53-
--- !u!114 &-1007214952234040975
50+
GlobalObjectIdHash: 951099334
51+
AlwaysReplicateAsRoot: 0
52+
DontDestroyWithOwner: 0
53+
AutoObjectParentSync: 1
54+
--- !u!114 &7475764267130300178
5455
MonoBehaviour:
5556
m_ObjectHideFlags: 0
5657
m_CorrespondingSourceObject: {fileID: 0}
@@ -59,13 +60,14 @@ MonoBehaviour:
5960
m_GameObject: {fileID: 7475764267130300177}
6061
m_Enabled: 1
6162
m_EditorHideFlags: 0
62-
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
63+
m_Script: {fileID: 11500000, guid: a2a5cf2c4e970b64a9073f4f760322b5, type: 3}
6364
m_Name:
6465
m_EditorClassIdentifier:
65-
GlobalObjectIdHash: 951099334
66-
AlwaysReplicateAsRoot: 0
67-
DontDestroyWithOwner: 0
68-
AutoObjectParentSync: 1
66+
parentReference:
67+
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
68+
autoRun: 1
69+
autoInjectGameObjects: []
70+
m_NetcodeHooks: {fileID: 6576822806953781696}
6971
--- !u!114 &4223400095609434710
7072
MonoBehaviour:
7173
m_ObjectHideFlags: 0
@@ -82,3 +84,15 @@ MonoBehaviour:
8284
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
8385
autoRun: 1
8486
autoInjectGameObjects: []
87+
--- !u!114 &6576822806953781696
88+
MonoBehaviour:
89+
m_ObjectHideFlags: 0
90+
m_CorrespondingSourceObject: {fileID: 0}
91+
m_PrefabInstance: {fileID: 0}
92+
m_PrefabAsset: {fileID: 0}
93+
m_GameObject: {fileID: 7475764267130300177}
94+
m_Enabled: 1
95+
m_EditorHideFlags: 0
96+
m_Script: {fileID: 11500000, guid: 6aedfcf74b3f4f248897af16490caa9d, type: 3}
97+
m_Name:
98+
m_EditorClassIdentifier:

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:f63ef21240536cea8fc653871261d274a3fe381f0bbe9a297bfb8b547fd82ae9
3-
size 67930
2+
oid sha256:f9162f4f410f9bf87f75cb0b933e0902b542ef09f9b1c1b7a2a93ce01ec11bf6
3+
size 67373

Assets/Scripts/Gameplay/GameState/CharSelectData.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ private void Awake()
7979
m_LobbyPlayers = new NetworkList<LobbyPlayerState>();
8080
}
8181

82-
public Action OnNetworkSpawnCallback;
83-
public override void OnNetworkSpawn()
84-
{
85-
OnNetworkSpawnCallback();
86-
}
87-
88-
public Action OnNetworkDespawnCallback;
89-
public override void OnNetworkDespawn()
90-
{
91-
OnNetworkDespawnCallback();
92-
}
93-
9482
/// <summary>
9583
/// Current state of all players in the lobby.
9684
/// </summary>

Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44
using TMPro;
5+
using Unity.Multiplayer.Samples.Utilities;
56
using Unity.Netcode;
67
using VContainer;
78
using UnityEngine.SceneManagement;
@@ -11,13 +12,17 @@ namespace Unity.Multiplayer.Samples.BossRoom.Client
1112
/// <summary>
1213
/// Client specialization of the Character Select game state. Mainly controls the UI during character-select.
1314
/// </summary>
15+
[RequireComponent(typeof(NetcodeHooks))]
1416
public class ClientCharSelectState : GameStateBehaviour
1517
{
1618
/// <summary>
1719
/// Reference to the scene's state object so that UI can access state
1820
/// </summary>
1921
public static ClientCharSelectState Instance { get; private set; }
2022

23+
[SerializeField]
24+
NetcodeHooks m_NetcodeHooks;
25+
2126
public override GameState ActiveState { get { return GameState.CharSelect; } }
2227
public CharSelectData CharSelectData { get; private set; }
2328

@@ -111,8 +116,8 @@ protected override void Awake()
111116

112117
// TODO inject or find another way to find CharSelectData
113118
CharSelectData = FindObjectOfType<CharSelectData>();
114-
CharSelectData.OnNetworkSpawnCallback += OnSpawn; if (CharSelectData.IsSpawned) OnSpawn();
115-
CharSelectData.OnNetworkDespawnCallback += OnDespawn;
119+
m_NetcodeHooks.OnNetworkSpawnHook += OnNetworkSpawn;
120+
m_NetcodeHooks.OnNetworkDespawnHook += OnNetworkDespawn;
116121

117122
m_LobbyUIElementsByMode = new Dictionary<LobbyMode, List<GameObject>>()
118123
{
@@ -145,7 +150,7 @@ protected override void Start()
145150
UpdateCharacterSelection(CharSelectData.SeatState.Inactive);
146151
}
147152

148-
public void OnDespawn()
153+
void OnNetworkDespawn()
149154
{
150155
if (CharSelectData)
151156
{
@@ -154,7 +159,7 @@ public void OnDespawn()
154159
}
155160
}
156161

157-
public void OnSpawn()
162+
void OnNetworkSpawn()
158163
{
159164
if (!NetworkManager.Singleton.IsClient)
160165
{

0 commit comments

Comments
 (0)