Cleaned up SyncVar system slightly
This commit is contained in:
parent
dc6afc1331
commit
c1e6e6cbf9
@ -84,7 +84,7 @@ namespace MLAPI
|
|||||||
{
|
{
|
||||||
_networkedObject = GetComponentInParent<NetworkedObject>();
|
_networkedObject = GetComponentInParent<NetworkedObject>();
|
||||||
}
|
}
|
||||||
NetworkedObject.networkedBehaviours.Add(this);
|
NetworkedObject.NetworkedBehaviours.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool networkedStartInvoked = false;
|
internal bool networkedStartInvoked = false;
|
||||||
@ -117,7 +117,7 @@ namespace MLAPI
|
|||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
NetworkedObject.networkedBehaviours.Remove(this);
|
NetworkedObject.NetworkedBehaviours.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
@ -237,16 +237,12 @@ namespace MLAPI
|
|||||||
|
|
||||||
internal void OnSyncVarUpdate(object value, byte fieldIndex)
|
internal void OnSyncVarUpdate(object value, byte fieldIndex)
|
||||||
{
|
{
|
||||||
if (isServer)
|
|
||||||
return;
|
|
||||||
syncedFields[fieldIndex].SetValue(this, value);
|
syncedFields[fieldIndex].SetValue(this, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float lastSyncTime = 0f;
|
private float lastSyncTime = 0f;
|
||||||
internal void SyncvarUpdate()
|
internal void SyncVarUpdate()
|
||||||
{
|
{
|
||||||
if (!isServer)
|
|
||||||
return;
|
|
||||||
SetDirtyness();
|
SetDirtyness();
|
||||||
if(Time.time - lastSyncTime >= SyncVarSyncDelay)
|
if(Time.time - lastSyncTime >= SyncVarSyncDelay)
|
||||||
{
|
{
|
||||||
|
@ -97,17 +97,18 @@ namespace MLAPI
|
|||||||
if(netBehaviours[i].networkedObject == this && !netBehaviours[i].networkedStartInvoked)
|
if(netBehaviours[i].networkedObject == this && !netBehaviours[i].networkedStartInvoked)
|
||||||
{
|
{
|
||||||
netBehaviours[i].NetworkStart();
|
netBehaviours[i].NetworkStart();
|
||||||
netBehaviours[i].SyncVarInit();
|
if (NetworkingManager.singleton.isServer)
|
||||||
|
netBehaviours[i].SyncVarInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<NetworkedBehaviour> networkedBehaviours = new List<NetworkedBehaviour>();
|
internal static List<NetworkedBehaviour> NetworkedBehaviours = new List<NetworkedBehaviour>();
|
||||||
internal static void InvokeSyncvarUpdate()
|
internal static void InvokeSyncvarUpdate()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < networkedBehaviours.Count; i++)
|
for (int i = 0; i < NetworkedBehaviours.Count; i++)
|
||||||
{
|
{
|
||||||
networkedBehaviours[i].SyncvarUpdate();
|
NetworkedBehaviours[i].SyncVarUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,9 +363,10 @@ namespace MLAPI
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (isServer)
|
if (isServer)
|
||||||
|
{
|
||||||
LagCompensationManager.AddFrames();
|
LagCompensationManager.AddFrames();
|
||||||
|
NetworkedObject.InvokeSyncvarUpdate();
|
||||||
NetworkedObject.InvokeSyncvarUpdate();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator ApprovalTimeout(int clientId)
|
private IEnumerator ApprovalTimeout(int clientId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user