// using FishNet.Object.Synchronizing; // using FishNet.Object.Synchronizing.Internal; // using FishNet.Serializing; // using Types.Items; // // public class SyncGameItem : SyncBase, ICustomSync // { // private GameItem _gameItem; // // public GameItem GameItem // { // get => _gameItem; // set // { // if (_gameItem != value) // { // _gameItem = value; // Dirty(); // } // } // } // // public object GetSerializedType() // { // return typeof(GameItem); // } // // public void WriteFull(Writer writer) // { // writer.WriteInt32(_gameItem ? _gameItem.ID : -1); // if (_gameItem != null) writer.WriteInt32(_gameItem.Quantity); // // Write other necessary fields... // } // // protected override void WriteDelta(PooledWriter writer, bool resetSyncTick = true) // { // base.WriteDelta(writer, resetSyncTick); // WriteGameItem(writer, _gameItem); // } // // public void WriteGameItem(PooledWriter writer, GameItem gameItem) // { // if (gameItem is WeaponItem) // writer.WriteByte(1); // else if (gameItem is EquipmentItem) // writer.WriteByte(2); // else if (gameItem is ResourceItem) // writer.WriteByte(3); // else if (gameItem is CropItem) // writer.WriteByte(4); // else if (gameItem is ConsumableItem) // writer.WriteByte(5); // else if (gameItem is SeedItem) // writer.WriteByte(6); // else if (gameItem is KeyItem) // writer.WriteByte(7); // else if (gameItem is ToolItem) // writer.WriteByte(8); // else // writer.WriteByte(0); // // // writer.WriteInt32(gameItem ? gameItem.ID : -1); // if (gameItem != null) writer.WriteInt32(gameItem.Quantity); // // Write other necessary fields... // } // // // public static GameItem ReadGameItem(Reader reader) // { // var type = reader.ReadByte(); // // if (type == 0) // return null; // if (type == 1) return reader.Read(); // if (type == 2) return reader.Read(); // if (type == 3) return reader.Read(); // if (type == 4) return reader.Read(); // if (type == 5) return reader.Read(); // if (type == 6) return reader.Read(); // if (type == 7) return reader.Read(); // if (type == 8) return reader.Read(); // // return null; // /*var id = reader.ReadInt32(); // if (id != -1) // { // _gameItem = ItemDatabase.Instance.GetItemById(id); // if (_gameItem != null) _gameItem.quantity = reader.ReadInt32(); // // Read other necessary fields... // } // else // { // _gameItem = null; // } // // Invoke any necessary callbacks*/ // } // }