mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 12:21:25 +00:00
Sync when calling SetCustomData directly not just from API
This commit is contained in:
parent
faa557591a
commit
fcef4d749d
@ -8,7 +8,5 @@ public class AddonCustomDataSyncMessage : QSBMessage<(uint playerId, string key,
|
||||
{
|
||||
public AddonCustomDataSyncMessage(uint playerId, string key, object data) : base((playerId, key, data.ToBytes())) { }
|
||||
|
||||
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||
|
||||
public override void OnReceiveRemote() => QSBPlayerManager.GetPlayer(Data.playerId).SetCustomData(Data.key, Data.data.ToObject());
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using QSB.Messaging;
|
||||
using QSB.Messaging;
|
||||
using QSB.Utility;
|
||||
|
||||
namespace QSB.API.Messages;
|
||||
|
@ -27,7 +27,7 @@ public class QSBAPI : IQSBAPI
|
||||
public UnityEvent<uint> OnPlayerLeave() => QSBAPIEvents.OnPlayerLeaveEvent;
|
||||
|
||||
public void SetCustomData<T>(uint playerId, string key, T data)
|
||||
=> new AddonCustomDataSyncMessage(playerId, key, data).Send();
|
||||
=> QSBPlayerManager.GetPlayer(playerId).SetCustomData<T>(key, data);
|
||||
|
||||
public T GetCustomData<T>(uint playerId, string key)
|
||||
=> QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
||||
|
@ -1,10 +1,12 @@
|
||||
using OWML.Common;
|
||||
using QSB.Animation.Player;
|
||||
using QSB.API.Messages;
|
||||
using QSB.Audio;
|
||||
using QSB.ClientServerStateSync;
|
||||
using QSB.HUD;
|
||||
using QSB.Messaging;
|
||||
using QSB.ModelShip;
|
||||
using QSB.Patches;
|
||||
using QSB.Player.Messages;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.QuantumSync.WorldObjects;
|
||||
@ -182,7 +184,15 @@ public partial class PlayerInfo
|
||||
private Dictionary<string, object> _customData = new();
|
||||
|
||||
public void SetCustomData<T>(string key, T data)
|
||||
=> _customData[key] = data;
|
||||
{
|
||||
_customData[key] = data;
|
||||
|
||||
if (!QSBPatch.Remote)
|
||||
{
|
||||
new AddonCustomDataSyncMessage(PlayerId, key, data).Send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T GetCustomData<T>(string key)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user