PSO2SERVER/Server/Protocol/Packets/08-SpawnPacket/08-0B-ObjectSpawnPacket.cs

47 lines
1.3 KiB
C#
Raw Normal View History

using Org.BouncyCastle.Utilities;
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using static PSO2SERVER.Models.PSOObject;
namespace PSO2SERVER.Protocol.Packets
{
public class ObjectSpawnPacket : Packet
{
private readonly PSOObject _obj;
public ObjectSpawnPacket(PSOObject obj)
{
_obj = obj;
}
#region implemented abstract members of Packet
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.WriteStruct(_obj.Header);
2024-09-21 09:23:14 +08:00
writer.WritePosition(_obj.Position);
writer.Seek(2, SeekOrigin.Current); // Padding I guess...
writer.WriteFixedLengthASCII(_obj.Name, 0x34);
writer.Write(_obj.ThingFlag);
writer.Write(_obj.Things.Length);
foreach (PSOObjectThing thing in _obj.Things)
{
writer.WriteStruct(thing);
}
return writer.ToArray();
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x08, 0x0B, PacketFlags.None);
}
#endregion
}
}