using System;
using System.Buffers.Binary;
namespace AcDream.Core.Net.Messages;
///
/// Inbound InventoryRemoveObject (0x0024) — a top-level GameMessage (UIQueue),
/// NOT a GameEvent. The server tells the client an object left its inventory view
/// (given away / sold / destroyed). The client drops it from object maintenance.
///
/// Wire layout (ACE GameMessageInventoryRemoveObject.cs, size hint 8):
///
/// u32 opcode = 0x0024
/// u32 guid
///
///
public static class InventoryRemoveObject
{
public const uint Opcode = 0x0024u;
public readonly record struct Parsed(uint Guid);
/// Parse a raw 0x0024 body. Returns null on opcode mismatch / truncation.
public static Parsed? TryParse(ReadOnlySpan body)
{
if (body.Length < 8) return null; // 4 + 4
if (BinaryPrimitives.ReadUInt32LittleEndian(body) != Opcode) return null;
uint guid = BinaryPrimitives.ReadUInt32LittleEndian(body[4..]);
return new Parsed(guid);
}
}