mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* ACE.DatLoader: XpTable updated * ACE.DatLoader physics and environment using new unpack pattern * ACE.DatLoader ContractTable updated to IUnpackable * ACE.DatLoader EnvCell refactored to new IUnpackable * Update PackableExtensions.cs
90 lines
3 KiB
C#
90 lines
3 KiB
C#
using System.IO;
|
|
|
|
namespace ACE.DatLoader.Entity
|
|
{
|
|
/// <summary>
|
|
/// Helper function to read position data from dat files
|
|
/// </summary>
|
|
public static class PositionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Reads just the X,Y,Z portion of a Position
|
|
/// </summary>
|
|
public static void ReadFrameOnly(this ACE.Entity.Position p, BinaryReader reader)
|
|
{
|
|
p.PositionX = reader.ReadSingle();
|
|
p.PositionY = reader.ReadSingle();
|
|
p.PositionZ = reader.ReadSingle();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads a full spatial position with X,Y,Z and Quaternion W,X,Y,Z values.
|
|
/// </summary>
|
|
public static void Read(this ACE.Entity.Position p, BinaryReader reader)
|
|
{
|
|
p.PositionX = reader.ReadSingle();
|
|
p.PositionY = reader.ReadSingle();
|
|
p.PositionZ = reader.ReadSingle();
|
|
p.RotationW = reader.ReadSingle();
|
|
p.RotationX = reader.ReadSingle();
|
|
p.RotationY = reader.ReadSingle();
|
|
p.RotationZ = reader.ReadSingle();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads the cell ID and the full spatial position with X,Y,Z and Quaternion W,X,Y,Z values.
|
|
/// </summary>
|
|
public static void ReadWithCell(this ACE.Entity.Position p, BinaryReader reader)
|
|
{
|
|
p.Cell = reader.ReadUInt32();
|
|
p.PositionX = reader.ReadSingle();
|
|
p.PositionY = reader.ReadSingle();
|
|
p.PositionZ = reader.ReadSingle();
|
|
p.RotationW = reader.ReadSingle();
|
|
p.RotationX = reader.ReadSingle();
|
|
p.RotationY = reader.ReadSingle();
|
|
p.RotationZ = reader.ReadSingle();
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Reads and returns a full spatial position with X,Y,Z and Quaternion W,X,Y,Z values.
|
|
/// </summary>
|
|
[System.Obsolete]
|
|
public static ACE.Entity.Position ReadPosition(DatReader datReader)
|
|
{
|
|
var p = new ACE.Entity.Position();
|
|
p.Read(datReader);
|
|
return p;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads and returns just the X,Y,Z portal of a Position
|
|
/// </summary>
|
|
[System.Obsolete]
|
|
public static ACE.Entity.Position ReadPositionFrame(DatReader datReader)
|
|
{
|
|
var p = new ACE.Entity.Position();
|
|
|
|
p.PositionX = datReader.ReadSingle();
|
|
p.PositionY = datReader.ReadSingle();
|
|
p.PositionZ = datReader.ReadSingle();
|
|
|
|
return p;
|
|
}
|
|
|
|
[System.Obsolete]
|
|
private static void Read(this ACE.Entity.Position p, DatReader datReader)
|
|
{
|
|
p.PositionX = datReader.ReadSingle();
|
|
p.PositionY = datReader.ReadSingle();
|
|
p.PositionZ = datReader.ReadSingle();
|
|
p.RotationW = datReader.ReadSingle();
|
|
p.RotationX = datReader.ReadSingle();
|
|
p.RotationY = datReader.ReadSingle();
|
|
p.RotationZ = datReader.ReadSingle();
|
|
}
|
|
}
|
|
}
|