示例#1
0
 public void OnRecieved()
 {
     if (!DotCatalog.TryGetDef(this.dotIndex, out var def))
     {
         Log.Fatal("Unregistered dot type recieved in message. This is going to cause desync and you should maybe just close the game now?");
         return;
     }
     def.Apply(this.target, this.bytes);
 }
示例#2
0
        public void Deserialize(NetworkReader reader)
        {
            this.dotIndex = (DotCatalog.Index)reader.ReadUInt64();
            if (!DotCatalog.TryGetDef(this.dotIndex, out var def))
            {
                Log.Fatal($"Unable to find dot with index {this.dotIndex}, this indicates that you are experiencing serious desync and need to stop playing. Crashes are likely");
                return;
            }
            var id = reader.ReadNetworkIdentity();

            this.bytes = def.tempStackSizedArray;
            var l = reader.ReadUInt16();

            if (!id || id.GetComponent <CharacterBody>() is not CharacterBody body || !body)
            {
                Log.Fatal("No matching networkidentity found. This indicates some kind of desync is going on and you should maybe end your run now.");
                return;
            }
            this.target = body;

            if (l != this.bytes.Length)
            {
                Log.Fatal("Mismatched buffer sizes for sent dot info. Ensure everyone is on the same version. This is a fatal error, meaning that there is zero way to recover internally, you should close your game.");
                return;
            }

            if (this.bytes is null)
            {
                Log.Fatal("Unregistered dot type recieved in message. This is going to cause desync and you should maybe just close the game now?");
                return;
            }
            for (Int32 i = 0; i < this.bytes.Length; ++i)
            {
                this.bytes[i] = reader.ReadByte();
            }
        }