simplify OnSerialize

This commit is contained in:
vis2k 2022-01-06 12:25:13 +08:00
parent f77396b404
commit 90ee471bb8

View File

@ -574,20 +574,10 @@ protected void SetSyncVar<T>(T value, ref T fieldValue, ulong dirtyBit)
// note: SyncVar hooks are only called when inital=false
public virtual bool OnSerialize(NetworkWriter writer, bool initialState)
{
bool objectWritten = false;
// if initialState: write all SyncVars.
// otherwise write dirtyBits+dirty SyncVars
if (initialState)
{
objectWritten = SerializeObjectsAll(writer);
}
else
{
objectWritten = SerializeObjectsDelta(writer);
}
bool objectWritten = initialState ? SerializeObjectsAll(writer) : SerializeObjectsDelta(writer);
bool syncVarWritten = SerializeSyncVars(writer, initialState);
return objectWritten || syncVarWritten;
}