UPdate
This commit is contained in:
@@ -16,12 +16,19 @@ public class PlayerDataManager : NetworkBehaviour
|
||||
|
||||
[Networked]
|
||||
public NetworkDictionary<PlayerRef, _PlayerMetaData> Players => default;
|
||||
|
||||
[Networked]
|
||||
public PlayerRef Leader { get; set; }
|
||||
|
||||
public event Action<PlayerRef, string> OnChatMessageReceived;
|
||||
|
||||
public override void Spawned()
|
||||
{
|
||||
Instance = this;
|
||||
if (Object.HasStateAuthority)
|
||||
{
|
||||
Leader = Runner.LocalPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Despawned(NetworkRunner runner, bool hasState)
|
||||
@@ -29,6 +36,15 @@ public class PlayerDataManager : NetworkBehaviour
|
||||
if (Instance == this) Instance = null;
|
||||
}
|
||||
|
||||
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
|
||||
public void RPC_TransferLeader(PlayerRef newLeader)
|
||||
{
|
||||
if (Players.ContainsKey(newLeader))
|
||||
{
|
||||
Leader = newLeader;
|
||||
}
|
||||
}
|
||||
|
||||
[Rpc(RpcSources.All, RpcTargets.StateAuthority)]
|
||||
public void RPC_UpdatePlayerMetaData(PlayerRef playerRef, _PlayerMetaData metaData)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user