2024-12-08 11:33:06 +08:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Org.BouncyCastle.Utilities;
|
2024-09-18 00:55:35 +08:00
|
|
|
|
using PSO2SERVER.Models;
|
2024-12-06 21:49:29 +08:00
|
|
|
|
using PSO2SERVER.Zone;
|
2024-09-18 00:55:35 +08:00
|
|
|
|
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;
|
|
|
|
|
|
2024-11-27 18:05:53 +08:00
|
|
|
|
namespace PSO2SERVER.Protocol.Packets
|
2024-09-18 00:55:35 +08:00
|
|
|
|
{
|
|
|
|
|
public class ObjectSpawnPacket : Packet
|
|
|
|
|
{
|
2024-12-06 22:06:01 +08:00
|
|
|
|
public readonly PSOObject _obj;
|
2024-12-08 11:33:06 +08:00
|
|
|
|
[JsonProperty("object")]
|
2024-12-06 21:49:29 +08:00
|
|
|
|
public ObjectHeader objHeader { get; set; } = new ObjectHeader();
|
2024-12-08 11:33:06 +08:00
|
|
|
|
[JsonProperty("position")]
|
2024-12-06 21:49:29 +08:00
|
|
|
|
public PSOLocation objPosition { get; set; } = new PSOLocation();
|
|
|
|
|
public ushort unk1 { get; set; } = 0;
|
2024-12-08 11:33:06 +08:00
|
|
|
|
/// Enemy name.
|
|
|
|
|
[JsonProperty("name")]
|
2024-12-06 21:49:29 +08:00
|
|
|
|
public string objName { get; set; } = string.Empty;//0x20
|
2024-12-06 22:06:01 +08:00
|
|
|
|
public uint[] unk2 { get; set; } = new uint[0x05];
|
|
|
|
|
public uint flags { get; set; } = 0;
|
|
|
|
|
public List<uint> data { get; set; } = new List<uint>();
|
2024-12-06 21:49:29 +08:00
|
|
|
|
|
2024-09-18 00:55:35 +08:00
|
|
|
|
public ObjectSpawnPacket(PSOObject obj)
|
|
|
|
|
{
|
2024-12-06 21:49:29 +08:00
|
|
|
|
objHeader = obj.Header;
|
|
|
|
|
objPosition = obj.Position;
|
|
|
|
|
objName = obj.Name;
|
2024-12-06 22:06:01 +08:00
|
|
|
|
flags = 4;
|
|
|
|
|
_obj = obj;
|
2024-09-18 00:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-08 11:33:06 +08:00
|
|
|
|
public ObjectSpawnPacket()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-18 00:55:35 +08:00
|
|
|
|
#region implemented abstract members of Packet
|
|
|
|
|
|
|
|
|
|
public override byte[] Build()
|
|
|
|
|
{
|
2024-12-06 21:49:29 +08:00
|
|
|
|
PacketWriter pkt = new PacketWriter();
|
2024-12-10 01:23:49 +08:00
|
|
|
|
objHeader.WriteObjectHeaderToStream(pkt);
|
2024-12-06 21:49:29 +08:00
|
|
|
|
pkt.WritePosition(objPosition);
|
|
|
|
|
pkt.Write(unk1); // Padding?
|
|
|
|
|
pkt.WriteFixedLengthASCII(objName, 0x20);
|
2024-12-11 20:47:36 +08:00
|
|
|
|
pkt.WriteIntArray(unk2);
|
2024-12-06 22:06:01 +08:00
|
|
|
|
pkt.Write(flags);
|
|
|
|
|
pkt.Write(_obj.Things.Length);
|
|
|
|
|
foreach (PSOObjectThing thing in _obj.Things)
|
|
|
|
|
{
|
|
|
|
|
pkt.WriteStruct(thing);
|
|
|
|
|
}
|
2024-12-06 21:49:29 +08:00
|
|
|
|
|
|
|
|
|
return pkt.ToArray();
|
2024-09-18 00:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override PacketHeader GetHeader()
|
|
|
|
|
{
|
2024-12-06 22:06:01 +08:00
|
|
|
|
return new PacketHeader(0x08, 0x0B, PacketFlags.None);
|
2024-09-18 00:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|