PSO2SERVER/Server/Protocol/Packets/08-SpawnPacket/08-09-EventSpawnPacket.cs

81 lines
2.5 KiB
C#
Raw Normal View History

2024-09-18 03:47:04 +08:00
using PSO2SERVER.Models;
2024-12-06 22:06:01 +08:00
using PSO2SERVER.Zone;
2024-09-18 03:47:04 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
2024-12-06 22:06:01 +08:00
using static PSO2SERVER.Models.PSOObject;
2024-09-18 03:47:04 +08:00
namespace PSO2SERVER.Protocol.Packets
2024-09-18 03:47:04 +08:00
{
public class EventSpawnPacket : Packet
{
2024-12-06 22:06:01 +08:00
public readonly PSOObject _obj;
public ObjectHeader objHeader { get; set; } = new ObjectHeader();
public PSOLocation objPosition { get; set; } = new PSOLocation();
public ushort unk1 { get; set; } = 0;
public string objName { get; set; } = string.Empty;
public uint unk3 { get; set; } = 0;
public byte[] unk4 { get; set; } = new byte[0x0C];
public ushort unk5 { get; set; } = 0;
public ushort unk6 { get; set; } = 0;
public uint unk7 { get; set; } = 0;
public uint unk8 { get; set; } = 0;
public uint unk9 { get; set; } = 0;
public uint unk10 { get; set; } = 0;
public uint unk11 { get; set; } = 0;
public uint unk12 { get; set; } = 0;
public uint unk13 { get; set; } = 0;
public uint unk14 { get; set; } = 0;
public uint flags { get; set; } = 0;
/// Event data.
public List<uint> data { get; set; } = new List<uint>();
2024-09-18 03:47:04 +08:00
2024-12-06 22:06:01 +08:00
public EventSpawnPacket(PSOObject obj)
2024-09-18 03:47:04 +08:00
{
2024-12-06 22:06:01 +08:00
objHeader = obj.Header;
objPosition = obj.Position;
objName = obj.Name;
flags = 4;
_obj = obj;
2024-09-18 03:47:04 +08:00
}
#region implemented abstract members of Packet
public override byte[] Build()
{
var pkt = new PacketWriter();
2024-12-06 22:06:01 +08:00
pkt.WriteStruct(objHeader);
pkt.WritePosition(objPosition);
pkt.Write(unk1); // Padding?
pkt.WriteFixedLengthASCII(objName, 0x20);
pkt.Write(unk3);
pkt.Write(unk4);
pkt.Write(unk5);
pkt.Write(unk6);
pkt.Write(unk7);
pkt.Write(unk8);
pkt.Write(unk9);
pkt.Write(unk10);
pkt.Write(unk11);
pkt.Write(unk12);
pkt.Write(unk13);
pkt.Write(unk14);
pkt.Write(flags);
pkt.Write(_obj.Things.Length);
foreach (PSOObjectThing thing in _obj.Things)
{
pkt.WriteStruct(thing);
}
2024-09-18 03:47:04 +08:00
return pkt.ToArray();
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x08, 0x09, PacketFlags.None);
}
#endregion
}
}