本文整理汇总了C#中PacketReader.ReadStruct方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadStruct方法的具体用法?C# PacketReader.ReadStruct怎么用?C# PacketReader.ReadStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadStruct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEnterSceneInfo
void OnEnterSceneInfo(NetState netstate, PacketReader reader)
{
var p1 = reader.ReadStruct <DogSE.Common.Vector3>();
var p2 = reader.ReadStruct <DogSE.Common.Vector3>();
module.OnEnterSceneInfo(p1,p2);
}
示例2: OnSpriteMove
void OnSpriteMove(NetState netstate, PacketReader reader)
{
var p1 = reader.ReadInt32();
var p2 = reader.ReadStruct <DogSE.Common.Vector3>();
var p3 = reader.ReadStruct <DogSE.Common.Vector3>();
module.OnSpriteMove(p1,p2,p3);
}
示例3: Read
public static TradeAge.Client.Entity.Character.SimplePlayer Read(PacketReader reader)
{
TradeAge.Client.Entity.Character.SimplePlayer ret = new TradeAge.Client.Entity.Character.SimplePlayer();
ret.Name = reader.ReadUTF8String();
ret.Postion = reader.ReadStruct <DogSE.Common.Vector3>();
ret.Direction = reader.ReadStruct <DogSE.Common.Vector3>();
ret.Id = reader.ReadInt32();
ret.AccountId = reader.ReadInt32();
ret.Sex = (TradeAge.Client.Entity.Character.Sex)reader.ReadByte();
return ret;
}
示例4: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
PacketReader reader = new PacketReader(data);
reader.ReadBytes(12); // Padding MAYBE???????????
ObjectHeader srcObject = reader.ReadStruct<ObjectHeader>();
byte[] someBytes = reader.ReadBytes(4); // Dunno what this is yet.
ObjectHeader dstObject = reader.ReadStruct<ObjectHeader>(); // Could be wrong
reader.ReadBytes(16); // Not sure what this is yet
string command = reader.ReadAscii(0xD711, 0xCA);
PSOObject srcObj;
if(srcObject.EntityType == EntityType.Object)
{
srcObj = ObjectManager.Instance.getObjectByID(context.CurrentZone.Name, srcObject.ID);
}
else if(srcObject.EntityType == EntityType.Player)
{
srcObj = new PSOObject();
srcObj.Header = srcObject;
srcObj.Name = "Player";
}
else
{
srcObj = null;
}
Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.Name, srcObj.Header.ID, command, (EntityType)dstObject.EntityType, dstObject.ID);
// TODO: Delete this code and do this COMPLETELY correctly!!!
if (command == "Transfer" && context.CurrentZone.Name == "lobby")
{
// Try and get the teleport definition for the object...
using (var db = new PolarisEf())
{
db.Configuration.AutoDetectChangesEnabled = true;
var teleporterEndpoint = db.Teleports.Find("lobby", (int)srcObject.ID);
if (teleporterEndpoint == null)
{
Logger.WriteError("[OBJ] Teleporter for {0} in {1} does not contain a destination!", srcObj.Header.ID, "lobby");
// Teleport Player to default point
context.SendPacket(new TeleportTransferPacket(srcObj, new PSOLocation(0f, 1f, 0f, -0.000031f, -0.417969f, 0.000031f, 134.375f)));
// Unhide player
context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
}
else
{
PSOLocation endpointLocation = new PSOLocation()
{
RotX = teleporterEndpoint.RotX,
RotY = teleporterEndpoint.RotY,
RotZ = teleporterEndpoint.RotZ,
RotW = teleporterEndpoint.RotW,
PosX = teleporterEndpoint.PosX,
PosY = teleporterEndpoint.PosY,
PosZ = teleporterEndpoint.PosZ,
};
// Teleport Player
context.SendPacket(new TeleportTransferPacket(srcObj, endpointLocation));
// Unhide player
context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded"));
}
}
}
if (command == "READY")
{
context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
new ObjectHeader(), "FavsNeutral"));
context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header,
new ObjectHeader(), "AP")); // Short for Appear, Thanks Zapero!
}
if (command == "Sit")
{
foreach (var client in Server.Instance.Clients)
{
if (client.Character == null || client == context)
continue;
client.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)client.User.PlayerId, EntityType.Player), srcObj.Header,
new ObjectHeader(dstObject.ID, EntityType.Player), new ObjectHeader(), "SitSuccess"));
}
}
}
示例5: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
PacketReader reader = new PacketReader(data);
FullMovementData movData = reader.ReadStruct<FullMovementData>();
if (movData.entity1.ID == 0 && movData.entity2.ID != 0)
movData.entity1 = movData.entity2;
movData.timestamp = 0;
// This could be simplified
PacketWriter writer = new PacketWriter();
writer.WriteStruct(movData);
Logger.WriteInternal("[MOV] {0} stopped moving at ({1}, {2}, {3})", context.Character.Name,
Helper.FloatFromHalfPrecision(movData.currentPos.x), Helper.FloatFromHalfPrecision(movData.currentPos.y),
Helper.FloatFromHalfPrecision(movData.currentPos.z));
foreach (var c in Server.Instance.Clients)
{
if (c == context || c.Character == null || c.CurrentZone != context.CurrentZone)
continue;
c.SendPacket(0x04, 0x71, 0x40, writer.ToArray());
}
}