public void ReadDelta(Stream stream, bool keepDirtyDelta) => ReadField(stream, keepDirtyDelta); //The NetworkedVar is built for simple data types and has no delta. /// <inheritdoc /> public void SetNetworkedBehaviour(NetworkedBehaviour behaviour) { networkedBehaviour = behaviour; }
internal static void HandleNetworkedVarUpdate(List <INetworkedVar> networkedVarList, Stream stream, uint clientId, NetworkedBehaviour logInstance) { using (PooledBitReader reader = PooledBitReader.Get(stream)) { for (int i = 0; i < networkedVarList.Count; i++) { if (!reader.ReadBool()) { continue; } if (NetworkingManager.Singleton.IsServer && !networkedVarList[i].CanClientWrite(clientId)) { //This client wrote somewhere they are not allowed. This is critical //We can't just skip this field. Because we don't actually know how to dummy read //That is, we don't know how many bytes to skip. Because the interface doesn't have a //Read that gives us the value. Only a Read that applies the value straight away //A dummy read COULD be added to the interface for this situation, but it's just being too nice. //This is after all a developer fault. A critical error should be fine. // - TwoTen if (LogHelper.CurrentLogLevel <= LogLevel.Error) { LogHelper.LogError("Client wrote to NetworkedVar without permission. No more variables can be read. This is critical. " + (logInstance != null ? ("NetworkId: " + logInstance.NetworkId + " BehaviourIndex: " + logInstance.NetworkedObject.GetOrderIndex(logInstance) + " VariableIndex: " + i) : string.Empty)); } return; } networkedVarList[i].ReadField(stream); } } }