Skip to content

Commit

Permalink
feat: allow end user's to create there own net id generator (#1019)
Browse files Browse the repository at this point in the history
* allow end user's to generate there own network Id.

* fixed should been uint not byte

* fixed name as james requested.

* forgot change ServerObjectManager reference.

Co-authored-by: dragonslaya <dragonslaya.ss@gmail.com>
  • Loading branch information
dragonslaya84 and dragonslaya84 committed Jan 15, 2022
1 parent a66caa5 commit d2e8834
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Assets/Mirage/Runtime/INetIdGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Mirage
{
public interface INetIdGenerator
{
/// <summary>
/// Generate your own specific net id.
/// </summary>
uint GenerateNetId();
}
}
11 changes: 11 additions & 0 deletions Assets/Mirage/Runtime/INetIdGenerator.cs.meta

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

4 changes: 3 additions & 1 deletion Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public class ServerObjectManager : MonoBehaviour, IServerObjectManager
[FormerlySerializedAs("networkSceneManager")]
public NetworkSceneManager NetworkSceneManager;

public INetIdGenerator NetIdGenerator;

uint nextNetworkId = 1;
uint GetNextNetworkId() => checked(nextNetworkId++);
uint GetNextNetworkId() => NetIdGenerator?.GenerateNetId() ?? checked(nextNetworkId++);

public void Start()
{
Expand Down

0 comments on commit d2e8834

Please sign in to comment.