Select the default combat mode from ordered equipped objects so bows request missile stance. Parse CreateObject parent metadata and ParentEvent, then render held objects as separate children composed from setup holding locations and placement frames each animation tick.
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using System.Buffers.Binary;
|
|
|
|
namespace AcDream.Core.Net.Messages;
|
|
|
|
/// <summary>
|
|
/// Inbound retail <c>ParentEvent</c> (<c>0xF749</c>): attach a child physics
|
|
/// object (weapon, shield, ammunition) to a named holding location on a
|
|
/// parent creature and apply the child's placement frame.
|
|
///
|
|
/// Wire oracle: <c>CM_Physics::DispatchSB_ParentEvent @ 0x006ACAF0</c>.
|
|
/// Runtime oracle: <c>SmartBox::HandleParentEvent @ 0x004535D0</c> and
|
|
/// <c>SmartBox::DoParentEvent @ 0x00452290</c>.
|
|
/// </summary>
|
|
public static class ParentEvent
|
|
{
|
|
public const uint Opcode = 0xF749u;
|
|
|
|
public readonly record struct Parsed(
|
|
uint ParentGuid,
|
|
uint ChildGuid,
|
|
uint ParentLocation,
|
|
uint PlacementId,
|
|
ushort ParentInstanceSequence,
|
|
ushort ChildPositionSequence);
|
|
|
|
public static Parsed? TryParse(ReadOnlySpan<byte> body)
|
|
{
|
|
if (body.Length < 24)
|
|
return null;
|
|
|
|
if (BinaryPrimitives.ReadUInt32LittleEndian(body) != Opcode)
|
|
return null;
|
|
|
|
return new Parsed(
|
|
BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(4, 4)),
|
|
BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(8, 4)),
|
|
BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(12, 4)),
|
|
BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(16, 4)),
|
|
BinaryPrimitives.ReadUInt16LittleEndian(body.Slice(20, 2)),
|
|
BinaryPrimitives.ReadUInt16LittleEndian(body.Slice(22, 2)));
|
|
}
|
|
}
|