mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 22:55:42 +00:00
Track VP_OBJECT_DATA
This commit is contained in:
parent
ec35a7a13d
commit
80f30b36bb
@ -49,6 +49,8 @@ public abstract class VirtualParadiseObject : IEquatable<VirtualParadiseObject>
|
||||
/// <value>The owner of this object.</value>
|
||||
public VirtualParadiseUser Owner { get; internal set; } = null!;
|
||||
|
||||
internal byte[] Data { get; set; } = Array.Empty<byte>();
|
||||
|
||||
private protected VirtualParadiseClient Client { get; }
|
||||
|
||||
/// <summary>
|
||||
@ -240,6 +242,7 @@ public abstract class VirtualParadiseObject : IEquatable<VirtualParadiseObject>
|
||||
Location = virtualParadiseObject.Location;
|
||||
ModificationTimestamp = virtualParadiseObject.ModificationTimestamp;
|
||||
Owner = virtualParadiseObject.Owner;
|
||||
Data = virtualParadiseObject.Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -272,5 +275,6 @@ public abstract class VirtualParadiseObject : IEquatable<VirtualParadiseObject>
|
||||
/// <param name="data">A span of bytes containing the object data.</param>
|
||||
protected virtual void ExtractFromData(ReadOnlySpan<byte> data)
|
||||
{
|
||||
Data = data.ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using VpSharp.Extensions;
|
||||
using VpSharp.Internal;
|
||||
using static VpSharp.Internal.NativeAttributes.DataAttribute;
|
||||
using static VpSharp.Internal.NativeAttributes.FloatAttribute;
|
||||
using static VpSharp.Internal.NativeAttributes.IntegerAttribute;
|
||||
using static VpSharp.Internal.NativeMethods;
|
||||
@ -57,6 +58,8 @@ public abstract class VirtualParadiseObjectBuilder
|
||||
/// <value>The rotation of the object, or <see langword="null" /> to leave unchanged.</value>
|
||||
public Optional<Quaternion> Rotation { get; set; }
|
||||
|
||||
internal Optional<IReadOnlyList<byte>> Data { get; set; }
|
||||
|
||||
private protected VirtualParadiseClient Client { get; }
|
||||
|
||||
private protected ObjectBuilderMode Mode { get; }
|
||||
@ -69,6 +72,21 @@ public abstract class VirtualParadiseObjectBuilder
|
||||
ApplyRotation();
|
||||
ApplyModificationTimestamp();
|
||||
ApplyOwner();
|
||||
ApplyData();
|
||||
}
|
||||
|
||||
private void ApplyData()
|
||||
{
|
||||
nint handle = Client.NativeInstanceHandle;
|
||||
if (Data.HasValue)
|
||||
{
|
||||
IReadOnlyList<byte> data = Data.Value!;
|
||||
_ = vp_data_set(handle, ObjectData, data.Count, data.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = vp_data_set(handle, ObjectData, 0, Array.Empty<byte>());
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyOwner()
|
||||
|
@ -239,6 +239,8 @@ public sealed class VirtualParadiseParticleEmitterObject : VirtualParadiseObject
|
||||
/// <inheritdoc />
|
||||
protected override void ExtractFromData(ReadOnlySpan<byte> data)
|
||||
{
|
||||
base.ExtractFromData(data);
|
||||
|
||||
#pragma warning disable 612
|
||||
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
PropertyInfo[] properties = typeof(VirtualParadiseParticleEmitterObject).GetProperties(bindingFlags);
|
||||
|
@ -42,6 +42,8 @@ public sealed class VirtualParadisePathObject : VirtualParadiseObject
|
||||
/// <inheritdoc />
|
||||
protected override void ExtractFromData(ReadOnlySpan<byte> data)
|
||||
{
|
||||
base.ExtractFromData(data);
|
||||
|
||||
Span<char> chars = stackalloc char[data.Length];
|
||||
Encoding.UTF8.GetChars(data, chars);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user