mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Follow naming conventions in NetworkBehaviour (#759)
This commit is contained in:
parent
f07ad218e0
commit
ecccb88be5
@ -28,8 +28,10 @@ public class NetworkBehaviour : MonoBehaviour
|
||||
protected ulong syncVarDirtyBits { get; private set; }
|
||||
protected bool syncVarHookGuard { get; set; }
|
||||
|
||||
[Obsolete("Use syncObjects instead.")]
|
||||
protected List<SyncObject> m_SyncObjects => syncObjects;
|
||||
// objects that can synchronize themselves, such as synclists
|
||||
protected readonly List<SyncObject> m_SyncObjects = new List<SyncObject>();
|
||||
protected readonly List<SyncObject> syncObjects = new List<SyncObject>();
|
||||
|
||||
// NetworkIdentity component caching for easier access
|
||||
NetworkIdentity m_netIdentity;
|
||||
@ -66,7 +68,7 @@ public int ComponentIndex
|
||||
// We collect all of them and we synchronize them with OnSerialize/OnDeserialize
|
||||
protected void InitSyncObject(SyncObject syncObject)
|
||||
{
|
||||
m_SyncObjects.Add(syncObject);
|
||||
syncObjects.Add(syncObject);
|
||||
}
|
||||
|
||||
#region Commands
|
||||
@ -427,9 +429,9 @@ public void ClearAllDirtyBits()
|
||||
// note: don't use List.ForEach here, this is a hot path
|
||||
// List.ForEach: 432b/frame
|
||||
// for: 231b/frame
|
||||
for (int i = 0; i < m_SyncObjects.Count; ++i)
|
||||
for (int i = 0; i < syncObjects.Count; ++i)
|
||||
{
|
||||
m_SyncObjects[i].Flush();
|
||||
syncObjects[i].Flush();
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,9 +440,9 @@ bool AnySyncObjectDirty()
|
||||
// note: don't use Linq here. 1200 networked objects:
|
||||
// Linq: 187KB GC/frame;, 2.66ms time
|
||||
// for: 8KB GC/frame; 1.28ms time
|
||||
for (int i = 0; i < m_SyncObjects.Count; ++i)
|
||||
for (int i = 0; i < syncObjects.Count; ++i)
|
||||
{
|
||||
if (m_SyncObjects[i].IsDirty)
|
||||
if (syncObjects[i].IsDirty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -484,9 +486,9 @@ public virtual void OnDeserialize(NetworkReader reader, bool initialState)
|
||||
ulong DirtyObjectBits()
|
||||
{
|
||||
ulong dirtyObjects = 0;
|
||||
for (int i = 0; i < m_SyncObjects.Count; i++)
|
||||
for (int i = 0; i < syncObjects.Count; i++)
|
||||
{
|
||||
SyncObject syncObject = m_SyncObjects[i];
|
||||
SyncObject syncObject = syncObjects[i];
|
||||
if (syncObject.IsDirty)
|
||||
{
|
||||
dirtyObjects |= 1UL << i;
|
||||
@ -498,9 +500,9 @@ ulong DirtyObjectBits()
|
||||
public bool SerializeObjectsAll(NetworkWriter writer)
|
||||
{
|
||||
bool dirty = false;
|
||||
for (int i = 0; i < m_SyncObjects.Count; i++)
|
||||
for (int i = 0; i < syncObjects.Count; i++)
|
||||
{
|
||||
SyncObject syncObject = m_SyncObjects[i];
|
||||
SyncObject syncObject = syncObjects[i];
|
||||
syncObject.OnSerializeAll(writer);
|
||||
dirty = true;
|
||||
}
|
||||
@ -513,9 +515,9 @@ public bool SerializeObjectsDelta(NetworkWriter writer)
|
||||
// write the mask
|
||||
writer.WritePackedUInt64(DirtyObjectBits());
|
||||
// serializable objects, such as synclists
|
||||
for (int i = 0; i < m_SyncObjects.Count; i++)
|
||||
for (int i = 0; i < syncObjects.Count; i++)
|
||||
{
|
||||
SyncObject syncObject = m_SyncObjects[i];
|
||||
SyncObject syncObject = syncObjects[i];
|
||||
if (syncObject.IsDirty)
|
||||
{
|
||||
syncObject.OnSerializeDelta(writer);
|
||||
@ -527,9 +529,9 @@ public bool SerializeObjectsDelta(NetworkWriter writer)
|
||||
|
||||
void DeSerializeObjectsAll(NetworkReader reader)
|
||||
{
|
||||
for (int i = 0; i < m_SyncObjects.Count; i++)
|
||||
for (int i = 0; i < syncObjects.Count; i++)
|
||||
{
|
||||
SyncObject syncObject = m_SyncObjects[i];
|
||||
SyncObject syncObject = syncObjects[i];
|
||||
syncObject.OnDeserializeAll(reader);
|
||||
}
|
||||
}
|
||||
@ -537,9 +539,9 @@ void DeSerializeObjectsAll(NetworkReader reader)
|
||||
void DeSerializeObjectsDelta(NetworkReader reader)
|
||||
{
|
||||
ulong dirty = reader.ReadPackedUInt64();
|
||||
for (int i = 0; i < m_SyncObjects.Count; i++)
|
||||
for (int i = 0; i < syncObjects.Count; i++)
|
||||
{
|
||||
SyncObject syncObject = m_SyncObjects[i];
|
||||
SyncObject syncObject = syncObjects[i];
|
||||
if ((dirty & (1UL << i)) != 0)
|
||||
{
|
||||
syncObject.OnDeserializeDelta(reader);
|
||||
|
Loading…
Reference in New Issue
Block a user