mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 22:55:42 +00:00
Extract updated properties after modifying object
This commit is contained in:
parent
7422a663af
commit
c58fe6a2a3
@ -82,6 +82,34 @@ public class VirtualParadiseModelObject : VirtualParadiseObject
|
||||
{
|
||||
throw new VirtualParadiseException(result);
|
||||
}
|
||||
|
||||
ExtractFromBuilder(builder);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected internal override void ExtractFromBuilder(VirtualParadiseObjectBuilder builder)
|
||||
{
|
||||
if (builder is not VirtualParadiseModelObjectBuilder modelObjectBuilder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.ExtractFromBuilder(builder);
|
||||
|
||||
if (modelObjectBuilder.Model.HasValue)
|
||||
{
|
||||
Model = modelObjectBuilder.Model.Value!;
|
||||
}
|
||||
|
||||
if (modelObjectBuilder.Description.HasValue)
|
||||
{
|
||||
Description = modelObjectBuilder.Description.Value!;
|
||||
}
|
||||
|
||||
if (modelObjectBuilder.Action.HasValue)
|
||||
{
|
||||
Action = modelObjectBuilder.Action.Value!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System.Numerics;
|
||||
using VpSharp.Exceptions;
|
||||
using VpSharp.Extensions;
|
||||
using VpSharp.Internal;
|
||||
using VpSharp.Internal.NativeAttributes;
|
||||
using X10D.Numerics;
|
||||
@ -232,6 +231,46 @@ public abstract class VirtualParadiseObject : IEquatable<VirtualParadiseObject>
|
||||
return $"Object {Id}; Owner {Owner}; Location {Location}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the object by extracting the values provided by a specified <see cref="VirtualParadiseObjectBuilder" />.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder whose values to extract.</param>
|
||||
protected internal virtual void ExtractFromBuilder(VirtualParadiseObjectBuilder builder)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(builder);
|
||||
|
||||
Location location = Location;
|
||||
Vector3d position = location.Position;
|
||||
Quaternion rotation = location.Rotation;
|
||||
|
||||
if (builder.Position.HasValue)
|
||||
{
|
||||
position = builder.Position.Value;
|
||||
}
|
||||
|
||||
if (builder.Rotation.HasValue)
|
||||
{
|
||||
rotation = builder.Rotation.Value;
|
||||
}
|
||||
|
||||
Location = new Location(location.World, position, rotation);
|
||||
|
||||
if (builder.Data.HasValue)
|
||||
{
|
||||
Data = builder.Data.Value!.ToArray();
|
||||
}
|
||||
|
||||
if (builder.ModificationTimestamp.HasValue)
|
||||
{
|
||||
ModificationTimestamp = builder.ModificationTimestamp.Value;
|
||||
}
|
||||
|
||||
if (builder.Owner.HasValue)
|
||||
{
|
||||
Owner = builder.Owner.Value!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the properties from another object into this object.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user