Skip to content

Commit c7f099f

Browse files
pdeschainfernando-cortezSamuelBellomo
authored
feat: removing bridge classes for game states MTT-4204 (#697)
* Adjusted GameStateBehaviour class description * Removed ClientBossRoomState And renamed ServerBossRoomState to BossRoomState. Added lifetime scopes to all the subscenes of BossRoom scene. These autoinject gameobjects that live under the "static network objects" groupings. * Removed NetworkGameState and NetworkWinState replaced with BufferedNetworkMessageChannel (an addition in this entry) - this message channel is identical to NetworkMessageChannel, but it inherits from a buffered message channel instead. This is used as a way to pass data that syncs from server to clients between different scenes without the need for SO variables, which are hard to understand. * ClientMainMenuState renamed to MainMenuState * Removed ClientPostGameState and renamed ServerPostGameState to PostGameState also added auto-injected objects to the PostGameState-bearing game object. * Changelog and typo fixes * nullref fix (was disposing of a subscription handle before it was returned from the method) * Removed BufferedNetworkMessageChannel Replaced it's usage with WinState with a NetworkWinState that's preserved by BossRoomState to survive onto the next scene, PostGameState, which then destroys that preserved gameobject/NetworkWinState when we exit PostGameState to whatever next state. * actually setting win state * # * Changed some type names based on feedback * Cleanup * Update Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs Co-authored-by: Fernando Cortez <[email protected]> * Update Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs Co-authored-by: Fernando Cortez <[email protected]> * Update CHANGELOG.md Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Fernando Cortez <[email protected]> Co-authored-by: Sam Bellomo <[email protected]>
1 parent 8ef7941 commit c7f099f

28 files changed

+77
-315
lines changed

Assets/GameData/Transforms.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Assets/GameData/Transforms/NetworkGameState.asset

Lines changed: 0 additions & 3 deletions
This file was deleted.

Assets/GameData/Transforms/NetworkGameState.asset.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Assets/Prefabs/Game/NetworkGameState.prefab

Lines changed: 0 additions & 93 deletions
This file was deleted.

Assets/Prefabs/Game/NetworkGameState.prefab.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

Assets/Prefabs/State/BossRoomState.prefab

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ GameObject:
1010
m_Component:
1111
- component: {fileID: 5655447013084909147}
1212
- component: {fileID: 3608714310874968837}
13-
- component: {fileID: -1764033382396218637}
1413
- component: {fileID: 5762482089640033414}
1514
- component: {fileID: 1290852967062359934}
1615
m_Layer: 0
@@ -59,22 +58,6 @@ MonoBehaviour:
5958
AlwaysReplicateAsRoot: 0
6059
DontDestroyWithOwner: 0
6160
AutoObjectParentSync: 1
62-
--- !u!114 &-1764033382396218637
63-
MonoBehaviour:
64-
m_ObjectHideFlags: 0
65-
m_CorrespondingSourceObject: {fileID: 0}
66-
m_PrefabInstance: {fileID: 0}
67-
m_PrefabAsset: {fileID: 0}
68-
m_GameObject: {fileID: 297185343939699586}
69-
m_Enabled: 1
70-
m_EditorHideFlags: 0
71-
m_Script: {fileID: 11500000, guid: 5e631ac38df479741af592cf6a1fb553, type: 3}
72-
m_Name:
73-
m_EditorClassIdentifier:
74-
parentReference:
75-
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
76-
autoRun: 1
77-
autoInjectGameObjects: []
7861
--- !u!114 &5762482089640033414
7962
MonoBehaviour:
8063
m_ObjectHideFlags: 0

Assets/Prefabs/State/PostGameState.prefab

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ GameObject:
1111
- component: {fileID: 7475764267130300179}
1212
- component: {fileID: -1007214952234040975}
1313
- component: {fileID: 7475764267130300178}
14-
- component: {fileID: 4223400095609434710}
1514
- component: {fileID: 6576822806953781696}
1615
m_Layer: 0
1716
m_Name: PostGameState
@@ -66,24 +65,10 @@ MonoBehaviour:
6665
parentReference:
6766
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
6867
autoRun: 1
69-
autoInjectGameObjects: []
68+
autoInjectGameObjects:
69+
- {fileID: 0}
70+
- {fileID: 0}
7071
m_NetcodeHooks: {fileID: 6576822806953781696}
71-
--- !u!114 &4223400095609434710
72-
MonoBehaviour:
73-
m_ObjectHideFlags: 0
74-
m_CorrespondingSourceObject: {fileID: 0}
75-
m_PrefabInstance: {fileID: 0}
76-
m_PrefabAsset: {fileID: 0}
77-
m_GameObject: {fileID: 7475764267130300177}
78-
m_Enabled: 1
79-
m_EditorHideFlags: 0
80-
m_Script: {fileID: 11500000, guid: 1cb58d1788f410740b05cace1af646d7, type: 3}
81-
m_Name:
82-
m_EditorClassIdentifier:
83-
parentReference:
84-
TypeName: Unity.Multiplayer.Samples.BossRoom.Shared.ApplicationController
85-
autoRun: 1
86-
autoInjectGameObjects: []
8772
--- !u!114 &6576822806953781696
8873
MonoBehaviour:
8974
m_ObjectHideFlags: 0

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:e3f00d58c6349986e4c2ca3da5c3d980eeda05bd854d63e23d1f3ab33f034b71
3-
size 509756
2+
oid sha256:28e9292af276f5fdbe32dc931b3a6d824263b787d59fefe880f074fa5e7fad6e
3+
size 512114
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:dc4d365307a7b5b33726c81e1712f9ab7bd560329a22eb58c7c47b4ef47efef5
3-
size 323941
2+
oid sha256:307baa6090b31634d2d893f38c607db1cf8a20b168e0a6685a8949e21a16f1bd
3+
size 341270
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:6204feb139a189133ac967d65ca2e1ecb98473d35b48374d869c978fded08b78
3-
size 23353
2+
oid sha256:57ac496744b0443b24010d960e533b4d87e8d4f80dd2392335230f5aaa340884
3+
size 32367
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:18e051b0b22353028bda0afb8480efdcde0402832ca6037be7152f3d86b4472d
3-
size 19943
2+
oid sha256:b336bff4745a948e139a266ca62409cc84a3de1d78015e23b8c53b18ce346212
3+
size 24809

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:ddaaa366f8d07e0e8347f5cecd0d7bd6b71715365ad0458a45667ce3463f3672
3-
size 67888
2+
oid sha256:a83cc5f0506fee3971c22471b21a73080100af8bf903f60b0d265cf35b7a2a9b
3+
size 66255

Assets/Scripts/ConnectionManagement/ConnectionManager.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ public class ConnectionManager : MonoBehaviour
6060
NetworkManager m_NetworkManager;
6161
public NetworkManager NetworkManager => m_NetworkManager;
6262

63-
[SerializeField]
64-
NetworkObject m_GameState;
65-
public NetworkObject GameState => m_GameState;
66-
6763
[Inject]
6864
IObjectResolver m_Resolver;
6965

Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ class HostingState : ConnectionState
2525

2626
public override void Enter()
2727
{
28-
var gameState = UnityEngine.Object.Instantiate(m_ConnectionManager.GameState);
29-
30-
gameState.Spawn();
31-
3228
SceneLoaderWrapper.Instance.AddOnSceneEventCallback();
3329

3430
//The "BossRoom" server always advances to CharSelect immediately on start. Different games

Assets/Scripts/Gameplay/GameState/ClientBossRoomState.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/ClientBossRoomState.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/ClientPostGameState.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum GameState
1616
}
1717

1818
/// <summary>
19-
/// A special kind of NetworkBehaviour that represents a discrete game state. The special feature it offers is
19+
/// A special component that represents a discrete game state and its dependencies. The special feature it offers is
2020
/// that it provides some guarantees that only one such GameState will be running at a time.
2121
/// </summary>
2222
/// <remarks>
@@ -32,7 +32,7 @@ public enum GameState
3232
/// with other networked prefabs).
3333
/// Q: If these are MonoBehaviours, how do you have a single state that persists across multiple scenes?
3434
/// A: Set your Persists property to true. If you transition to another scene that has the same gamestate, the
35-
/// current GameState object will live on, and the version in the new scene will suicide to make room for it.
35+
/// current GameState object will live on, and the version in the new scene will auto-destruct to make room for it.
3636
///
3737
/// Important Note: We assume that every Scene has a GameState object. If not, then it's possible that a Persisting game state
3838
/// will outlast its lifetime (as there is no successor state to clean it up).

Assets/Scripts/Gameplay/GameState/NetworkGameState.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/NetworkGameState.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/NetworkWinState.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/Scripts/Gameplay/GameState/NetworkWinState.cs renamed to Assets/Scripts/Gameplay/GameState/PersistentGameState.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ public enum WinState
1212
}
1313

1414
/// <summary>
15-
/// MonoBehaviour containing only one NetworkVariableBool to represent the game session's win state.
15+
/// MonoBehaviour containing only one NetworkVariable<WinState> to represent the game session's win state.
1616
/// </summary>
17-
public class NetworkWinState : NetworkBehaviour
17+
public class PersistentGameState : NetworkBehaviour
1818
{
1919
public NetworkVariable<WinState> winState = new NetworkVariable<WinState>(WinState.Invalid);
20+
21+
public static PersistentGameState Instance;
2022
}
2123
}

Assets/Scripts/Gameplay/GameState/ClientPostGameState.cs.meta renamed to Assets/Scripts/Gameplay/GameState/PersistentGameState.cs.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.

0 commit comments

Comments
 (0)