diff --git a/VpSharp/src/Entities/VirtualParadiseModelObject.cs b/VpSharp/src/Entities/VirtualParadiseModelObject.cs index 729e889..abc1937 100644 --- a/VpSharp/src/Entities/VirtualParadiseModelObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseModelObject.cs @@ -82,6 +82,34 @@ public class VirtualParadiseModelObject : VirtualParadiseObject { throw new VirtualParadiseException(result); } + + ExtractFromBuilder(builder); + } + + /// + 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!; + } } /// diff --git a/VpSharp/src/Entities/VirtualParadiseObject.cs b/VpSharp/src/Entities/VirtualParadiseObject.cs index 5567513..486e507 100644 --- a/VpSharp/src/Entities/VirtualParadiseObject.cs +++ b/VpSharp/src/Entities/VirtualParadiseObject.cs @@ -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 return $"Object {Id}; Owner {Owner}; Location {Location}"; } + /// + /// Updates the object by extracting the values provided by a specified . + /// + /// The builder whose values to extract. + 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!; + } + } + /// /// Copies the properties from another object into this object. ///