From 399f2b6042c6d7ae8fdd910242f3b923f5dbdbe2 Mon Sep 17 00:00:00 2001 From: Borys Stelmakh Date: Sun, 7 Sep 2025 16:36:27 +0400 Subject: [PATCH 1/4] Added syncRotation param to DynamicObject --- src/SampSharp.Streamer.Entities/Components/DynamicObject.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs b/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs index 98b3244..a1d2de0 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs @@ -149,14 +149,15 @@ public void AttachCameraTo(EntityId player) /// The dynamic object, player or vehicle. /// The offset. /// The rotation. - public void AttachTo(EntityId target, Vector3 offset, Vector3 rotation) + /// Synchronize rotation. + public void AttachTo(EntityId target, Vector3 offset, Vector3 rotation, bool syncRotation = true) { if (!target.IsOfAnyType(StreamerEntities.DynamicObjectType, SampEntities.PlayerType, SampEntities.VehicleType)) throw new InvalidEntityArgumentException(nameof(target), StreamerEntities.DynamicObjectType, SampEntities.PlayerType, SampEntities.VehicleType); if (target.IsOfType(StreamerEntities.DynamicObjectType)) GetComponent().AttachDynamicObjectToObject(target, offset.X, offset.Y, offset.Z, - rotation.X, rotation.Y, rotation.Z); + rotation.X, rotation.Y, rotation.Z, Convert.ToInt32(syncRotation)); else if (target.IsOfType(SampEntities.PlayerType)) GetComponent().AttachDynamicObjectToPlayer(target, offset.X, offset.Y, offset.Z, rotation.X, rotation.Y, rotation.Z); From 4ebe4e11100576b195a688c769298f562cb31361 Mon Sep 17 00:00:00 2001 From: Borys Stelmakh Date: Sat, 4 Apr 2026 15:22:59 +0400 Subject: [PATCH 2/4] Fix: add missing syncrotation param to AttachDynamicObjectToObject native signature --- .../NativeComponents/NativeDynamicObject.cs | 252 +++++++----------- 1 file changed, 96 insertions(+), 156 deletions(-) diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicObject.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicObject.cs index 158a127..58d1a81 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicObject.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicObject.cs @@ -16,160 +16,100 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicObject : BaseNativeComponent { - public class NativeDynamicObject : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; - - [NativeMethod] - public virtual bool IsValidDynamicObject() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool DestroyDynamicObject() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetDynamicObjectPos(out float x, out float y, out float z) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int SetDynamicObjectPos(float x, float y, float z) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetDynamicObjectRot(out float rx, out float ry, out float rz) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int SetDynamicObjectRot(float rx, float ry, float rz) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public bool GetDynamicObjectNoCameraCol() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public bool SetDynamicObjectNoCameraCol() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int MoveDynamicObject(float x, float y, float z, float speed, float rx, float ry, float rz) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int StopDynamicObject() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool IsDynamicObjectMoving() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int AttachCameraToDynamicObject(int playerid) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int AttachDynamicObjectToObject(int attachtoid, float offsetx, float offsety, float offsetz, - float rx, float ry, float rz, int syncrotation = 1) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int AttachDynamicObjectToPlayer(int playerid, float offsetx, float offsety, - float offsetz, float rx, float ry, float rz) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int AttachDynamicObjectToVehicle(int vehicleid, float offsetx, float offsety, - float offsetz, float rx, float ry, float rz) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool IsDynamicObjectMaterialUsed(int materialindex) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetDynamicObjectMaterial(int materialindex, out int modelid, - out string txdname, out string texturename, out int materialcolor, int maxtxdname, int maxtexturename) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int SetDynamicObjectMaterial(int materialindex, int modelid, string txdname, - string texturename, int materialcolor) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int RemoveDynamicObjectMaterial(int materialindex) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool IsDynamicObjectMaterialTextUsed(int materialindex) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetDynamicObjectMaterialText(int materialindex, out string text, - out int materialsize, out string fontface, out int fontsize, out bool bold, out int fontcolor, - out int backcolor, out int textalignment, int maxtext, int maxfontface) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int SetDynamicObjectMaterialText(int materialindex, string text, - int materialsize, string fontface, int fontsize, bool bold, int fontcolor, int backcolor, - int textalignment) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int RemoveDynamicObjectMaterialText(int materialindex) - { - throw new NativeNotImplementedException(); - } - } -} + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; + + [NativeMethod] + public virtual bool IsValidDynamicObject() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool DestroyDynamicObject() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetDynamicObjectPos(out float x, out float y, out float z) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int SetDynamicObjectPos(float x, float y, float z) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetDynamicObjectRot(out float rx, out float ry, out float rz) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int SetDynamicObjectRot(float rx, float ry, float rz) => throw new NativeNotImplementedException(); + + [NativeMethod] + public bool GetDynamicObjectNoCameraCol() => throw new NativeNotImplementedException(); + + [NativeMethod] + public bool SetDynamicObjectNoCameraCol() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int MoveDynamicObject(float x, float y, float z, float speed, float rx, float ry, float rz) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int StopDynamicObject() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool IsDynamicObjectMoving() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int AttachCameraToDynamicObject(int playerid) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int AttachDynamicObjectToObject(int attachtoid, float offsetx, float offsety, float offsetz, + float rx, float ry, float rz, bool syncrotation = true) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int AttachDynamicObjectToPlayer(int playerid, float offsetx, float offsety, + float offsetz, float rx, float ry, float rz) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int AttachDynamicObjectToVehicle(int vehicleid, float offsetx, float offsety, + float offsetz, float rx, float ry, float rz) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool IsDynamicObjectMaterialUsed(int materialindex) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetDynamicObjectMaterial(int materialindex, out int modelid, + out string txdname, out string texturename, out int materialcolor, int maxtxdname, int maxtexturename) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int SetDynamicObjectMaterial(int materialindex, int modelid, string txdname, + string texturename, int materialcolor) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int RemoveDynamicObjectMaterial(int materialindex) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool IsDynamicObjectMaterialTextUsed(int materialindex) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetDynamicObjectMaterialText(int materialindex, out string text, + out int materialsize, out string fontface, out int fontsize, out bool bold, out int fontcolor, + out int backcolor, out int textalignment, int maxtext, int maxfontface) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int SetDynamicObjectMaterialText(int materialindex, string text, + int materialsize, string fontface, int fontsize, bool bold, int fontcolor, int backcolor, + int textalignment) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int RemoveDynamicObjectMaterialText(int materialindex) => throw new NativeNotImplementedException(); +} \ No newline at end of file From e5f8b052df5d3ed38121c516c40c67f1b9388391 Mon Sep 17 00:00:00 2001 From: Borys Stelmakh Date: Sat, 4 Apr 2026 15:25:13 +0400 Subject: [PATCH 3/4] Migration: update namespace style, TargetFramework to net9.0, fix BaseOutputPath --- Directory.Build.props | 14 +- .../Components/DynamicObject.cs | 423 +++++++++--------- .../SampSharp.Streamer.Entities.csproj | 6 +- .../SampSharp.Streamer.csproj | 4 +- 4 files changed, 225 insertions(+), 222 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6abae0f..e7c7f07 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ - ..\..\bin\$(Configuration)\ + ..\..\bin\ true true @@ -35,7 +35,7 @@ gta samp sampsharp $(AssemblyName) $(AssemblyName) - true + true @@ -74,11 +74,11 @@ snupkg - + true - + @@ -86,4 +86,10 @@ true + + + false + + + diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs b/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs index a1d2de0..00b6c27 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicObject.cs @@ -17,259 +17,254 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic object. +/// +public sealed class DynamicObject : Component { + private DynamicObject() + { + } + + /// + /// Gets whether this dynamic object is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicObject(); + /// - /// Represents a component which provides the data and functionality of an dynamic object. + /// Gets whether this dynamic object is moving. /// - public sealed class DynamicObject : Component + public bool IsMoving => GetComponent().IsDynamicObjectMoving(); + + /// + /// Gets the position of this dynamic object. + /// + public Vector3 Position { - private DynamicObject() + get { + GetComponent().GetDynamicObjectPos(out var x, out var y, out var z); + return new Vector3(x, y, z); + } + set => GetComponent().SetDynamicObjectPos(value.X, value.Y, value.Z); + } + /// + /// Gets the rotation of this dynamic object. + /// + public Vector3 Rotation + { + get + { + GetComponent().GetDynamicObjectRot(out var x, out var y, out var z); + return new Vector3(x, y, z); } + set => GetComponent().SetDynamicObjectRot(value.X, value.Y, value.Z); + } - /// - /// Gets whether this dynamic object is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicObject(); + /// + /// Gets if camera collision of this dynamic object is disabled. + /// + public bool NoCameraCol => GetComponent().GetDynamicObjectNoCameraCol(); - /// - /// Gets whether this dynamic object is moving. - /// - public bool IsMoving => GetComponent().IsDynamicObjectMoving(); + /// + /// Gets whether this dynamic object used material. + /// + public bool IsMaterialUsed(int materialindex) => + GetComponent().IsDynamicObjectMaterialUsed(materialindex); - /// - /// Gets whether this dynamic object used material. - /// - public bool IsMaterialUsed(int materialindex) => GetComponent().IsDynamicObjectMaterialUsed(materialindex); + /// + /// Gets whether this dynamic object used material text. + /// + public bool IsMaterialTextUsed(int materialindex) => + GetComponent().IsDynamicObjectMaterialTextUsed(materialindex); - /// - /// Gets whether this dynamic object used material text. - /// - public bool IsMaterialTextUsed(int materialindex) => GetComponent().IsDynamicObjectMaterialTextUsed(materialindex); + /// + /// Disables camera collision of this dynamic object. + /// + public void SetNoCameraCol() => GetComponent().SetDynamicObjectNoCameraCol(); - /// - /// Gets the position of this dynamic object. - /// - public Vector3 Position - { - get - { - GetComponent().GetDynamicObjectPos(out var x, out var y, out var z); - return new Vector3(x, y, z); - } - set => GetComponent().SetDynamicObjectPos(value.X, value.Y, value.Z); - } + /// + /// Moves this dynamic object to the given position and rotation with the given speed. + /// + /// The position to which to move this dynamic object. + /// The speed at which to move this dynamic object. + /// The rotation to which to move this dynamic object. + /// + /// The time it will take for the object to move in milliseconds. + /// + public int Move(Vector3 position, float speed, Vector3 rotation) + { + return GetComponent().MoveDynamicObject(position.X, position.Y, position.Z, speed, + rotation.X, rotation.Y, rotation.Z); + } - /// - /// Gets the rotation of this dynamic object. - /// - public Vector3 Rotation - { - get - { - GetComponent().GetDynamicObjectRot(out var x, out var y, out var z); - return new Vector3(x, y, z); - } - set => GetComponent().SetDynamicObjectRot(value.X, value.Y, value.Z); - } + /// + /// Moves this dynamic object to the given position with the given speed. + /// + /// The position to which to move this dynamic object. + /// The speed at which to move this dynamic object. + /// + /// The time it will take for the object to move in milliseconds. + /// + public int Move(Vector3 position, float speed) + { + return GetComponent().MoveDynamicObject(position.X, position.Y, position.Z, speed, + -1000, -1000, -1000); + } - /// - /// Gets if camera collision of this dynamic object is disabled. - /// - public bool NoCameraCol - { - get - { - return GetComponent().GetDynamicObjectNoCameraCol(); - } - } + /// + /// Stop this dynamic object from moving any further. + /// + public void Stop() => GetComponent().StopDynamicObject(); - /// - /// Disables camera collision of this dynamic object. - /// - public void SetNoCameraCol() + /// + /// Attaches camera to the specified dynamic object. + /// + /// The player. + public void AttachCameraTo(EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) { - GetComponent().SetDynamicObjectNoCameraCol(); + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); } - /// - /// Moves this dynamic object to the given position and rotation with the given speed. - /// - /// The position to which to move this dynamic object. - /// The speed at which to move this dynamic object. - /// The rotation to which to move this dynamic object. - /// - /// The time it will take for the object to move in milliseconds. - /// - public int Move(Vector3 position, float speed, Vector3 rotation) - { - return GetComponent().MoveDynamicObject(position.X, position.Y, position.Z, speed, - rotation.X, rotation.Y, rotation.Z); - } + GetComponent().AttachCameraToDynamicObject(player); + } - /// - /// Moves this dynamic object to the given position with the given speed. - /// - /// The position to which to move this dynamic object. - /// The speed at which to move this dynamic object. - /// - /// The time it will take for the object to move in milliseconds. - /// - public int Move(Vector3 position, float speed) + /// + /// Attaches this dynamic object to the specified dynamic object, player or vehicle. + /// + /// The dynamic object, player or vehicle. + /// The offset. + /// The rotation. + /// Synchronize rotation with the target object. + public void AttachTo(EntityId target, Vector3 offset, Vector3 rotation, bool syncRotation = true) + { + if (!target.IsOfAnyType(StreamerEntities.DynamicObjectType, SampEntities.PlayerType, SampEntities.VehicleType)) { - return GetComponent().MoveDynamicObject(position.X, position.Y, position.Z, speed, - -1000, -1000, -1000); + throw new InvalidEntityArgumentException(nameof(target), StreamerEntities.DynamicObjectType, + SampEntities.PlayerType, SampEntities.VehicleType); } - /// - /// Stop this dynamic object from moving any further. - /// - public void Stop() + if (target.IsOfType(StreamerEntities.DynamicObjectType)) { - GetComponent().StopDynamicObject(); + GetComponent().AttachDynamicObjectToObject(target, offset.X, offset.Y, offset.Z, + rotation.X, rotation.Y, rotation.Z, syncRotation); } - - /// - /// Attaches camera to the specified dynamic object. - /// - /// The player. - public void AttachCameraTo(EntityId player) + else if (target.IsOfType(SampEntities.PlayerType)) { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - - GetComponent().AttachCameraToDynamicObject(player); + GetComponent().AttachDynamicObjectToPlayer(target, offset.X, offset.Y, offset.Z, + rotation.X, rotation.Y, rotation.Z); } - - /// - /// Attaches this dynamic object to the specified dynamic object, player or vehicle. - /// - /// The dynamic object, player or vehicle. - /// The offset. - /// The rotation. - /// Synchronize rotation. - public void AttachTo(EntityId target, Vector3 offset, Vector3 rotation, bool syncRotation = true) + else if (target.IsOfType(SampEntities.VehicleType)) { - if (!target.IsOfAnyType(StreamerEntities.DynamicObjectType, SampEntities.PlayerType, SampEntities.VehicleType)) - throw new InvalidEntityArgumentException(nameof(target), StreamerEntities.DynamicObjectType, SampEntities.PlayerType, SampEntities.VehicleType); - - if (target.IsOfType(StreamerEntities.DynamicObjectType)) - GetComponent().AttachDynamicObjectToObject(target, offset.X, offset.Y, offset.Z, - rotation.X, rotation.Y, rotation.Z, Convert.ToInt32(syncRotation)); - else if (target.IsOfType(SampEntities.PlayerType)) - GetComponent().AttachDynamicObjectToPlayer(target, offset.X, offset.Y, offset.Z, - rotation.X, rotation.Y, rotation.Z); - else if (target.IsOfType(SampEntities.VehicleType)) - GetComponent().AttachDynamicObjectToVehicle(target, offset.X, offset.Y, offset.Z, - rotation.X, rotation.Y, rotation.Z); + GetComponent().AttachDynamicObjectToVehicle(target, offset.X, offset.Y, offset.Z, + rotation.X, rotation.Y, rotation.Z); } + } - /// - /// Gets the material of this dynamic object. - /// - public void GetMaterial(int materialindex, out int modelid, out string txdname, out string texturename, - out Color materialColor) - { - GetComponent().GetDynamicObjectMaterial(materialindex, out modelid, - out txdname, out texturename, out var holderMaterialColor, 64, 64); + /// + /// Gets the material of this dynamic object. + /// + public void GetMaterial(int materialindex, out int modelid, out string txdname, out string texturename, + out Color materialColor) + { + GetComponent().GetDynamicObjectMaterial(materialindex, out modelid, + out txdname, out texturename, out var holderMaterialColor, 64, 64); - materialColor = Color.FromInteger(holderMaterialColor, ColorFormat.ARGB); - } + materialColor = Color.FromInteger(holderMaterialColor, ColorFormat.ARGB); + } - /// - /// Sets the material of this dynamic object. - /// - /// The material index. - /// The model id. - /// The txd name. - /// The texture name. - /// The material color. - public void SetMaterial(int materialindex, int modelid, string txdname, string texturename, - Color materialcolor = new Color()) - { - GetComponent().SetDynamicObjectMaterial(materialindex, modelid, - txdname, texturename, materialcolor.ToInteger(ColorFormat.ARGB)); - } + /// + /// Sets the material of this dynamic object. + /// + /// The material index. + /// The model id. + /// The txd name. + /// The texture name. + /// The material color. + public void SetMaterial(int materialindex, int modelid, string txdname, string texturename, + Color materialcolor = new()) + { + GetComponent().SetDynamicObjectMaterial(materialindex, modelid, + txdname, texturename, materialcolor.ToInteger(ColorFormat.ARGB)); + } - /// - /// Remove the material of this dynamic object. - /// - /// The material index. - public void RemoveMaterial(int materialindex) - { - GetComponent().RemoveDynamicObjectMaterial(materialindex); - } + /// + /// Remove the material of this dynamic object. + /// + /// The material index. + public void RemoveMaterial(int materialindex) => + GetComponent().RemoveDynamicObjectMaterial(materialindex); - /// - /// Gets the material text of this dynamic object. - /// - public void GetMaterialText(int materialindex, out string text, - out ObjectMaterialSize materialSize, out string fontface, out int fontsize, out bool bold, - out Color fontcolor, out Color backcolor, out ObjectMaterialTextAlign textalignment) - { - GetComponent().GetDynamicObjectMaterialText(materialindex, out text, - out var holderMaterialSize, out fontface, out fontsize, out bold, + /// + /// Gets the material text of this dynamic object. + /// + public void GetMaterialText(int materialindex, out string text, + out ObjectMaterialSize materialSize, out string fontface, out int fontsize, out bool bold, + out Color fontcolor, out Color backcolor, out ObjectMaterialTextAlign textalignment) + { + GetComponent().GetDynamicObjectMaterialText(materialindex, out text, + out var holderMaterialSize, out fontface, out fontsize, out bold, out var holderFontColor, out var holderBackColor, out var holderTextalignment, 1024, 64); - fontcolor = Color.FromInteger(holderFontColor, ColorFormat.ARGB); - backcolor = Color.FromInteger(holderBackColor, ColorFormat.ARGB); - materialSize = (ObjectMaterialSize)holderMaterialSize; - textalignment = (ObjectMaterialTextAlign)holderTextalignment; - } - - /// - /// Sets the material text of this dynamic object. - /// - /// The material index. - /// The text. - /// The material size. - /// The font face. - /// The font size. - /// The bold. - /// The font color. - /// The back color. - /// The text alignment. - public void SetMaterialText(int materialindex, string text, - ObjectMaterialSize materialsize = ObjectMaterialSize.X256X128, string fontface = "Arial", int fontsize = 24, - bool bold = true, Color fontcolor = new Color(), Color backcolor = new Color(), - ObjectMaterialTextAlign textalignment = ObjectMaterialTextAlign.Center) - { - GetComponent().SetDynamicObjectMaterialText(materialindex, text, (int)materialsize, fontface, fontsize, bold, - fontcolor.ToInteger(ColorFormat.ARGB), backcolor.ToInteger(ColorFormat.ARGB), (int)textalignment); - } - - /// - /// Remove the material text of this dynamic object. - /// - /// The material index. - public void RemoveMaterialText(int materialindex) - { - GetComponent().RemoveDynamicObjectMaterialText(materialindex); - } + fontcolor = Color.FromInteger(holderFontColor, ColorFormat.ARGB); + backcolor = Color.FromInteger(holderBackColor, ColorFormat.ARGB); + materialSize = (ObjectMaterialSize)holderMaterialSize; + textalignment = (ObjectMaterialTextAlign)holderTextalignment; + } - /// - /// The toggle object for specific player. - /// - /// The player to toggle (or not) the object. - /// TRUE to toggle. - /// - /// - /// - public bool ToggleForPlayer(Player player, bool toggle) - { - if (player == null) - throw new ArgumentNullException(nameof(player)); + /// + /// Sets the material text of this dynamic object. + /// + /// The material index. + /// The text. + /// The material size. + /// The font face. + /// The font size. + /// The bold. + /// The font color. + /// The back color. + /// The text alignment. + public void SetMaterialText(int materialindex, string text, + ObjectMaterialSize materialsize = ObjectMaterialSize.X256X128, string fontface = "Arial", int fontsize = 24, + bool bold = true, Color fontcolor = new(), Color backcolor = new(), + ObjectMaterialTextAlign textalignment = ObjectMaterialTextAlign.Center) + { + GetComponent().SetDynamicObjectMaterialText(materialindex, text, (int)materialsize, + fontface, fontsize, bold, + fontcolor.ToInteger(ColorFormat.ARGB), backcolor.ToInteger(ColorFormat.ARGB), (int)textalignment); + } - return GetComponent().ToggleItem( - player.Entity.Handle, (int)StreamerType.Object, this.Entity.Handle, toggle); - } + /// + /// Remove the material text of this dynamic object. + /// + /// The material index. + public void RemoveMaterialText(int materialindex) => + GetComponent().RemoveDynamicObjectMaterialText(materialindex); - /// - protected override void OnDestroyComponent() + /// + /// The toggle object for specific player. + /// + /// The player to toggle (or not) the object. + /// TRUE to toggle. + /// + /// + /// + public bool ToggleForPlayer(Player player, bool toggle) + { + if (player == null) { - GetComponent().DestroyDynamicObject(); + throw new ArgumentNullException(nameof(player)); } + + return GetComponent().ToggleItem( + player.Entity.Handle, (int)StreamerType.Object, Entity.Handle, toggle); } + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicObject(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj b/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj index 6916708..7005be6 100644 --- a/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj +++ b/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj @@ -1,13 +1,15 @@  - netstandard2.1 + net9.0 + ..\..\bin\ Streamer Wrapper for SampSharp.Entities A SampSharp wrapper for Incognito's streamer plugin. - + + \ No newline at end of file diff --git a/src/SampSharp.Streamer/SampSharp.Streamer.csproj b/src/SampSharp.Streamer/SampSharp.Streamer.csproj index 63ed760..a4ae1a8 100644 --- a/src/SampSharp.Streamer/SampSharp.Streamer.csproj +++ b/src/SampSharp.Streamer/SampSharp.Streamer.csproj @@ -1,14 +1,14 @@  - netstandard2.1 + net9.0 Streamer Wrapper for SampSharp.GameMode A SampSharp wrapper for Incognito's streamer plugin. false - + From 6cb1b3dc0b866eed97e1ee18285357bb4aee24cf Mon Sep 17 00:00:00 2001 From: Borys Stelmakh Date: Sat, 4 Apr 2026 17:16:14 +0400 Subject: [PATCH 4/4] Fix formatting issues and improve code consistency across multiple files --- .editorconfig | 2 +- Directory.Build.props | 8 +- .../Components/DynamicArea.cs | 102 +- .../Components/DynamicCheckpoint.cs | 81 +- .../Components/DynamicMapIcon.cs | 101 +- .../Components/DynamicPickup.cs | 70 +- .../Components/DynamicRaceCheckpoint.cs | 80 +- .../Components/DynamicTextLabel.cs | 124 ++- .../Data/StreamerEntities.cs | 204 ++-- .../Definitions/AreaType.cs | 57 +- .../Definitions/StreamerObjectType.cs | 34 +- .../Definitions/StreamerType.cs | 93 +- .../ArgumentsOverrideEventContext.cs | 21 +- .../PlayerEditDynamicObjectMiddleware.cs | 51 +- .../PlayerEnterDynamicAreaMiddleware.cs | 39 +- .../PlayerEnterDynamicCheckpointMiddleware.cs | 39 +- ...yerEnterDynamicRaceCheckpointMiddleware.cs | 39 +- .../PlayerLeaveDynamicAreaMiddleware.cs | 39 +- .../PlayerLeaveDynamicCheckpointMiddleware.cs | 39 +- ...yerLeaveDynamicRaceCheckpointMiddleware.cs | 39 +- .../PlayerPickupDynamicPickupMiddleware.cs | 39 +- .../PlayerSelectDynamicObjectMiddleware.cs | 49 +- .../PlayerShootDynamicObjectMiddleware.cs | 51 +- .../StreamerPlayerConnectMiddleware.cs | 37 +- .../NativeComponents/NativeDynamicArea.cs | 72 +- .../NativeDynamicCheckpoint.cs | 29 +- .../NativeComponents/NativeDynamicMapIcon.cs | 29 +- .../NativeComponents/NativeDynamicPickup.cs | 29 +- .../NativeDynamicRaceCheckpoint.cs | 29 +- .../NativeDynamicTextLabel.cs | 45 +- .../NativeDynamicWoldObject.cs | 15 +- .../NativeComponents/NativeStreamerPlayer.cs | 130 +-- .../PlayerExtensions.cs | 209 ++-- ...Sharp.Streamer.Entities.csproj.DotSettings | 17 +- .../Services/IStreamerService.cs | 899 +++++++++--------- .../Services/StreamerService.cs | 662 +++++++------ .../Services/StreamerServiceNative.cs | 386 ++++---- .../StreamerEcsBuilderExtensions.cs | 207 ++-- 38 files changed, 2035 insertions(+), 2161 deletions(-) diff --git a/.editorconfig b/.editorconfig index b6eeb20..88af7ad 100644 --- a/.editorconfig +++ b/.editorconfig @@ -93,7 +93,7 @@ csharp_style_conditional_delegate_call = true:suggestion # Modifier preferences csharp_prefer_static_local_function = true:suggestion -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async # Code-block preferences csharp_prefer_braces = true:warning diff --git a/Directory.Build.props b/Directory.Build.props index e7c7f07..97ead19 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -62,10 +62,10 @@ - - all - runtime; build; native; contentfiles; analyzers - + + all + runtime; build; native; contentfiles; analyzers + diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicArea.cs b/src/SampSharp.Streamer.Entities/Components/DynamicArea.cs index b0eadb7..a700a90 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicArea.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicArea.cs @@ -14,76 +14,66 @@ // limitations under the License. using System.Collections.Generic; - using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic area. +/// +public sealed class DynamicArea : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic area. - /// - public sealed class DynamicArea : Component + private DynamicArea() { - private DynamicArea() - { + } - } + /// + /// Gets whether this dynamic area is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicArea(); - /// - /// Gets whether this dynamic area is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicArea(); + /// + /// Gets the dynamic area type. + /// + public AreaType AreaType => (AreaType)GetComponent().GetDynamicAreaType(); - /// - /// Gets the dynamic area type. - /// - public AreaType AreaType => (AreaType)GetComponent().GetDynamicAreaType(); + /// + /// Gets polygon points. + /// + public IEnumerable GetPolygonPoints() + { + var pointCount = GetPointsCount(); + GetComponent().GetDynamicPolygonPoints(out var points, pointCount * 2); - /// - /// Gets polygon points. - /// - public IEnumerable GetPolygonPoints() + if (points == null) { - var pointCount = GetPointsCount(); - GetComponent().GetDynamicPolygonPoints(out var points, pointCount * 2); - - if (points == null) yield break; - - for (var i = 0; i < points.Length - 1; i += 2) - { - yield return new Vector3(points[i], points[i + 1]); - } + yield break; } - /// - /// Gets number points. - /// - public int GetPointsCount() + for (var i = 0; i < points.Length - 1; i += 2) { - return GetComponent().GetDynamicPolygonNumberPoints(); + yield return new Vector3(points[i], points[i + 1]); } + } - /// - /// Gets any player in area. - /// - public bool IsAnyPlayerInArea(bool recheck = false) - { - return GetComponent().IsAnyPlayerInDynamicArea(recheck); - } + /// + /// Gets number points. + /// + public int GetPointsCount() => GetComponent().GetDynamicPolygonNumberPoints(); - /// - /// Gets any player in any area. - /// - public bool IsAnyPlayerInAnyArea(bool recheck = false) - { - return GetComponent().IsAnyPlayerInAnyDynamicArea(recheck); - } + /// + /// Gets any player in area. + /// + public bool IsAnyPlayerInArea(bool recheck = false) => + GetComponent().IsAnyPlayerInDynamicArea(recheck); - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamicArea(); - } - } -} + /// + /// Gets any player in any area. + /// + public bool IsAnyPlayerInAnyArea(bool recheck = false) => + GetComponent().IsAnyPlayerInAnyDynamicArea(recheck); + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicArea(); +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicCheckpoint.cs b/src/SampSharp.Streamer.Entities/Components/DynamicCheckpoint.cs index 22f57fd..4ad2f98 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicCheckpoint.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicCheckpoint.cs @@ -14,59 +14,56 @@ // limitations under the License. using System; - using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic checkpoint. +/// +public sealed class DynamicCheckpoint : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic checkpoint. - /// - public sealed class DynamicCheckpoint : Component + private DynamicCheckpoint(Vector3 position, float size) { - private DynamicCheckpoint(Vector3 position, float size) - { - Position = position; - Size = size; - } + Position = position; + Size = size; + } - /// - /// Gets whether this dynamic checkpoint is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicCP(); + /// + /// Gets whether this dynamic checkpoint is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicCP(); - /// - /// Gets the position of this checkpoint. - /// - public Vector3 Position { get; } + /// + /// Gets the position of this checkpoint. + /// + public Vector3 Position { get; } - /// - /// Gets the size of this checkpoint. - /// - public float Size { get; } + /// + /// Gets the size of this checkpoint. + /// + public float Size { get; } - /// - /// The toggle checkpoint for specific player. - /// - /// The player to toggle (or not) the checkpoint. - /// TRUE to toggle. - /// - /// - /// - public bool ToggleForPlayer(Player player, bool toggle) + /// + /// The toggle checkpoint for specific player. + /// + /// The player to toggle (or not) the checkpoint. + /// TRUE to toggle. + /// + /// + /// + public bool ToggleForPlayer(Player player, bool toggle) + { + if (player == null) { - if (player == null) - throw new ArgumentNullException(nameof(player)); - - return GetComponent().ToggleItem( - player.Entity.Handle, (int)StreamerType.Checkpoint, this.Entity.Handle, toggle); + throw new ArgumentNullException(nameof(player)); } - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamicCP(); - } + return GetComponent().ToggleItem( + player.Entity.Handle, (int)StreamerType.Checkpoint, Entity.Handle, toggle); } + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicCP(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicMapIcon.cs b/src/SampSharp.Streamer.Entities/Components/DynamicMapIcon.cs index 3fdf2a6..f78816c 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicMapIcon.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicMapIcon.cs @@ -14,71 +14,68 @@ // limitations under the License. using System; - using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic map icon. +/// +public sealed class DynamicMapIcon : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic map icon. - /// - public sealed class DynamicMapIcon : Component + private DynamicMapIcon(Vector3 position, MapIcon type, MapIconType style, Color color) { - private DynamicMapIcon(Vector3 position, MapIcon type, MapIconType style, Color color) - { - Position = position; - Type = type; - Style = style; - Color = color; - } + Position = position; + Type = type; + Style = style; + Color = color; + } - /// - /// Gets whether this dynamic map icon is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicMapIcon(); + /// + /// Gets whether this dynamic map icon is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicMapIcon(); - /// - /// Gets the position of this map icon. - /// - public Vector3 Position { get; } + /// + /// Gets the position of this map icon. + /// + public Vector3 Position { get; } - /// - /// Gets the type of this map icon. - /// - public MapIcon Type { get; } + /// + /// Gets the type of this map icon. + /// + public MapIcon Type { get; } - /// - /// Gets the style of this map icon. - /// - public MapIconType Style { get; } + /// + /// Gets the style of this map icon. + /// + public MapIconType Style { get; } - /// - /// Gets the color of this map icon. - /// - public Color Color { get; } + /// + /// Gets the color of this map icon. + /// + public Color Color { get; } - /// - /// The toggle map icon for specific player. - /// - /// The player to toggle (or not) the map icon. - /// TRUE to toggle. - /// - /// - /// - public bool ToggleForPlayer(Player player, bool toggle) + /// + /// The toggle map icon for specific player. + /// + /// The player to toggle (or not) the map icon. + /// TRUE to toggle. + /// + /// + /// + public bool ToggleForPlayer(Player player, bool toggle) + { + if (player == null) { - if (player == null) - throw new ArgumentNullException(nameof(player)); - - return GetComponent().ToggleItem( - player.Entity.Handle, (int)StreamerType.MapIcon, this.Entity.Handle, toggle); + throw new ArgumentNullException(nameof(player)); } - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamicMapIcon(); - } + return GetComponent().ToggleItem( + player.Entity.Handle, (int)StreamerType.MapIcon, Entity.Handle, toggle); } + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicMapIcon(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicPickup.cs b/src/SampSharp.Streamer.Entities/Components/DynamicPickup.cs index 584a82d..340a2e4 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicPickup.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicPickup.cs @@ -17,49 +17,47 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic pickup. +/// +public sealed class DynamicPickup : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic pickup. - /// - public sealed class DynamicPickup : Component + private DynamicPickup(Vector3 position) { - private DynamicPickup(Vector3 position) - { - Position = position; - } + Position = position; + } - /// - /// Gets whether this dynamic pickup is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicPickup(); + /// + /// Gets whether this dynamic pickup is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicPickup(); - /// - /// Gets the position of this pickup. - /// - public Vector3 Position { get; } + /// + /// Gets the position of this pickup. + /// + public Vector3 Position { get; } - /// - /// The toggle pickup for specific player. - /// - /// The player to toggle (or not) the pickup. - /// TRUE to toggle. - /// - /// - /// - public bool ToggleForPlayer(Player player, bool toggle) + /// + /// The toggle pickup for specific player. + /// + /// The player to toggle (or not) the pickup. + /// TRUE to toggle. + /// + /// + /// + public bool ToggleForPlayer(Player player, bool toggle) + { + if (player == null) { - if (player == null) - throw new ArgumentNullException(nameof(player)); - - return GetComponent().ToggleItem( - player.Entity.Handle, (int)StreamerType.Pickup, this.Entity.Handle, toggle); + throw new ArgumentNullException(nameof(player)); } - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamicPickup(); - } + return GetComponent().ToggleItem( + player.Entity.Handle, (int)StreamerType.Pickup, Entity.Handle, toggle); } + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicPickup(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicRaceCheckpoint.cs b/src/SampSharp.Streamer.Entities/Components/DynamicRaceCheckpoint.cs index 2ba1de6..a944b6c 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicRaceCheckpoint.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicRaceCheckpoint.cs @@ -17,55 +17,53 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic race checkpoint. +/// +public sealed class DynamicRaceCheckpoint : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic race checkpoint. - /// - public sealed class DynamicRaceCheckpoint : Component + private DynamicRaceCheckpoint(Vector3 position, Vector3 nextPosition) { - private DynamicRaceCheckpoint(Vector3 position, Vector3 nextPosition) - { - Position = position; - NextPosition = nextPosition; - } + Position = position; + NextPosition = nextPosition; + } - /// - /// Gets whether this dynamic race checkpoint is valid. - /// - public bool IsValid => GetComponent().IsValidDynamicRaceCP(); + /// + /// Gets whether this dynamic race checkpoint is valid. + /// + public bool IsValid => GetComponent().IsValidDynamicRaceCP(); - /// - /// Gets the position of this race checkpoint. - /// - public Vector3 Position { get; } + /// + /// Gets the position of this race checkpoint. + /// + public Vector3 Position { get; } - /// - /// Gets the next position of this race checkpoint. - /// - public Vector3 NextPosition { get; } + /// + /// Gets the next position of this race checkpoint. + /// + public Vector3 NextPosition { get; } - /// - /// The toggle race checkpoint for specific player. - /// - /// The player to toggle (or not) the checkpoint. - /// TRUE to toggle. - /// - /// - /// - public bool ToggleForPlayer(Player player, bool toggle) + /// + /// The toggle race checkpoint for specific player. + /// + /// The player to toggle (or not) the checkpoint. + /// TRUE to toggle. + /// + /// + /// + public bool ToggleForPlayer(Player player, bool toggle) + { + if (player == null) { - if (player == null) - throw new ArgumentNullException(nameof(player)); - - return GetComponent().ToggleItem( - player.Entity.Handle, (int)StreamerType.RaceCheckpoint, this.Entity.Handle, toggle); + throw new ArgumentNullException(nameof(player)); } - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamicRaceCP(); - } + return GetComponent().ToggleItem( + player.Entity.Handle, (int)StreamerType.RaceCheckpoint, Entity.Handle, toggle); } + + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamicRaceCP(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Components/DynamicTextLabel.cs b/src/SampSharp.Streamer.Entities/Components/DynamicTextLabel.cs index d52df64..59c8175 100644 --- a/src/SampSharp.Streamer.Entities/Components/DynamicTextLabel.cs +++ b/src/SampSharp.Streamer.Entities/Components/DynamicTextLabel.cs @@ -16,83 +16,79 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a component which provides the data and functionality of an dynamic text label. +/// +public sealed class DynamicTextLabel : Component { - /// - /// Represents a component which provides the data and functionality of an dynamic text label. - /// - public sealed class DynamicTextLabel : Component - { - #region Properties + #region Constructor - private string _text; - private Color _color; + private DynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, int virtualWorld) + { + _text = text; + _color = color; + Position = position; + DrawDistance = drawDistance; + VirtualWorld = virtualWorld; + } - #endregion + #endregion - #region Constructor + /// + /// Gets whether this dynamic text label is valid. + /// + public bool IsValid => GetComponent().IsValidDynamic3DTextLabel(); - private DynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, int virtualWorld) + /// + /// Gets or sets the text of this dynamic text label. + /// + public string Text + { + get => _text; + set { - _text = text; - _color = color; - Position = position; - DrawDistance = drawDistance; - VirtualWorld = virtualWorld; + _text = value; + GetComponent().UpdateDynamic3DTextLabelText(Color, value ?? string.Empty); } + } - #endregion - - /// - /// Gets whether this dynamic text label is valid. - /// - public bool IsValid => GetComponent().IsValidDynamic3DTextLabel(); - - /// - /// Gets or sets the text of this dynamic text label. - /// - public string Text + /// + /// Gets or sets the color of this dynamic text label. + /// + public Color Color + { + get => _color; + set { - get => _text; - set - { - _text = value; - GetComponent().UpdateDynamic3DTextLabelText(Color, value ?? string.Empty); - } + _color = value; + GetComponent().UpdateDynamic3DTextLabelText(value, Text); } + } - /// - /// Gets or sets the color of this dynamic text label. - /// - public Color Color - { - get => _color; - set - { - _color = value; - GetComponent().UpdateDynamic3DTextLabelText(value, Text); - } - } + /// + /// Gets the position of this dynamic text label. + /// + public Vector3 Position { get; } - /// - /// Gets the position of this dynamic text label. - /// - public Vector3 Position { get; } + /// + /// Gets the draw distance of this dynamic text label. + /// + public float DrawDistance { get; } - /// - /// Gets the draw distance of this dynamic text label. - /// - public float DrawDistance { get; } + /// + /// Gets the virtual world of this dynamic text label. + /// + public int VirtualWorld { get; } - /// - /// Gets the virtual world of this dynamic text label. - /// - public int VirtualWorld { get; } + /// + protected override void OnDestroyComponent() => GetComponent().DestroyDynamic3DTextLabel(); - /// - protected override void OnDestroyComponent() - { - GetComponent().DestroyDynamic3DTextLabel(); - } - } + #region Properties + + private string _text; + private Color _color; + + #endregion } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Data/StreamerEntities.cs b/src/SampSharp.Streamer.Entities/Data/StreamerEntities.cs index 86bc6c8..31fddb6 100644 --- a/src/SampSharp.Streamer.Entities/Data/StreamerEntities.cs +++ b/src/SampSharp.Streamer.Entities/Data/StreamerEntities.cs @@ -16,123 +16,95 @@ using System; using SampSharp.Entities; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Contains functions for constructing values for Streamer native entities. +/// +public static class StreamerEntities { /// - /// Contains functions for constructing values for Streamer native entities. + /// The Streamer dynamic object entity type identifier. + /// + [EntityType] public static readonly Guid DynamicObjectType = new("DFDD0E7F-7351-4D13-AF60-665837B09DAC"); + + /// + /// The Streamer dynamic pickup entity type identifier. + /// + [EntityType] public static readonly Guid DynamicPickupType = new("5930AA01-BEB3-4ABA-9107-B63C84F7F4B8"); + + /// + /// The Streamer dynamic checkpoint entity type identifier. + /// + [EntityType] public static readonly Guid DynamicCheckpointType = new("1E80381E-44BE-4A06-8C79-6309E7DD9440"); + + /// + /// The Streamer dynamic race checkpoint entity type identifier. + /// + [EntityType] public static readonly Guid DynamicRaceCheckpointType = new("388F3E60-A176-473C-A4E2-D852F894DFDF"); + + /// + /// The Streamer dynamic map icon entity type identifier. + /// + [EntityType] public static readonly Guid DynamicMapIconType = new("595B2E88-FAC5-478F-9E60-191B63B352ED"); + + /// + /// The Streamer dynamic text label entity type identifier. + /// + [EntityType] public static readonly Guid DynamicTextLabelType = new("9A93A721-7B86-4D90-94A1-43CE918776A7"); + + /// + /// The Streamer dynamic area entity type identifier. + /// + [EntityType] public static readonly Guid DynamicAreaType = new("0CEA86BA-978E-4289-913A-14433D8F9362"); + + /// + /// Gets a dynamic object entity identifier based on an integer dynamic object identifier. + /// + /// The dynamic object identifier. + /// The entity identifier. + public static EntityId GetDynamicObjectId(int objectId) => new(DynamicObjectType, objectId); + + /// + /// Gets a dynamic pickup entity identifier based on an integer dynamic pickup identifier. + /// + /// The dynamic pickup identifier. + /// The entity identifier. + public static EntityId GetDynamicPickupId(int pickupId) => new(DynamicPickupType, pickupId); + + /// + /// Gets a dynamic checkpoint entity identifier based on an integer dynamic checkpoint identifier. + /// + /// The dynamic checkpoint identifier. + /// The entity identifier. + public static EntityId GetDynamicCheckpointId(int checkpointId) => new(DynamicCheckpointType, checkpointId); + + /// + /// Gets a dynamic race checkpoint entity identifier based on an integer dynamic race checkpoint identifier. + /// + /// The dynamic race checkpoint identifier. + /// The entity identifier. + public static EntityId GetDynamicRaceCheckpointId(int raceCheckpointId) => + new(DynamicRaceCheckpointType, raceCheckpointId); + + /// + /// Gets a dynamic map icon entity identifier based on an integer dynamic map icon identifier. + /// + /// The dynamic map icon identifier. + /// The entity identifier. + public static EntityId GetDynamicMapIconId(int mapIconId) => new(DynamicMapIconType, mapIconId); + + /// + /// Gets a dynamic text label entity identifier based on an integer dynamic text label identifier. + /// + /// The dynamic text label identifier. + /// The entity identifier. + public static EntityId GetDynamicTextLabelId(int textLabelId) => new(DynamicTextLabelType, textLabelId); + + /// + /// Gets a dynamic area entity identifier based on an integer dynamic area identifier. /// - public static class StreamerEntities - { - /// - /// The Streamer dynamic object entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicObjectType = new Guid("DFDD0E7F-7351-4D13-AF60-665837B09DAC"); - - /// - /// The Streamer dynamic pickup entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicPickupType = new Guid("5930AA01-BEB3-4ABA-9107-B63C84F7F4B8"); - - /// - /// The Streamer dynamic checkpoint entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicCheckpointType = new Guid("1E80381E-44BE-4A06-8C79-6309E7DD9440"); - - /// - /// The Streamer dynamic race checkpoint entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicRaceCheckpointType = new Guid("388F3E60-A176-473C-A4E2-D852F894DFDF"); - - /// - /// The Streamer dynamic map icon entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicMapIconType = new Guid("595B2E88-FAC5-478F-9E60-191B63B352ED"); - - /// - /// The Streamer dynamic text label entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicTextLabelType = new Guid("9A93A721-7B86-4D90-94A1-43CE918776A7"); - - /// - /// The Streamer dynamic area entity type identifier. - /// - [EntityType] - public static readonly Guid DynamicAreaType = new Guid("0CEA86BA-978E-4289-913A-14433D8F9362"); - - /// - /// Gets a dynamic object entity identifier based on an integer dynamic object identifier. - /// - /// The dynamic object identifier. - /// The entity identifier. - public static EntityId GetDynamicObjectId(int objectId) - { - return new EntityId(DynamicObjectType, objectId); - } - - /// - /// Gets a dynamic pickup entity identifier based on an integer dynamic pickup identifier. - /// - /// The dynamic pickup identifier. - /// The entity identifier. - public static EntityId GetDynamicPickupId(int pickupId) - { - return new EntityId(DynamicPickupType, pickupId); - } - - /// - /// Gets a dynamic checkpoint entity identifier based on an integer dynamic checkpoint identifier. - /// - /// The dynamic checkpoint identifier. - /// The entity identifier. - public static EntityId GetDynamicCheckpointId(int checkpointId) - { - return new EntityId(DynamicCheckpointType, checkpointId); - } - - /// - /// Gets a dynamic race checkpoint entity identifier based on an integer dynamic race checkpoint identifier. - /// - /// The dynamic race checkpoint identifier. - /// The entity identifier. - public static EntityId GetDynamicRaceCheckpointId(int raceCheckpointId) - { - return new EntityId(DynamicRaceCheckpointType, raceCheckpointId); - } - - /// - /// Gets a dynamic map icon entity identifier based on an integer dynamic map icon identifier. - /// - /// The dynamic map icon identifier. - /// The entity identifier. - public static EntityId GetDynamicMapIconId(int mapIconId) - { - return new EntityId(DynamicMapIconType, mapIconId); - } - - /// - /// Gets a dynamic text label entity identifier based on an integer dynamic text label identifier. - /// - /// The dynamic text label identifier. - /// The entity identifier. - public static EntityId GetDynamicTextLabelId(int textLabelId) - { - return new EntityId(DynamicTextLabelType, textLabelId); - } - - /// - /// Gets a dynamic area entity identifier based on an integer dynamic area identifier. - /// - /// The dynamic area identifier. - /// The entity identifier. - public static EntityId GetDynamicAreaId(int areaId) - { - return new EntityId(DynamicAreaType, areaId); - } - } + /// The dynamic area identifier. + /// The entity identifier. + public static EntityId GetDynamicAreaId(int areaId) => new(DynamicAreaType, areaId); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Definitions/AreaType.cs b/src/SampSharp.Streamer.Entities/Definitions/AreaType.cs index a519679..edeae5c 100644 --- a/src/SampSharp.Streamer.Entities/Definitions/AreaType.cs +++ b/src/SampSharp.Streamer.Entities/Definitions/AreaType.cs @@ -13,41 +13,40 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Contains types of areas a see can cover. +/// +public enum AreaType { /// - /// Contains types of areas a see can cover. + /// A circular area /// - public enum AreaType - { - /// - /// A circular area - /// - Circle = 0, + Circle = 0, - /// - /// A cylindrical area. - /// - Cylinder = 1, + /// + /// A cylindrical area. + /// + Cylinder = 1, - /// - /// A spherical area - /// - Sphere = 2, + /// + /// A spherical area + /// + Sphere = 2, - /// - /// A rectangular area. - /// - Rectangle = 3, + /// + /// A rectangular area. + /// + Rectangle = 3, - /// - /// A cuboidal area. - /// - Cuboid = 4, + /// + /// A cuboidal area. + /// + Cuboid = 4, - /// - /// A polygonal area. - /// - Polygon = 5 - } + /// + /// A polygonal area. + /// + Polygon = 5 } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Definitions/StreamerObjectType.cs b/src/SampSharp.Streamer.Entities/Definitions/StreamerObjectType.cs index 41b8559..3474011 100644 --- a/src/SampSharp.Streamer.Entities/Definitions/StreamerObjectType.cs +++ b/src/SampSharp.Streamer.Entities/Definitions/StreamerObjectType.cs @@ -15,25 +15,25 @@ using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Provides types of visible objects available in streamer and SampSharp. +/// +public enum StreamerObjectType { /// - /// Provides types of visible objects available in streamer and SampSharp. + /// A . + /// + Global = 0, + + /// + /// A . /// - public enum StreamerObjectType - { - /// - /// A . - /// - Global = 0, - /// - /// A . - /// - Player = 1, + Player = 1, - /// - /// A . - /// - Dynamic = 2 - } + /// + /// A . + /// + Dynamic = 2 } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Definitions/StreamerType.cs b/src/SampSharp.Streamer.Entities/Definitions/StreamerType.cs index d792cd3..f616160 100644 --- a/src/SampSharp.Streamer.Entities/Definitions/StreamerType.cs +++ b/src/SampSharp.Streamer.Entities/Definitions/StreamerType.cs @@ -13,49 +13,56 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Contains types of entities available in streamer. +/// +public enum StreamerType { /// - /// Contains types of entities available in streamer. - /// - public enum StreamerType - { - /// - /// All types provided by streamer. - /// - All = -1, - /// - /// A . - /// - Object = 0, - /// - /// A . - /// - Pickup = 1, - /// - /// A . - /// - Checkpoint = 2, - /// - /// A . - /// - RaceCheckpoint = 3, - /// - /// A . - /// - MapIcon = 4, - /// - /// A . - /// - TextLabel = 5, - /// - /// A . - /// - Area = 6, - /// - /// A dynamic actor. - /// - // TODO: Implement actor in SampSharp.Streamer.Entities. - Actor = 7 - } + /// All types provided by streamer. + /// + All = -1, + + /// + /// A . + /// + Object = 0, + + /// + /// A . + /// + Pickup = 1, + + /// + /// A . + /// + Checkpoint = 2, + + /// + /// A . + /// + RaceCheckpoint = 3, + + /// + /// A . + /// + MapIcon = 4, + + /// + /// A . + /// + TextLabel = 5, + + /// + /// A . + /// + Area = 6, + + /// + /// A dynamic actor. + /// + // TODO: Implement actor in SampSharp.Streamer.Entities. + Actor = 7 } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/ArgumentsOverrideEventContext.cs b/src/SampSharp.Streamer.Entities/Middleware/ArgumentsOverrideEventContext.cs index dc31449..0b12fa0 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/ArgumentsOverrideEventContext.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/ArgumentsOverrideEventContext.cs @@ -16,21 +16,20 @@ using System; using SampSharp.Entities; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class ArgumentsOverrideEventContext : EventContext { - internal class ArgumentsOverrideEventContext : EventContext + public ArgumentsOverrideEventContext(int argumentCount) { - public ArgumentsOverrideEventContext(int argumentCount) - { - Arguments = new object[argumentCount]; - } + Arguments = new object[argumentCount]; + } - public EventContext BaseContext { get; set; } + public EventContext BaseContext { get; set; } - public override string Name => BaseContext.Name; + public override string Name => BaseContext.Name; - public override object[] Arguments { get; } + public override object[] Arguments { get; } - public override IServiceProvider EventServices => BaseContext.EventServices; - } + public override IServiceProvider EventServices => BaseContext.EventServices; } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerEditDynamicObjectMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerEditDynamicObjectMiddleware.cs index 367ee5a..bdc84a6 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerEditDynamicObjectMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerEditDynamicObjectMiddleware.cs @@ -16,37 +16,38 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerEditDynamicObjectMiddleware { - internal class PlayerEditDynamicObjectMiddleware + private readonly ArgumentsOverrideEventContext _context = new(5); + private readonly EventDelegate _next; + + public PlayerEditDynamicObjectMiddleware(EventDelegate next) { - private readonly ArgumentsOverrideEventContext _context = new ArgumentsOverrideEventContext(5); - private readonly EventDelegate _next; + _next = next; + } - public PlayerEditDynamicObjectMiddleware(EventDelegate next) - { - _next = next; - } + public object Invoke(EventContext context) + { + var inArgs = context.Arguments; + var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); + var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[1]); - public object Invoke(EventContext context) + if (!objectEntity) { - var inArgs = context.Arguments; - var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); - var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[1]); - - if (!objectEntity) - return null; + return null; + } - _context.BaseContext = context; + _context.BaseContext = context; - var args = _context.Arguments; - args[0] = playerEntity; - args[1] = objectEntity; - args[2] = inArgs[2]; // response - args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position - args[4] = new Vector3((float)inArgs[6], (float)inArgs[7], (float)inArgs[8]); // rotation + var args = _context.Arguments; + args[0] = playerEntity; + args[1] = objectEntity; + args[2] = inArgs[2]; // response + args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position + args[4] = new Vector3((float)inArgs[6], (float)inArgs[7], (float)inArgs[8]); // rotation - return _next(_context); - } + return _next(_context); } -} +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicAreaMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicAreaMiddleware.cs index 7c04677..467ba36 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicAreaMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicAreaMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerEnterDynamicAreaMiddleware { - internal class PlayerEnterDynamicAreaMiddleware + private readonly EventDelegate _next; + + public PlayerEnterDynamicAreaMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var areaEntity = StreamerEntities.GetDynamicAreaId((int)context.Arguments[1]); - public PlayerEnterDynamicAreaMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(areaEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var areaEntity = StreamerEntities.GetDynamicAreaId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(areaEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = areaEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = areaEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicCheckpointMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicCheckpointMiddleware.cs index 1ee877c..6562ff8 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicCheckpointMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicCheckpointMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerEnterDynamicCheckpointMiddleware { - internal class PlayerEnterDynamicCheckpointMiddleware + private readonly EventDelegate _next; + + public PlayerEnterDynamicCheckpointMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var checkpointEntity = StreamerEntities.GetDynamicCheckpointId((int)context.Arguments[1]); - public PlayerEnterDynamicCheckpointMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(checkpointEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var checkpointEntity = StreamerEntities.GetDynamicCheckpointId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(checkpointEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = checkpointEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = checkpointEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicRaceCheckpointMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicRaceCheckpointMiddleware.cs index b6f8f92..47f47f7 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicRaceCheckpointMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerEnterDynamicRaceCheckpointMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerEnterDynamicRaceCheckpointMiddleware { - internal class PlayerEnterDynamicRaceCheckpointMiddleware + private readonly EventDelegate _next; + + public PlayerEnterDynamicRaceCheckpointMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var raceCheckpointEntity = StreamerEntities.GetDynamicRaceCheckpointId((int)context.Arguments[1]); - public PlayerEnterDynamicRaceCheckpointMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(raceCheckpointEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var raceCheckpointEntity = StreamerEntities.GetDynamicRaceCheckpointId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(raceCheckpointEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = raceCheckpointEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = raceCheckpointEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicAreaMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicAreaMiddleware.cs index bea176d..c826bf8 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicAreaMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicAreaMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerLeaveDynamicAreaMiddleware { - internal class PlayerLeaveDynamicAreaMiddleware + private readonly EventDelegate _next; + + public PlayerLeaveDynamicAreaMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var areaEntity = StreamerEntities.GetDynamicAreaId((int)context.Arguments[1]); - public PlayerLeaveDynamicAreaMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(areaEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var areaEntity = StreamerEntities.GetDynamicAreaId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(areaEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = areaEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = areaEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicCheckpointMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicCheckpointMiddleware.cs index 75c91df..1035b26 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicCheckpointMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicCheckpointMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerLeaveDynamicCheckpointMiddleware { - internal class PlayerLeaveDynamicCheckpointMiddleware + private readonly EventDelegate _next; + + public PlayerLeaveDynamicCheckpointMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var checkpointEntity = StreamerEntities.GetDynamicCheckpointId((int)context.Arguments[1]); - public PlayerLeaveDynamicCheckpointMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(checkpointEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var checkpointEntity = StreamerEntities.GetDynamicCheckpointId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(checkpointEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = checkpointEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = checkpointEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicRaceCheckpointMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicRaceCheckpointMiddleware.cs index 4b29294..97bbef1 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicRaceCheckpointMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerLeaveDynamicRaceCheckpointMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerLeaveDynamicRaceCheckpointMiddleware { - internal class PlayerLeaveDynamicRaceCheckpointMiddleware + private readonly EventDelegate _next; + + public PlayerLeaveDynamicRaceCheckpointMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var raceCheckpointEntity = StreamerEntities.GetDynamicRaceCheckpointId((int)context.Arguments[1]); - public PlayerLeaveDynamicRaceCheckpointMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(raceCheckpointEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var raceCheckpointEntity = StreamerEntities.GetDynamicRaceCheckpointId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(raceCheckpointEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = raceCheckpointEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = raceCheckpointEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerPickupDynamicPickupMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerPickupDynamicPickupMiddleware.cs index 7661a18..a1a0097 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerPickupDynamicPickupMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerPickupDynamicPickupMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerPickupDynamicPickupMiddleware { - internal class PlayerPickupDynamicPickupMiddleware + private readonly EventDelegate _next; + + public PlayerPickupDynamicPickupMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); + var pickupEntity = StreamerEntities.GetDynamicPickupId((int)context.Arguments[1]); - public PlayerPickupDynamicPickupMiddleware(EventDelegate next) + if (!entityManager.Exists(playerEntity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entityManager.Exists(pickupEntity)) { - var playerEntity = SampEntities.GetPlayerId((int)context.Arguments[0]); - var pickupEntity = StreamerEntities.GetDynamicPickupId((int)context.Arguments[1]); - - if (!entityManager.Exists(playerEntity)) - return null; - - if (!entityManager.Exists(pickupEntity)) - return null; + return null; + } - context.Arguments[0] = playerEntity; - context.Arguments[1] = pickupEntity; + context.Arguments[0] = playerEntity; + context.Arguments[1] = pickupEntity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerSelectDynamicObjectMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerSelectDynamicObjectMiddleware.cs index a6cc5ba..8108007 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerSelectDynamicObjectMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerSelectDynamicObjectMiddleware.cs @@ -16,36 +16,37 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerSelectDynamicObjectMiddleware { - internal class PlayerSelectDynamicObjectMiddleware + private readonly ArgumentsOverrideEventContext _context = new(4); + private readonly EventDelegate _next; + + public PlayerSelectDynamicObjectMiddleware(EventDelegate next) { - private readonly ArgumentsOverrideEventContext _context = new ArgumentsOverrideEventContext(4); - private readonly EventDelegate _next; + _next = next; + } - public PlayerSelectDynamicObjectMiddleware(EventDelegate next) - { - _next = next; - } + public object Invoke(EventContext context) + { + var inArgs = context.Arguments; + var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); + var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[1]); - public object Invoke(EventContext context) + if (!objectEntity) { - var inArgs = context.Arguments; - var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); - var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[1]); - - if (!objectEntity) - return null; + return null; + } - _context.BaseContext = context; + _context.BaseContext = context; - var args = _context.Arguments; - args[0] = playerEntity; - args[1] = objectEntity; - args[2] = inArgs[2]; // modelid - args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position + var args = _context.Arguments; + args[0] = playerEntity; + args[1] = objectEntity; + args[2] = inArgs[2]; // modelid + args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position - return _next(_context); - } + return _next(_context); } -} +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/PlayerShootDynamicObjectMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/PlayerShootDynamicObjectMiddleware.cs index 3ef869b..526d8bb 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/PlayerShootDynamicObjectMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/PlayerShootDynamicObjectMiddleware.cs @@ -16,37 +16,38 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class PlayerShootDynamicObjectMiddleware { - internal class PlayerShootDynamicObjectMiddleware - { - private readonly ArgumentsOverrideEventContext _context = new ArgumentsOverrideEventContext(4); - private readonly EventDelegate _next; + private readonly ArgumentsOverrideEventContext _context = new(4); + private readonly EventDelegate _next; - public PlayerShootDynamicObjectMiddleware(EventDelegate next) - { - _next = next; - } + public PlayerShootDynamicObjectMiddleware(EventDelegate next) + { + _next = next; + } - public object Invoke(EventContext context) - { - var inArgs = context.Arguments; + public object Invoke(EventContext context) + { + var inArgs = context.Arguments; - var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); - var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[2]); + var playerEntity = SampEntities.GetPlayerId((int)inArgs[0]); + var objectEntity = StreamerEntities.GetDynamicObjectId((int)inArgs[2]); - if (!objectEntity) - return null; + if (!objectEntity) + { + return null; + } - _context.BaseContext = context; + _context.BaseContext = context; - var args = _context.Arguments; - args[0] = playerEntity; - args[1] = (Weapon)inArgs[1]; // weaponid - args[2] = objectEntity; - args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position + var args = _context.Arguments; + args[0] = playerEntity; + args[1] = (Weapon)inArgs[1]; // weaponid + args[2] = objectEntity; + args[3] = new Vector3((float)inArgs[3], (float)inArgs[4], (float)inArgs[5]); // position - return _next(_context); - } + return _next(_context); } -} +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Middleware/StreamerPlayerConnectMiddleware.cs b/src/SampSharp.Streamer.Entities/Middleware/StreamerPlayerConnectMiddleware.cs index d4ad8c0..8fc32e9 100644 --- a/src/SampSharp.Streamer.Entities/Middleware/StreamerPlayerConnectMiddleware.cs +++ b/src/SampSharp.Streamer.Entities/Middleware/StreamerPlayerConnectMiddleware.cs @@ -16,32 +16,35 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +internal class StreamerPlayerConnectMiddleware { - internal class StreamerPlayerConnectMiddleware + private readonly EventDelegate _next; + + public StreamerPlayerConnectMiddleware(EventDelegate next) + { + _next = next; + } + + public object Invoke(EventContext context, IEntityManager entityManager) { - private readonly EventDelegate _next; + var entity = (EntityId)context.Arguments[0]; - public StreamerPlayerConnectMiddleware(EventDelegate next) + if (!entityManager.Exists(entity)) { - _next = next; + return null; } - public object Invoke(EventContext context, IEntityManager entityManager) + if (!entity.IsOfType(SampEntities.PlayerType)) { - var entity = (EntityId)context.Arguments[0]; - - if (!entityManager.Exists(entity)) - return null; + return null; + } - if (!entity.IsOfType(SampEntities.PlayerType)) - return null; - - entityManager.AddComponent(entity); + entityManager.AddComponent(entity); - context.Arguments[0] = entity; + context.Arguments[0] = entity; - return _next(context); - } + return _next(context); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicArea.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicArea.cs index fedcfb2..e1f387f 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicArea.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicArea.cs @@ -16,61 +16,37 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicArea : BaseNativeComponent { - public class NativeDynamicArea : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamicArea() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamicArea() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool DestroyDynamicArea() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool DestroyDynamicArea() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int GetDynamicAreaType() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual int GetDynamicAreaType() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int GetDynamicPolygonPoints(out float[] points, int maxlength) - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual int GetDynamicPolygonPoints(out float[] points, int maxlength) => + throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int GetDynamicPolygonNumberPoints() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual int GetDynamicPolygonNumberPoints() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool IsAnyPlayerInDynamicArea(bool recheck = false) - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsAnyPlayerInDynamicArea(bool recheck = false) => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool IsAnyPlayerInAnyDynamicArea(bool recheck = false) - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsAnyPlayerInAnyDynamicArea(bool recheck = false) => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int GetPlayerNumberDynamicAreas(int playerid) - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual int GetPlayerNumberDynamicAreas(int playerid) => throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicCheckpoint.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicCheckpoint.cs index 9eaf1f1..3054619 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicCheckpoint.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicCheckpoint.cs @@ -16,25 +16,18 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicCheckpoint : BaseNativeComponent { - public class NativeDynamicCheckpoint : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamicCP() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamicCP() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool DestroyDynamicCP() - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual bool DestroyDynamicCP() => throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicMapIcon.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicMapIcon.cs index 2585876..2c31fd4 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicMapIcon.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicMapIcon.cs @@ -16,25 +16,18 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicMapIcon : BaseNativeComponent { - public class NativeDynamicMapIcon : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamicMapIcon() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamicMapIcon() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool DestroyDynamicMapIcon() - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual bool DestroyDynamicMapIcon() => throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicPickup.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicPickup.cs index 1bff55a..d51526b 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicPickup.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicPickup.cs @@ -16,25 +16,18 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicPickup : BaseNativeComponent { - public class NativeDynamicPickup : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamicPickup() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamicPickup() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int DestroyDynamicPickup() - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual int DestroyDynamicPickup() => throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicRaceCheckpoint.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicRaceCheckpoint.cs index 5f2cb8f..9e876bc 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicRaceCheckpoint.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicRaceCheckpoint.cs @@ -16,25 +16,18 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicRaceCheckpoint : BaseNativeComponent { - public class NativeDynamicRaceCheckpoint : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamicRaceCP() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamicRaceCP() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool DestroyDynamicRaceCP() - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual bool DestroyDynamicRaceCP() => throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicTextLabel.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicTextLabel.cs index 95da5d0..94d5464 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicTextLabel.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicTextLabel.cs @@ -16,37 +16,26 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicTextLabel : BaseNativeComponent { - public class NativeDynamicTextLabel : BaseNativeComponent - { - /// - /// Identifier indicating the handle is invalid. - /// - public const int InvalidId = 0xFFFF; + /// + /// Identifier indicating the handle is invalid. + /// + public const int InvalidId = 0xFFFF; - [NativeMethod] - public virtual bool IsValidDynamic3DTextLabel() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool IsValidDynamic3DTextLabel() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual bool DestroyDynamic3DTextLabel() - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual bool DestroyDynamic3DTextLabel() => throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int GetDynamic3DTextLabelText(out string text, int maxlength) - { - throw new NativeNotImplementedException(); - } + [NativeMethod] + public virtual int GetDynamic3DTextLabelText(out string text, int maxlength) => + throw new NativeNotImplementedException(); - [NativeMethod] - public virtual int UpdateDynamic3DTextLabelText(int color, string text) - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod] + public virtual int UpdateDynamic3DTextLabelText(int color, string text) => + throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicWoldObject.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicWoldObject.cs index 995d2b0..51a0b25 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicWoldObject.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeDynamicWoldObject.cs @@ -16,14 +16,11 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeDynamicWorldObject : NativeComponent { - public class NativeDynamicWorldObject : NativeComponent - { - [NativeMethod(Function = "Streamer_ToggleItem")] - public virtual bool ToggleItem(int playerid, int type, int id, bool toggle) - { - throw new NativeNotImplementedException(); - } - } + [NativeMethod(Function = "Streamer_ToggleItem")] + public virtual bool ToggleItem(int playerid, int type, int id, bool toggle) => + throw new NativeNotImplementedException(); } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/NativeComponents/NativeStreamerPlayer.cs b/src/SampSharp.Streamer.Entities/NativeComponents/NativeStreamerPlayer.cs index b6c2d46..d80e490 100644 --- a/src/SampSharp.Streamer.Entities/NativeComponents/NativeStreamerPlayer.cs +++ b/src/SampSharp.Streamer.Entities/NativeComponents/NativeStreamerPlayer.cs @@ -16,84 +16,56 @@ using SampSharp.Core.Natives.NativeObjects; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class NativeStreamerPlayer : BaseNativeComponent { - public class NativeStreamerPlayer : BaseNativeComponent - { - #region Objects - - [NativeMethod] - public virtual void EditDynamicObject(int dynamicObjectId) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetPlayerCameraTargetDynObject() - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Checkpoints - - [NativeMethod] - public virtual bool IsPlayerInDynamicCP(int dynamicCheckpointId) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetPlayerVisibleDynamicCP() - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Race Checkpoints - - [NativeMethod] - public virtual bool IsPlayerInDynamicRaceCP(int dynamicRaceCheckpointId) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetPlayerVisibleDynamicRaceCP() - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Area - - [NativeMethod] - public virtual bool IsPlayerInDynamicArea(int dynamicAreaId, bool recheck = false) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool IsPlayerInAnyDynamicArea(bool recheck = false) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetPlayerNumberDynamicAreas() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int GetPlayerDynamicAreas(out int[] areas, int maxlength) - { - throw new NativeNotImplementedException(); - } - - #endregion - } + #region Objects + + [NativeMethod] + public virtual void EditDynamicObject(int dynamicObjectId) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetPlayerCameraTargetDynObject() => throw new NativeNotImplementedException(); + + #endregion + + #region Checkpoints + + [NativeMethod] + public virtual bool IsPlayerInDynamicCP(int dynamicCheckpointId) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetPlayerVisibleDynamicCP() => throw new NativeNotImplementedException(); + + #endregion + + #region Race Checkpoints + + [NativeMethod] + public virtual bool IsPlayerInDynamicRaceCP(int dynamicRaceCheckpointId) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetPlayerVisibleDynamicRaceCP() => throw new NativeNotImplementedException(); + + #endregion + + #region Area + + [NativeMethod] + public virtual bool IsPlayerInDynamicArea(int dynamicAreaId, bool recheck = false) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool IsPlayerInAnyDynamicArea(bool recheck = false) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetPlayerNumberDynamicAreas() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int GetPlayerDynamicAreas(out int[] areas, int maxlength) => + throw new NativeNotImplementedException(); + + #endregion } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/PlayerExtensions.cs b/src/SampSharp.Streamer.Entities/PlayerExtensions.cs index bd29e86..ed03751 100644 --- a/src/SampSharp.Streamer.Entities/PlayerExtensions.cs +++ b/src/SampSharp.Streamer.Entities/PlayerExtensions.cs @@ -4,129 +4,124 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Provides streamer methods for components. +/// +public static class PlayerExtensions { /// - /// Provides streamer methods for components. + /// Starts the object editor for the specified . + /// + /// The player. + /// The object for which to open the editor. + public static void EditDynamicObject(this Player player, EntityId dynamicObject) => + player.GetComponent().EditDynamicObject(dynamicObject); + + /// + /// Gets the dynamic object the player is currently targeting. /// - public static class PlayerExtensions + /// The player. + /// The dynamic object the player is currently targeting. + public static EntityId GetCameraTargetDynamicObject(this Player player) { - /// - /// Starts the object editor for the specified . - /// - /// The player. - /// The object for which to open the editor. - public static void EditDynamicObject(this Player player, EntityId dynamicObject) - { - player.GetComponent().EditDynamicObject(dynamicObject); - } + var id = player.GetComponent().GetPlayerCameraTargetDynObject(); + return id == NativeDynamicObject.InvalidId ? EntityId.Empty : StreamerEntities.GetDynamicObjectId(id); + } - /// - /// Gets the dynamic object the player is currently targeting. - /// - /// The player. - /// The dynamic object the player is currently targeting. - public static EntityId GetCameraTargetDynamicObject(this Player player) - { - var id = player.GetComponent().GetPlayerCameraTargetDynObject(); - return id == NativeDynamicObject.InvalidId ? EntityId.Empty : StreamerEntities.GetDynamicObjectId(id); - } + /// + /// Gets a value indicating whether the player is in the specified . + /// + /// The player. + /// The checkpoint. + /// true if the player is currently in the checkpoint; otherwise false. + public static bool IsInDynamicCheckpoint(this Player player, EntityId dynamicCheckpoint) => + player.GetComponent().IsPlayerInDynamicCP(dynamicCheckpoint); - /// - /// Gets a value indicating whether the player is in the specified . - /// - /// The player. - /// The checkpoint. - /// true if the player is currently in the checkpoint; otherwise false. - public static bool IsInDynamicCheckpoint(this Player player, EntityId dynamicCheckpoint) - { - return player.GetComponent().IsPlayerInDynamicCP(dynamicCheckpoint); - } + /// + /// Gets the currently visible checkpoint for the player. + /// + /// The player. + /// The currently visible checkpoint. + public static EntityId GetVisibleDynamicCheckpoint(this Player player) + { + var id = player.GetComponent().GetPlayerVisibleDynamicCP(); + return id == NativeDynamicCheckpoint.InvalidId ? EntityId.Empty : StreamerEntities.GetDynamicCheckpointId(id); + } - /// - /// Gets the currently visible checkpoint for the player. - /// - /// The player. - /// The currently visible checkpoint. - public static EntityId GetVisibleDynamicCheckpoint(this Player player) - { - var id = player.GetComponent().GetPlayerVisibleDynamicCP(); - return id == NativeDynamicCheckpoint.InvalidId ? EntityId.Empty : StreamerEntities.GetDynamicCheckpointId(id); - } - - /// - /// Gets a value indicating whether the player is in the specified . - /// - /// The player. - /// The race checkpoint. - /// true if the player is currently in the checkpoint; otherwise false. - public static bool IsInDynamicRaceCheckpoint(this Player player, EntityId dynamicRaceCheckpoint) - { - return player.GetComponent().IsPlayerInDynamicRaceCP(dynamicRaceCheckpoint); - } - - /// - /// Gets the currently visible race checkpoint for the player. - /// - /// The player. - /// The currently visible race checkpoint. - public static EntityId GetVisibleDynamicRaceCheckpoint(this Player player) - { - var id = player.GetComponent().GetPlayerVisibleDynamicRaceCP(); - return id == NativeDynamicRaceCheckpoint.InvalidId ? EntityId.Empty : StreamerEntities.GetDynamicRaceCheckpointId(id); - } + /// + /// Gets a value indicating whether the player is in the specified . + /// + /// The player. + /// The race checkpoint. + /// true if the player is currently in the checkpoint; otherwise false. + public static bool IsInDynamicRaceCheckpoint(this Player player, EntityId dynamicRaceCheckpoint) => + player.GetComponent().IsPlayerInDynamicRaceCP(dynamicRaceCheckpoint); - /// - /// Gets a value indicating whether the player is in the specified . - /// - /// The player. - /// The area. - /// false when a cached value may be used. - /// true if the player is currently in the area; otherwise false. - public static bool IsPlayerInDynamicArea(this Player player, EntityId dynamicArea, bool recheck = false) - { - return player.GetComponent().IsPlayerInDynamicArea(dynamicArea, recheck); - } + /// + /// Gets the currently visible race checkpoint for the player. + /// + /// The player. + /// The currently visible race checkpoint. + public static EntityId GetVisibleDynamicRaceCheckpoint(this Player player) + { + var id = player.GetComponent().GetPlayerVisibleDynamicRaceCP(); + return id == NativeDynamicRaceCheckpoint.InvalidId + ? EntityId.Empty + : StreamerEntities.GetDynamicRaceCheckpointId(id); + } - /// - /// Gets a value indicating whether the player is currently in any dynamic area. - /// - /// The player. - /// false when a cached value may be used. - /// A value indicating whether the player is currently in any dynamic area. - public static bool IsPlayerInAnyDynamicArea(this Player player, bool recheck = false) - { - return player.GetComponent().IsPlayerInAnyDynamicArea(recheck); - } + /// + /// Gets a value indicating whether the player is in the specified . + /// + /// The player. + /// The area. + /// false when a cached value may be used. + /// true if the player is currently in the area; otherwise false. + public static bool IsPlayerInDynamicArea(this Player player, EntityId dynamicArea, bool recheck = false) => + player.GetComponent().IsPlayerInDynamicArea(dynamicArea, recheck); - /// - /// Gets the number of areas the player is currently in. - /// - /// The player. - /// The number of areas the player is currently in. - public static int GetAreaCountForPlayer(this Player player) - { - if (player == null) - throw new ArgumentNullException(nameof(player)); + /// + /// Gets a value indicating whether the player is currently in any dynamic area. + /// + /// The player. + /// false when a cached value may be used. + /// A value indicating whether the player is currently in any dynamic area. + public static bool IsPlayerInAnyDynamicArea(this Player player, bool recheck = false) => + player.GetComponent().IsPlayerInAnyDynamicArea(recheck); - return player.GetComponent().GetPlayerNumberDynamicAreas(); + /// + /// Gets the number of areas the player is currently in. + /// + /// The player. + /// The number of areas the player is currently in. + public static int GetAreaCountForPlayer(this Player player) + { + if (player == null) + { + throw new ArgumentNullException(nameof(player)); } - /// - /// Gets the areas the player is currently in. - /// - /// The player. - /// The areas the player is currently in. - public static IEnumerable GetAreasForPlayer(this Player player) + return player.GetComponent().GetPlayerNumberDynamicAreas(); + } + + /// + /// Gets the areas the player is currently in. + /// + /// The player. + /// The areas the player is currently in. + public static IEnumerable GetAreasForPlayer(this Player player) + { + if (player == null) { - if (player == null) - throw new ArgumentNullException(nameof(player)); + throw new ArgumentNullException(nameof(player)); + } - player.GetComponent() - .GetPlayerDynamicAreas(out var areas, GetAreaCountForPlayer(player)); + player.GetComponent() + .GetPlayerDynamicAreas(out var areas, player.GetAreaCountForPlayer()); - return areas.Select(StreamerEntities.GetDynamicAreaId); - } + return areas.Select(StreamerEntities.GetDynamicAreaId); } } \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj.DotSettings b/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj.DotSettings index a3b906f..14dce49 100644 --- a/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj.DotSettings +++ b/src/SampSharp.Streamer.Entities/SampSharp.Streamer.Entities.csproj.DotSettings @@ -1,7 +1,12 @@ - + True - True - True - True - True - True \ No newline at end of file + True + True + True + True + True \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Services/IStreamerService.cs b/src/SampSharp.Streamer.Entities/Services/IStreamerService.cs index 9846124..ea54ee5 100644 --- a/src/SampSharp.Streamer.Entities/Services/IStreamerService.cs +++ b/src/SampSharp.Streamer.Entities/Services/IStreamerService.cs @@ -16,450 +16,461 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Provides functionality for adding entities to and controlling the Streamer. +/// +public interface IStreamerService { + #region Objects + + /// + /// Creates a new Dynamic Object in the world. + /// + /// The model id. + /// The position. + /// The rotation. + /// The virtual world. + /// The interior. + /// The attached player. + /// The stream distance. + /// The draw distance. + /// The attached area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicObject CreateDynamicObject(int modelId, Vector3 position, Vector3 rotation, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, + float drawDistance = 0.0f, int areaid = -1, int priority = 0, EntityId parent = default); + + #endregion + + #region Pickups + + /// + /// Creates a new Dynamic Pickup in the world. + /// + /// The model id. + /// The pickup type. + /// The position. + /// The virtual world. + /// The interior. + /// The attached player. + /// The stream distance. + /// The attached area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicPickup CreateDynamicPickup(int modelId, PickupType pickupType, Vector3 position, int virtualWorld = -1, + int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default); + + #endregion + + #region Checkpoint + + /// + /// Creates a new Dynamic Checkpoint in the world. + /// + /// The position. + /// The size. + /// The virtual world. + /// The interior. + /// The attached player. + /// The stream distance. + /// The attached area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicCheckpoint CreateDynamicCheckpoint(Vector3 position, float size, int virtualWorld = -1, int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default); + + #endregion + + #region Race Checkpoint + + /// + /// Creates a new Dynamic Race Checkpoint in the world. + /// + /// The check point type. + /// The position. + /// The next position. + /// The size. + /// The virtual world. + /// The interior. + /// The attached player. + /// The stream distance. + /// The attached area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicRaceCheckpoint CreateDynamicRaceCheckpoint(CheckpointType type, Vector3 position, Vector3 nextPosition, + float size, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, int areaid = -1, + int priority = 0, + EntityId parent = default); + + #endregion + + #region Map Icon + + /// + /// Creates a new Dynamic Map Icon in the world. + /// + /// The position. + /// The map icon type. + /// The color. + /// The virtual world. + /// The interior. + /// The attached player. + /// The stream distance. + /// The map icon style. + /// The attached area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicMapIcon CreateDynamicMapIcon(Vector3 position, MapIcon mapIcon, Color color, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, + MapIconType style = MapIconType.Local, int areaid = -1, int priority = 0, EntityId parent = default); + + #endregion + + #region Text Labels + + /// + /// Creates a new Dynamic Text Label in the world. + /// + /// The text. + /// The color. + /// The position. + /// The draw distance. + /// The attach player. + /// The attache vehicle. + /// The test los. + /// The virtual world. + /// The interior. + /// The player. + /// The stream distance. + /// The area id. + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicTextLabel CreateDynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, + Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLos = false, int virtualWorld = -1, + int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default); + + #endregion + + #region General + + /// + /// Gets the current maximum item amount (number of items that can be created with the plugin natives) for specified + /// item type. + /// + /// The item type. + /// + /// + /// + int GetMaxItems(StreamerType type); + + /// + /// Sets the current maximum item amount (number of items that can be created with the plugin natives) for the + /// specified item type. + /// + /// The item type. + /// The maximum item amount (-1 for no imposed limit). + /// + /// + /// + int SetMaxItems(StreamerType type, int items); + + /// + /// Gets the current visible item amount (number of items that can be streamed) for the specified item type and player. + /// + /// The item type. + /// The player ID. + /// + /// + /// + int GetVisibleItems(StreamerType type, EntityId playerid); + + /// + /// Gets the current visible item amount (number of items that can be streamed) for the specified item type and player. + /// + /// The item type. + /// The maximum item amount (-1 for no imposed limit). + /// The player ID. + /// + /// + /// + int SetVisibleItems(StreamerType type, int items, EntityId playerid); + + /// + /// Sets the current streaming radius multiplier for the specified item type and player. + /// + /// The item type. + /// The float multiplier. + /// The player ID. + /// + /// + /// + int SetRadiusMultiplier(StreamerType type, float multiplier, EntityId playerid); + + #endregion + + #region Updates + + /// + /// Updates any item that is currently active (that is, moving or attached), including: + /// + /// + /// + /// Moving and attached objects. + /// + /// + /// + /// + /// Attached areas and 3D text labels. + /// + /// + /// + /// + void ProcessActiveItems(); + + /// + /// Toggles whether updates are issued while the player is idle. + /// By default, this is turned off. + /// + /// The player. + /// false to turn off, true to turn on. + /// + /// false on failure, true on success. + /// + /// + bool ToggleIdleUpdate(EntityId player, bool toggle); + + /// + /// Returns whether Streamer_ToggleIdleUpdate is enabled for the player. + /// + /// The player. + /// + /// + /// + bool IsToggleIdleUpdate(EntityId player); + + /// + /// Toggles whether updates are based on the player's current camera position + /// rather than the player's current world position. + /// + /// By default, this is turned off. + /// + /// + /// The player. + /// false to turn off, true to turn on. + /// + /// false on failure, true on success. + /// + /// + bool ToggleCameraUpdate(EntityId player, bool toggle); + + /// + /// Returns whether Streamer_ToggleCameraUpdate is enabled for the player. + /// + /// The player. + /// + /// + /// + bool IsToggleCameraUpdate(EntityId player); + + /// + /// Toggles whether updates are issued for the specified player and item type. + /// + /// The player. + /// The item type. + /// false to turn off, true to turn on. + /// + /// false on failure, true on success. + /// + /// + bool ToggleItemUpdate(EntityId player, StreamerType type, bool toggle); + + /// + /// Returns whether Streamer_ToggleItemUpdate + /// is enabled for the specified player and item type. + /// + /// By default, every item type is turned on, except for NPCs. + /// + /// + /// The player. + /// The item type. + /// + /// + /// + bool IsToggleItemUpdate(EntityId player, StreamerType type); + + /// + /// Issues an update for the player. + /// + /// The player. + /// The item type. + /// + /// false on failure, true on success. + /// + /// + bool Update(EntityId player, StreamerType type); + + /// + /// Issues an update for the player at a specific position. + /// + /// The player. + /// The position. + /// The virtual world. + /// The interior. + /// The item type. + /// The compensated time in milliseconds. + /// The freeze player (0 to turn off, 1 to turn on). + /// + /// + /// + bool UpdateEx(EntityId player, Vector3 position, int virtualWorld = -1, int interior = -1, + StreamerType type = StreamerType.All, int compensatedtime = -1, int freezeplayer = 1); + + #endregion + + #region Area + + /// + /// Creates a new dynamic circle in the world. + /// + /// The position. + /// The size. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateCircle(Vector2 position, float size, int virtualWorld = -1, int interior = -1, + Player player = null, int priority = 0, EntityId parent = default); + + /// + /// Creates a new dynamic cylinder in the world. + /// + /// The position. + /// The minz. + /// The maxz. + /// The size. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateCylinder(Vector2 position, float minz, float maxz, float size, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); + + /// + /// Creates a new dynamic sphere in the world. + /// + /// The position. + /// The size. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateSphere(Vector3 position, float size, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); + + /// + /// Creates a new dynamic rectange in the world. + /// + /// The min XY. + /// The max XY. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateRectangle(Vector2 min, Vector2 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); + + /// + /// Creates a new dynamic cuboid in the world. + /// + /// The min XYZ. + /// The max XYZ. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateCuboid(Vector3 min, Vector3 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); + + /// + /// Creates a new dynamic cube in the world. + /// + /// The min XYZ. + /// The max XYZ. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreateCube(Vector3 min, Vector3 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, + EntityId parent = default); + /// - /// Provides functionality for adding entities to and controlling the Streamer. + /// Creates a new dynamic polygon in the world. /// - public interface IStreamerService - { - #region General - /// - /// Gets the current maximum item amount (number of items that can be created with the plugin natives) for specified item type. - /// - /// The item type. - /// - /// - /// - int GetMaxItems(StreamerType type); - - /// - /// Sets the current maximum item amount (number of items that can be created with the plugin natives) for the specified item type. - /// - /// The item type. - /// The maximum item amount (-1 for no imposed limit). - /// - /// - /// - int SetMaxItems(StreamerType type, int items); - - /// - /// Gets the current visible item amount (number of items that can be streamed) for the specified item type and player. - /// - /// The item type. - /// The player ID. - /// - /// - /// - int GetVisibleItems(StreamerType type, EntityId playerid); - - /// - /// Gets the current visible item amount (number of items that can be streamed) for the specified item type and player. - /// - /// The item type. - /// The maximum item amount (-1 for no imposed limit). - /// The player ID. - /// - /// - /// - int SetVisibleItems(StreamerType type, int items, EntityId playerid); - - /// - /// Sets the current streaming radius multiplier for the specified item type and player. - /// - /// The item type. - /// The float multiplier. - /// The player ID. - /// - /// - /// - int SetRadiusMultiplier(StreamerType type, float multiplier, EntityId playerid); - #endregion - - #region Updates - - /// - /// Updates any item that is currently active (that is, moving or attached), including: - /// - /// - /// - /// Moving and attached objects. - /// - /// - /// - /// - /// Attached areas and 3D text labels. - /// - /// - /// - /// - void ProcessActiveItems(); - - /// - /// Toggles whether updates are issued while the player is idle. - /// By default, this is turned off. - /// - /// The player. - /// false to turn off, true to turn on. - /// - /// false on failure, true on success. - /// - /// - bool ToggleIdleUpdate(EntityId player, bool toggle); - - /// - /// Returns whether Streamer_ToggleIdleUpdate is enabled for the player. - /// - /// The player. - /// - /// - /// - bool IsToggleIdleUpdate(EntityId player); - - /// - /// Toggles whether updates are based on the player's current camera position - /// rather than the player's current world position. - /// - /// By default, this is turned off. - /// - /// - /// The player. - /// false to turn off, true to turn on. - /// - /// false on failure, true on success. - /// - /// - bool ToggleCameraUpdate(EntityId player, bool toggle); - - /// - /// Returns whether Streamer_ToggleCameraUpdate is enabled for the player. - /// - /// The player. - /// - /// - /// - bool IsToggleCameraUpdate(EntityId player); - - /// - /// Toggles whether updates are issued for the specified player and item type. - /// - /// The player. - /// The item type. - /// false to turn off, true to turn on. - /// - /// false on failure, true on success. - /// - /// - bool ToggleItemUpdate(EntityId player, StreamerType type, bool toggle); - - /// - /// Returns whether Streamer_ToggleItemUpdate - /// is enabled for the specified player and item type. - /// - /// By default, every item type is turned on, except for NPCs. - /// - /// - /// The player. - /// The item type. - /// - /// - /// - bool IsToggleItemUpdate(EntityId player, StreamerType type); - - /// - /// Issues an update for the player. - /// - /// The player. - /// The item type. - /// - /// false on failure, true on success. - /// - /// - bool Update(EntityId player, StreamerType type); - - /// - /// Issues an update for the player at a specific position. - /// - /// The player. - /// The position. - /// The virtual world. - /// The interior. - /// The item type. - /// The compensated time in milliseconds. - /// The freeze player (0 to turn off, 1 to turn on). - /// - /// - /// - bool UpdateEx(EntityId player, Vector3 position, int virtualWorld = -1, int interior = -1, StreamerType type = StreamerType.All, int compensatedtime = -1, int freezeplayer = 1); - - #endregion - - #region Objects - - /// - /// Creates a new Dynamic Object in the world. - /// - /// The model id. - /// The position. - /// The rotation. - /// The virtual world. - /// The interior. - /// The attached player. - /// The stream distance. - /// The draw distance. - /// The attached area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicObject CreateDynamicObject(int modelId, Vector3 position, Vector3 rotation, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, - float drawDistance = 0.0f, int areaid = -1, int priority = 0, EntityId parent = default); - - #endregion - - #region Pickups - - /// - /// Creates a new Dynamic Pickup in the world. - /// - /// The model id. - /// The pickup type. - /// The position. - /// The virtual world. - /// The interior. - /// The attached player. - /// The stream distance. - /// The attached area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicPickup CreateDynamicPickup(int modelId, PickupType pickupType, Vector3 position, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default); - - #endregion - - #region Checkpoint - - /// - /// Creates a new Dynamic Checkpoint in the world. - /// - /// The position. - /// The size. - /// The virtual world. - /// The interior. - /// The attached player. - /// The stream distance. - /// The attached area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicCheckpoint CreateDynamicCheckpoint(Vector3 position, float size, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default); - - #endregion - - #region Race Checkpoint - - /// - /// Creates a new Dynamic Race Checkpoint in the world. - /// - /// The check point type. - /// The position. - /// The next position. - /// The size. - /// The virtual world. - /// The interior. - /// The attached player. - /// The stream distance. - /// The attached area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicRaceCheckpoint CreateDynamicRaceCheckpoint(CheckpointType type, Vector3 position, Vector3 nextPosition, float size, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, - EntityId parent = default); - - #endregion - - #region Map Icon - - /// - /// Creates a new Dynamic Map Icon in the world. - /// - /// The position. - /// The map icon type. - /// The color. - /// The virtual world. - /// The interior. - /// The attached player. - /// The stream distance. - /// The map icon style. - /// The attached area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicMapIcon CreateDynamicMapIcon(Vector3 position, MapIcon mapIcon, Color color, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, - MapIconType style = MapIconType.Local, int areaid = -1, int priority = 0, EntityId parent = default); - - #endregion - - #region Text Labels - - /// - /// Creates a new Dynamic Text Label in the world. - /// - /// The text. - /// The color. - /// The position. - /// The draw distance. - /// The attach player. - /// The attache vehicle. - /// The test los. - /// The virtual world. - /// The interior. - /// The player. - /// The stream distance. - /// The area id. - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicTextLabel CreateDynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, - Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLos = false, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default); - - #endregion - - #region Area - - /// - /// Creates a new dynamic circle in the world. - /// - /// The position. - /// The size. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateCircle(Vector2 position, float size, int virtualWorld = -1, int interior = -1, - Player player = null, int priority = 0, EntityId parent = default); - - /// - /// Creates a new dynamic cylinder in the world. - /// - /// The position. - /// The minz. - /// The maxz. - /// The size. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateCylinder(Vector2 position, float minz, float maxz, float size, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); - - /// - /// Creates a new dynamic sphere in the world. - /// - /// The position. - /// The size. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateSphere(Vector3 position, float size, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); - - /// - /// Creates a new dynamic rectange in the world. - /// - /// The min XY. - /// The max XY. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateRectangle(Vector2 min, Vector2 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); - - /// - /// Creates a new dynamic cuboid in the world. - /// - /// The min XYZ. - /// The max XYZ. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateCuboid(Vector3 min, Vector3 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); - - /// - /// Creates a new dynamic cube in the world. - /// - /// The min XYZ. - /// The max XYZ. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreateCube(Vector3 min, Vector3 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, - EntityId parent = default); - - /// - /// Creates a new dynamic polygon in the world. - /// - /// The points. - /// The minz. - /// The maxz. - /// The virtual world. - /// The interior. - /// The player - /// The priority. - /// The EntityId parent. - /// - /// - /// - DynamicArea CreatePolygon(float[] points, float minz = float.NegativeInfinity, float maxz = float.PositiveInfinity, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); - - #endregion - } -} + /// The points. + /// The minz. + /// The maxz. + /// The virtual world. + /// The interior. + /// The player + /// The priority. + /// The EntityId parent. + /// + /// + /// + DynamicArea CreatePolygon(float[] points, float minz = float.NegativeInfinity, float maxz = float.PositiveInfinity, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default); + + #endregion +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Services/StreamerService.cs b/src/SampSharp.Streamer.Entities/Services/StreamerService.cs index d1a6f44..273b0bd 100644 --- a/src/SampSharp.Streamer.Entities/Services/StreamerService.cs +++ b/src/SampSharp.Streamer.Entities/Services/StreamerService.cs @@ -16,456 +16,492 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Represents a service for adding entities to and control the Streamer. +/// +public class StreamerService : IStreamerService { + private readonly IEntityManager _entityManager; + private readonly StreamerServiceNative _native; + /// - /// Represents a service for adding entities to and control the Streamer. + /// Initializes a new instance of the class. /// - public class StreamerService : IStreamerService + public StreamerService(IEntityManager entityManager, INativeProxy nativeProxy) { - private readonly IEntityManager _entityManager; - private readonly StreamerServiceNative _native; + _entityManager = entityManager; + _native = nativeProxy.Instance; + } - /// - /// Initializes a new instance of the class. - /// - public StreamerService(IEntityManager entityManager, INativeProxy nativeProxy) - { - _entityManager = entityManager; - _native = nativeProxy.Instance; - } + #region Objects - #region Settings - /// - public int GetMaxItems(StreamerType type) - { - return _native.Streamer_GetMaxItems((int)type); - } + /// + public DynamicObject CreateDynamicObject(int modelId, Vector3 position, Vector3 rotation, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 300.0f, + float drawDistance = 0.0f, int areaid = -1, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicObject(modelId, position.X, position.Y, position.Z, + rotation.X, rotation.Y, rotation.Z, virtualWorld, interior, player ? player.Entity.Handle : -1, + streamDistance, drawDistance, areaid, priority); - /// - public int SetMaxItems(StreamerType type, int items) + if (id == NativeDynamicObject.InvalidId) { - return _native.Streamer_SetMaxItems((int)type, items); + throw new EntityCreationException(); } - /// - public int GetVisibleItems(StreamerType type, EntityId player) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } - - return _native.Streamer_GetVisibleItems((int)type, player.Handle); - } + var entity = StreamerEntities.GetDynamicObjectId(id); + _entityManager.Create(entity, parent); - /// - public int SetVisibleItems(StreamerType type, int items, EntityId player) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - return _native.Streamer_SetVisibleItems((int)type, items, player.Handle); - } + return _entityManager.AddComponent(entity); + } - /// - public int SetRadiusMultiplier(StreamerType type, float multiplier, EntityId player) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + #endregion - return _native.Streamer_SetRadiusMultiplier((int)type, multiplier, player.Handle); - } - #endregion + #region Pickups - #region Updates + /// + public DynamicPickup CreateDynamicPickup(int modelId, PickupType pickupType, Vector3 position, + int virtualWorld = -1, int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default) + { + var id = _native.CreateDynamicPickup(modelId, (int)pickupType, position.X, position.Y, position.Z, virtualWorld, + interior, + player ? player.Entity.Handle : -1, streamDistance, areaid, priority); - /// - public void ProcessActiveItems() + if (id == NativeDynamicPickup.InvalidId) { - _native.Streamer_ProcessActiveItems(); + throw new EntityCreationException(); } - /// - public bool ToggleIdleUpdate(EntityId player, bool toggle) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + var entity = StreamerEntities.GetDynamicPickupId(id); + _entityManager.Create(entity, parent); - var success = _native.Streamer_ToggleIdleUpdate(player.Handle, toggle); - return success; - } + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - /// - public bool IsToggleIdleUpdate(EntityId player) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + return _entityManager.AddComponent(entity, position); + } - var isToggled = _native.Streamer_IsToggleIdleUpdate(player.Handle); - return isToggled; - } + #endregion - /// - public bool ToggleCameraUpdate(EntityId player, bool toggle) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + #region Checkpoints - var success = _native.Streamer_ToggleCameraUpdate(player.Handle, toggle); - return success; - } + /// + public DynamicCheckpoint CreateDynamicCheckpoint(Vector3 position, float size, int virtualWorld = -1, + int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default) + { + var id = _native.CreateDynamicCP(position.X, position.Y, position.Z, size, virtualWorld, interior, + player ? player.Entity.Handle : -1, streamDistance, areaid, priority); - /// - public bool IsToggleCameraUpdate(EntityId player) + if (id == NativeDynamicCheckpoint.InvalidId) { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } - - var isToggled = _native.Streamer_IsToggleCameraUpdate(player.Handle); - return isToggled; + throw new EntityCreationException(); } - /// - public bool ToggleItemUpdate(EntityId player, StreamerType type, bool toggle) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + var entity = StreamerEntities.GetDynamicCheckpointId(id); + _entityManager.Create(entity, parent); - var success = _native.Streamer_ToggleItemUpdate(player.Handle, (int)type, toggle); - return success; - } + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - /// - public bool IsToggleItemUpdate(EntityId player, StreamerType type) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - { - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); - } + return _entityManager.AddComponent(entity, position, size); + } - var isToggled = _native.Streamer_IsToggleItemUpdate(player.Handle, (int)type); - return isToggled; - } + #endregion - /// - public bool Update(EntityId player, StreamerType type) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + #region Race Checkpoints - var success = _native.Streamer_Update(player.Handle, (int)type); + /// + public DynamicRaceCheckpoint CreateDynamicRaceCheckpoint(CheckpointType type, Vector3 position, + Vector3 nextPosition, float size, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, int areaid = -1, + int priority = 0, + EntityId parent = default) + { + var id = _native.CreateDynamicRaceCP((int)type, position.X, position.Y, position.Z, nextPosition.X, + nextPosition.Y, nextPosition.Z, + size, virtualWorld, interior, player ? player.Entity.Handle : -1, streamDistance, areaid, priority); - return success; + if (id == NativeDynamicRaceCheckpoint.InvalidId) + { + throw new EntityCreationException(); } - /// - public bool UpdateEx(EntityId player, Vector3 position, int virtualWorld = -1, int interior = -1, StreamerType type = StreamerType.All, int compensatedtime = -1, int freezeplayer = 1) - { - if (!player.IsOfAnyType(SampEntities.PlayerType)) - throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + var entity = StreamerEntities.GetDynamicRaceCheckpointId(id); + _entityManager.Create(entity, parent); - var success = _native.Streamer_UpdateEx(player.Handle, position.X, position.Y, position.Z, virtualWorld, interior, (int)type, compensatedtime, freezeplayer); + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - return success; - } + return _entityManager.AddComponent(entity, position, nextPosition); + } - #endregion + #endregion - #region Objects + #region Map Icon - /// - public DynamicObject CreateDynamicObject(int modelId, Vector3 position, Vector3 rotation, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 300.0f, - float drawDistance = 0.0f, int areaid = -1, int priority = 0, EntityId parent = default) + /// + public DynamicMapIcon CreateDynamicMapIcon(Vector3 position, MapIcon mapIcon, Color color, + int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, + MapIconType style = MapIconType.Local, int areaid = -1, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicMapIcon(position.X, position.Y, position.Z, (int)mapIcon, color, + virtualWorld, interior, player ? player.Entity.Handle : -1, streamDistance, (int)style, areaid, priority); + + if (id == NativeDynamicMapIcon.InvalidId) { - var id = _native.CreateDynamicObject(modelId, position.X, position.Y, position.Z, - rotation.X, rotation.Y, rotation.Z, virtualWorld, interior, player ? player.Entity.Handle : -1, - streamDistance, drawDistance, areaid, priority); + throw new EntityCreationException(); + } - if (id == NativeDynamicObject.InvalidId) - throw new EntityCreationException(); + var entity = StreamerEntities.GetDynamicRaceCheckpointId(id); + _entityManager.Create(entity, parent); - var entity = StreamerEntities.GetDynamicObjectId(id); - _entityManager.Create(entity, parent); + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + return _entityManager.AddComponent(entity, position, mapIcon, style, color); + } - return _entityManager.AddComponent(entity); - } + #endregion - #endregion + #region Text Labels - #region Pickups + /// + public DynamicTextLabel CreateDynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, + Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLos = false, int virtualWorld = -1, + int interior = -1, + Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, + EntityId parent = default) + { + var id = _native.CreateDynamic3DTextLabel(text, color, position.X, position.Y, position.Z, + drawDistance, attachedPlayer ? attachedPlayer.Entity.Handle : 0xFFFF, + attachedVehicle ? attachedVehicle.Entity.Handle : 0xFFFF, testLos, virtualWorld, interior, + player ? player.Entity.Handle : -1, streamDistance, areaid, priority); - /// - public DynamicPickup CreateDynamicPickup(int modelId, PickupType pickupType, Vector3 position, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default) + if (id == NativeDynamicTextLabel.InvalidId) { - var id = _native.CreateDynamicPickup(modelId, (int)pickupType, position.X, position.Y, position.Z, virtualWorld, interior, - player ? player.Entity.Handle : -1, streamDistance, areaid, priority); + throw new EntityCreationException(); + } - if (id == NativeDynamicPickup.InvalidId) - throw new EntityCreationException(); + var entity = StreamerEntities.GetDynamicTextLabelId(id); - var entity = StreamerEntities.GetDynamicPickupId(id); - _entityManager.Create(entity, parent); + _entityManager.Create(entity, parent); - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); + _entityManager.AddComponent(entity); - return _entityManager.AddComponent(entity, position); - } + return _entityManager.AddComponent(entity, text, color, position, drawDistance, virtualWorld); + } - #endregion + #endregion - #region Checkpoints + #region Settings - /// - public DynamicCheckpoint CreateDynamicCheckpoint(Vector3 position, float size, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default) - { - var id = _native.CreateDynamicCP(position.X, position.Y, position.Z, size, virtualWorld, interior, - player ? player.Entity.Handle : -1, streamDistance, areaid, priority); + /// + public int GetMaxItems(StreamerType type) => _native.Streamer_GetMaxItems((int)type); - if (id == NativeDynamicCheckpoint.InvalidId) - throw new EntityCreationException(); + /// + public int SetMaxItems(StreamerType type, int items) => _native.Streamer_SetMaxItems((int)type, items); - var entity = StreamerEntities.GetDynamicCheckpointId(id); - _entityManager.Create(entity, parent); + /// + public int GetVisibleItems(StreamerType type, EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + return _native.Streamer_GetVisibleItems((int)type, player.Handle); + } - return _entityManager.AddComponent(entity, position, size); + /// + public int SetVisibleItems(StreamerType type, int items, EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); } - #endregion - - #region Race Checkpoints + return _native.Streamer_SetVisibleItems((int)type, items, player.Handle); + } - /// - public DynamicRaceCheckpoint CreateDynamicRaceCheckpoint(CheckpointType type, Vector3 position, Vector3 nextPosition, float size, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, - EntityId parent = default) + /// + public int SetRadiusMultiplier(StreamerType type, float multiplier, EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) { - var id = _native.CreateDynamicRaceCP((int)type, position.X, position.Y, position.Z, nextPosition.X, nextPosition.Y, nextPosition.Z, - size, virtualWorld, interior, player ? player.Entity.Handle : -1, streamDistance, areaid, priority); + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - if (id == NativeDynamicRaceCheckpoint.InvalidId) - throw new EntityCreationException(); + return _native.Streamer_SetRadiusMultiplier((int)type, multiplier, player.Handle); + } - var entity = StreamerEntities.GetDynamicRaceCheckpointId(id); - _entityManager.Create(entity, parent); + #endregion - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + #region Updates - return _entityManager.AddComponent(entity, position, nextPosition); - } + /// + public void ProcessActiveItems() => _native.Streamer_ProcessActiveItems(); - #endregion + /// + public bool ToggleIdleUpdate(EntityId player, bool toggle) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - #region Map Icon + var success = _native.Streamer_ToggleIdleUpdate(player.Handle, toggle); + return success; + } - /// - public DynamicMapIcon CreateDynamicMapIcon(Vector3 position, MapIcon mapIcon, Color color, - int virtualWorld = -1, int interior = -1, Player player = null, float streamDistance = 200.0f, - MapIconType style = MapIconType.Local, int areaid = -1, int priority = 0, EntityId parent = default) + /// + public bool IsToggleIdleUpdate(EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) { - var id = _native.CreateDynamicMapIcon(position.X, position.Y, position.Z, (int)mapIcon, color, - virtualWorld, interior, player ? player.Entity.Handle : -1, streamDistance, (int)style, areaid, priority); + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - if (id == NativeDynamicMapIcon.InvalidId) - throw new EntityCreationException(); + var isToggled = _native.Streamer_IsToggleIdleUpdate(player.Handle); + return isToggled; + } - var entity = StreamerEntities.GetDynamicRaceCheckpointId(id); - _entityManager.Create(entity, parent); + /// + public bool ToggleCameraUpdate(EntityId player, bool toggle) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + var success = _native.Streamer_ToggleCameraUpdate(player.Handle, toggle); + return success; + } - return _entityManager.AddComponent(entity, position, mapIcon, style, color); + /// + public bool IsToggleCameraUpdate(EntityId player) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); } - #endregion - - #region Text Labels + var isToggled = _native.Streamer_IsToggleCameraUpdate(player.Handle); + return isToggled; + } - /// - public DynamicTextLabel CreateDynamicTextLabel(string text, Color color, Vector3 position, float drawDistance, - Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLos = false, int virtualWorld = -1, int interior = -1, - Player player = null, float streamDistance = 200.0f, int areaid = -1, int priority = 0, EntityId parent = default) + /// + public bool ToggleItemUpdate(EntityId player, StreamerType type, bool toggle) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) { - var id = _native.CreateDynamic3DTextLabel(text, color, position.X, position.Y, position.Z, - drawDistance, attachedPlayer ? attachedPlayer.Entity.Handle : 0xFFFF, attachedVehicle ? attachedVehicle.Entity.Handle : 0xFFFF, testLos, virtualWorld, interior, - player ? player.Entity.Handle : -1, streamDistance, areaid, priority); - - if (id == NativeDynamicTextLabel.InvalidId) - throw new EntityCreationException(); + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - var entity = StreamerEntities.GetDynamicTextLabelId(id); + var success = _native.Streamer_ToggleItemUpdate(player.Handle, (int)type, toggle); + return success; + } - _entityManager.Create(entity, parent); + /// + public bool IsToggleItemUpdate(EntityId player, StreamerType type) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + var isToggled = _native.Streamer_IsToggleItemUpdate(player.Handle, (int)type); + return isToggled; + } - return _entityManager.AddComponent(entity, text, color, position, drawDistance, virtualWorld); + /// + public bool Update(EntityId player, StreamerType type) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) + { + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); } - #endregion + var success = _native.Streamer_Update(player.Handle, (int)type); - #region Area + return success; + } - /// - public DynamicArea CreateCircle(Vector2 position, float size, int virtualWorld = -1, int interior = -1, - Player player = null, int priority = 0, EntityId parent = default) + /// + public bool UpdateEx(EntityId player, Vector3 position, int virtualWorld = -1, int interior = -1, + StreamerType type = StreamerType.All, int compensatedtime = -1, int freezeplayer = 1) + { + if (!player.IsOfAnyType(SampEntities.PlayerType)) { - var id = _native.CreateDynamicCircle(position.X, position.Y, size, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + throw new InvalidEntityArgumentException(nameof(player), SampEntities.PlayerType); + } - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + var success = _native.Streamer_UpdateEx(player.Handle, position.X, position.Y, position.Z, virtualWorld, + interior, (int)type, compensatedtime, freezeplayer); - var entity = StreamerEntities.GetDynamicAreaId(id); + return success; + } - _entityManager.Create(entity, parent); + #endregion - _entityManager.AddComponent(entity); + #region Area - return _entityManager.AddComponent(entity); - } + /// + public DynamicArea CreateCircle(Vector2 position, float size, int virtualWorld = -1, int interior = -1, + Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicCircle(position.X, position.Y, size, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - /// - public DynamicArea CreateCylinder(Vector2 position, float minz, float maxz, float size, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + if (id == NativeDynamicArea.InvalidId) { - var id = _native.CreateDynamicCylinder(position.X, position.Y, minz, maxz, size, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + throw new EntityCreationException(); + } - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + var entity = StreamerEntities.GetDynamicAreaId(id); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.Create(entity, parent); - _entityManager.Create(entity, parent); + _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + return _entityManager.AddComponent(entity); + } - return _entityManager.AddComponent(entity); - } + /// + public DynamicArea CreateCylinder(Vector2 position, float minz, float maxz, float size, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicCylinder(position.X, position.Y, minz, maxz, size, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - /// - public DynamicArea CreateSphere(Vector3 position, float size, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + if (id == NativeDynamicArea.InvalidId) { - var id = _native.CreateDynamicSphere(position.X, position.Y, position.Z, size, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + throw new EntityCreationException(); + } - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + var entity = StreamerEntities.GetDynamicAreaId(id); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.Create(entity, parent); - _entityManager.Create(entity, parent); + _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + return _entityManager.AddComponent(entity); + } - return _entityManager.AddComponent(entity); - } + /// + public DynamicArea CreateSphere(Vector3 position, float size, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicSphere(position.X, position.Y, position.Z, size, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - /// - public DynamicArea CreateRectangle(Vector2 min, Vector2 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + if (id == NativeDynamicArea.InvalidId) { - var id = _native.CreateDynamicRectangle(min.X, min.Y, max.X, max.Y, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + throw new EntityCreationException(); + } - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + var entity = StreamerEntities.GetDynamicAreaId(id); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.Create(entity, parent); - _entityManager.Create(entity, parent); + _entityManager.AddComponent(entity); - _entityManager.AddComponent(entity); + return _entityManager.AddComponent(entity); + } - return _entityManager.AddComponent(entity); - } + /// + public DynamicArea CreateRectangle(Vector2 min, Vector2 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicRectangle(min.X, min.Y, max.X, max.Y, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - /// - public DynamicArea CreateCuboid(Vector3 min, Vector3 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + if (id == NativeDynamicArea.InvalidId) { - var id = _native.CreateDynamicCuboid(min.X, min.Y, min.Z, max.X, max.Y, max.Z, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + throw new EntityCreationException(); + } + + var entity = StreamerEntities.GetDynamicAreaId(id); - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + _entityManager.Create(entity, parent); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.AddComponent(entity); - _entityManager.Create(entity, parent); + return _entityManager.AddComponent(entity); + } - _entityManager.AddComponent(entity); + /// + public DynamicArea CreateCuboid(Vector3 min, Vector3 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicCuboid(min.X, min.Y, min.Z, max.X, max.Y, max.Z, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - return _entityManager.AddComponent(entity); + if (id == NativeDynamicArea.InvalidId) + { + throw new EntityCreationException(); } - /// - public DynamicArea CreateCube(Vector3 min, Vector3 max, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) - { - var id = _native.CreateDynamicCube(min.X, min.Y, min.Z, max.X, max.Y, max.Z, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + var entity = StreamerEntities.GetDynamicAreaId(id); - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + _entityManager.Create(entity, parent); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.AddComponent(entity); - _entityManager.Create(entity, parent); + return _entityManager.AddComponent(entity); + } - _entityManager.AddComponent(entity); + /// + public DynamicArea CreateCube(Vector3 min, Vector3 max, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicCube(min.X, min.Y, min.Z, max.X, max.Y, max.Z, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - return _entityManager.AddComponent(entity); + if (id == NativeDynamicArea.InvalidId) + { + throw new EntityCreationException(); } - /// - public DynamicArea CreatePolygon(float[] points, float minz = float.NegativeInfinity, float maxz = float.PositiveInfinity, - int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) - { - var id = _native.CreateDynamicPolygon(points, minz, maxz, points.Length, virtualWorld, interior, - player ? player.Entity.Handle : -1, priority); + var entity = StreamerEntities.GetDynamicAreaId(id); - if (id == NativeDynamicArea.InvalidId) - throw new EntityCreationException(); + _entityManager.Create(entity, parent); - var entity = StreamerEntities.GetDynamicAreaId(id); + _entityManager.AddComponent(entity); - _entityManager.Create(entity, parent); + return _entityManager.AddComponent(entity); + } - _entityManager.AddComponent(entity); + /// + public DynamicArea CreatePolygon(float[] points, float minz = float.NegativeInfinity, + float maxz = float.PositiveInfinity, + int virtualWorld = -1, int interior = -1, Player player = null, int priority = 0, EntityId parent = default) + { + var id = _native.CreateDynamicPolygon(points, minz, maxz, points.Length, virtualWorld, interior, + player ? player.Entity.Handle : -1, priority); - return _entityManager.AddComponent(entity); + if (id == NativeDynamicArea.InvalidId) + { + throw new EntityCreationException(); } - #endregion + var entity = StreamerEntities.GetDynamicAreaId(id); + + _entityManager.Create(entity, parent); + + _entityManager.AddComponent(entity); + + return _entityManager.AddComponent(entity); } -} + + #endregion +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/Services/StreamerServiceNative.cs b/src/SampSharp.Streamer.Entities/Services/StreamerServiceNative.cs index ac53b7e..5001f16 100644 --- a/src/SampSharp.Streamer.Entities/Services/StreamerServiceNative.cs +++ b/src/SampSharp.Streamer.Entities/Services/StreamerServiceNative.cs @@ -17,226 +17,168 @@ #pragma warning disable 1591 -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +public class StreamerServiceNative { - public class StreamerServiceNative - { - #region Settings - [NativeMethod] - public virtual int Streamer_GetMaxItems(int type) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int Streamer_SetMaxItems(int type, int items) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int Streamer_GetVisibleItems(int type, int playerid) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int Streamer_SetVisibleItems(int type, int items, int playerid) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int Streamer_SetRadiusMultiplier(int type, float multiplier, int playerid) - { - throw new NativeNotImplementedException(); - } - #endregion - - #region Updates - - [NativeMethod] - public virtual void Streamer_ProcessActiveItems() - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_ToggleIdleUpdate(int playerid, bool toggle) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_IsToggleIdleUpdate(int playerid) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_ToggleCameraUpdate(int playerid, bool toggle) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_IsToggleCameraUpdate(int playerid) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_ToggleItemUpdate(int playerid, int type, bool toggle) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_IsToggleItemUpdate(int playerid, int type) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual void Streamer_GetLastUpdateTime(out float time) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_Update(int playerid, int type) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual bool Streamer_UpdateEx(int playerid, float x, float y, float z, int worldid = -1, int interiorid = -1, int type = -1, int compensatedtime = -1, int freezeplayer = 1) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Objects - - [NativeMethod] - public virtual int CreateDynamicObject(int modelid, float x, float y, float z, float rx, float ry, float rz, - int worldid, int interiorid, int playerid, float streamdistance, float drawdistance, int areaid, - int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Pickups - - [NativeMethod] - public virtual int CreateDynamicPickup(int modelid, int type, float x, float y, float z, int worldid, - int interiorid, int playerid, float streamdistance, int areaid, int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Checkpoints - - [NativeMethod] - public virtual int CreateDynamicCP(float x, float y, float z, float size, int worldid, int interiorid, - int playerid, float streamdistance, int areaid, int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Race Checkpoints - - [NativeMethod] - public virtual int CreateDynamicRaceCP(int type, float x, float y, float z, float nextx, float nexty, - float nextz, float size, int worldid, int interiorid, int playerid, float streamdistance, int areaid, - int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Map Icon - - [NativeMethod] - public virtual int CreateDynamicMapIcon(float x, float y, float z, int type, int color, int worldid, - int interiorid, int playerid, float streamdistance, int style, int areaid, int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Text Labels - - [NativeMethod] - public virtual int CreateDynamic3DTextLabel(string text, int color, float x, float y, float z, - float drawdistance, int attachedplayer, int attachedvehicle, bool testlos, int worldid, int interiorid, - int playerid, float streamdistance, int areaid, int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - - #region Area - - [NativeMethod] - public virtual int CreateDynamicCircle(float x, float y, float size, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicCylinder(float x, float y, float minz, float maxz, float size, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicSphere(float x, float y, float z, float size, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicRectangle(float minx, float miny, float maxx, float maxy, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicCuboid(float minx, float miny, float minz, float maxx, float maxy, float maxz, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicCube(float minx, float miny, float minz, float maxx, float maxy, float maxz, int worldid, int interiorid, - int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - [NativeMethod] - public virtual int CreateDynamicPolygon(float[] points, float minz, float maxz, int maxpoints, int worldid, - int interiorid, int playerid, int priority) - { - throw new NativeNotImplementedException(); - } - - #endregion - } -} + #region Objects + + [NativeMethod] + public virtual int CreateDynamicObject(int modelid, float x, float y, float z, float rx, float ry, float rz, + int worldid, int interiorid, int playerid, float streamdistance, float drawdistance, int areaid, + int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Pickups + + [NativeMethod] + public virtual int CreateDynamicPickup(int modelid, int type, float x, float y, float z, int worldid, + int interiorid, int playerid, float streamdistance, int areaid, int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Checkpoints + + [NativeMethod] + public virtual int CreateDynamicCP(float x, float y, float z, float size, int worldid, int interiorid, + int playerid, float streamdistance, int areaid, int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Race Checkpoints + + [NativeMethod] + public virtual int CreateDynamicRaceCP(int type, float x, float y, float z, float nextx, float nexty, + float nextz, float size, int worldid, int interiorid, int playerid, float streamdistance, int areaid, + int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Map Icon + + [NativeMethod] + public virtual int CreateDynamicMapIcon(float x, float y, float z, int type, int color, int worldid, + int interiorid, int playerid, float streamdistance, int style, int areaid, int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Text Labels + + [NativeMethod] + public virtual int CreateDynamic3DTextLabel(string text, int color, float x, float y, float z, + float drawdistance, int attachedplayer, int attachedvehicle, bool testlos, int worldid, int interiorid, + int playerid, float streamdistance, int areaid, int priority) => + throw new NativeNotImplementedException(); + + #endregion + + #region Settings + + [NativeMethod] + public virtual int Streamer_GetMaxItems(int type) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int Streamer_SetMaxItems(int type, int items) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int Streamer_GetVisibleItems(int type, int playerid) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int Streamer_SetVisibleItems(int type, int items, int playerid) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int Streamer_SetRadiusMultiplier(int type, float multiplier, int playerid) => + throw new NativeNotImplementedException(); + + #endregion + + #region Updates + + [NativeMethod] + public virtual void Streamer_ProcessActiveItems() => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_ToggleIdleUpdate(int playerid, bool toggle) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_IsToggleIdleUpdate(int playerid) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_ToggleCameraUpdate(int playerid, bool toggle) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_IsToggleCameraUpdate(int playerid) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_ToggleItemUpdate(int playerid, int type, bool toggle) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_IsToggleItemUpdate(int playerid, int type) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual void Streamer_GetLastUpdateTime(out float time) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_Update(int playerid, int type) => throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual bool Streamer_UpdateEx(int playerid, float x, float y, float z, int worldid = -1, + int interiorid = -1, int type = -1, int compensatedtime = -1, int freezeplayer = 1) => + throw new NativeNotImplementedException(); + + #endregion + + #region Area + + [NativeMethod] + public virtual int CreateDynamicCircle(float x, float y, float size, int worldid, int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicCylinder(float x, float y, float minz, float maxz, float size, int worldid, + int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicSphere(float x, float y, float z, float size, int worldid, int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicRectangle(float minx, float miny, float maxx, float maxy, int worldid, + int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicCuboid(float minx, float miny, float minz, float maxx, float maxy, float maxz, + int worldid, int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicCube(float minx, float miny, float minz, float maxx, float maxy, float maxz, + int worldid, int interiorid, + int playerid, int priority) => + throw new NativeNotImplementedException(); + + [NativeMethod] + public virtual int CreateDynamicPolygon(float[] points, float minz, float maxz, int maxpoints, int worldid, + int interiorid, int playerid, int priority) => + throw new NativeNotImplementedException(); + + #endregion +} \ No newline at end of file diff --git a/src/SampSharp.Streamer.Entities/StreamerEcsBuilderExtensions.cs b/src/SampSharp.Streamer.Entities/StreamerEcsBuilderExtensions.cs index 2004cdd..f9b65b0 100644 --- a/src/SampSharp.Streamer.Entities/StreamerEcsBuilderExtensions.cs +++ b/src/SampSharp.Streamer.Entities/StreamerEcsBuilderExtensions.cs @@ -16,113 +16,112 @@ using SampSharp.Entities; using SampSharp.Entities.SAMP; -namespace SampSharp.Streamer.Entities +namespace SampSharp.Streamer.Entities; + +/// +/// Provides methods for enabling Streamer systems in an instance. +/// +public static class SampEcsBuilderExtensions { /// - /// Provides methods for enabling Streamer systems in an instance. + /// Enables all dynamic object related Streamer events. + /// + /// The builder. + /// The builder. + public static IEcsBuilder EnableStreamerEvents(this IEcsBuilder builder) + { + builder + .UseMiddleware("OnPlayerConnect"); + + builder + .EnableDynamicObjectEvents() + .EnableDynamicPickupEvents() + .EnableDynamicCheckpointEvents() + .EnableDynamicRaceCheckpointEvents() + .EnableDynamicAreaEvents(); + + return builder; + } + + /// + /// Enables all dynamic object related Streamer events. + /// + /// The builder. + /// The builder. + public static IEcsBuilder EnableDynamicObjectEvents(this IEcsBuilder builder) + { + builder.EnableEvent("OnDynamicObjectMoved"); + builder.EnableEvent("OnPlayerEditDynamicObject"); + builder.EnableEvent("OnPlayerSelectDynamicObject"); + builder.EnableEvent("OnPlayerShootDynamicObject"); + + builder.UseMiddleware("OnDynamicObjectMoved", 0, StreamerEntities.DynamicObjectType, false); + builder.UseMiddleware("OnPlayerEditDynamicObject"); + builder.UseMiddleware("OnPlayerSelectDynamicObject"); + builder.UseMiddleware("OnPlayerShootDynamicObject"); + + return builder; + } + + /// + /// Enables all dynamic pickup related Streamer events. + /// + /// The builder. + /// The builder. + public static IEcsBuilder EnableDynamicPickupEvents(this IEcsBuilder builder) + { + builder.EnableEvent("OnPlayerPickUpDynamicPickup"); + + builder.UseMiddleware("OnPlayerPickUpDynamicPickup"); + + return builder; + } + + /// + /// Enables all dynamic checkpoint related Streamer events. + /// + /// The builder. + /// The builder. + public static IEcsBuilder EnableDynamicCheckpointEvents(this IEcsBuilder builder) + { + builder.EnableEvent("OnPlayerEnterDynamicCP"); + builder.EnableEvent("OnPlayerLeaveDynamicCP"); + + builder.UseMiddleware("OnPlayerEnterDynamicCP"); + builder.UseMiddleware("OnPlayerLeaveDynamicCP"); + + return builder; + } + + /// + /// Enables all dynamic race checkpoint related Streamer events. /// - public static class SampEcsBuilderExtensions + /// The builder. + /// The builder. + public static IEcsBuilder EnableDynamicRaceCheckpointEvents(this IEcsBuilder builder) { - /// - /// Enables all dynamic object related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableStreamerEvents(this IEcsBuilder builder) - { - builder - .UseMiddleware("OnPlayerConnect"); - - builder - .EnableDynamicObjectEvents() - .EnableDynamicPickupEvents() - .EnableDynamicCheckpointEvents() - .EnableDynamicRaceCheckpointEvents() - .EnableDynamicAreaEvents(); - - return builder; - } - - /// - /// Enables all dynamic object related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableDynamicObjectEvents(this IEcsBuilder builder) - { - builder.EnableEvent("OnDynamicObjectMoved"); - builder.EnableEvent("OnPlayerEditDynamicObject"); - builder.EnableEvent("OnPlayerSelectDynamicObject"); - builder.EnableEvent("OnPlayerShootDynamicObject"); - - builder.UseMiddleware("OnDynamicObjectMoved", 0, StreamerEntities.DynamicObjectType, false); - builder.UseMiddleware("OnPlayerEditDynamicObject"); - builder.UseMiddleware("OnPlayerSelectDynamicObject"); - builder.UseMiddleware("OnPlayerShootDynamicObject"); - - return builder; - } - - /// - /// Enables all dynamic pickup related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableDynamicPickupEvents(this IEcsBuilder builder) - { - builder.EnableEvent("OnPlayerPickUpDynamicPickup"); - - builder.UseMiddleware("OnPlayerPickUpDynamicPickup"); - - return builder; - } - - /// - /// Enables all dynamic checkpoint related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableDynamicCheckpointEvents(this IEcsBuilder builder) - { - builder.EnableEvent("OnPlayerEnterDynamicCP"); - builder.EnableEvent("OnPlayerLeaveDynamicCP"); - - builder.UseMiddleware("OnPlayerEnterDynamicCP"); - builder.UseMiddleware("OnPlayerLeaveDynamicCP"); - - return builder; - } - - /// - /// Enables all dynamic race checkpoint related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableDynamicRaceCheckpointEvents(this IEcsBuilder builder) - { - builder.EnableEvent("OnPlayerEnterDynamicRaceCP"); - builder.EnableEvent("OnPlayerLeaveDynamicRaceCP"); - - builder.UseMiddleware("OnPlayerEnterDynamicRaceCP"); - builder.UseMiddleware("OnPlayerLeaveDynamicRaceCP"); - - return builder; - } - - /// - /// Enables all dynamic area related Streamer events. - /// - /// The builder. - /// The builder. - public static IEcsBuilder EnableDynamicAreaEvents(this IEcsBuilder builder) - { - builder.EnableEvent("OnPlayerEnterDynamicArea"); - builder.EnableEvent("OnPlayerLeaveDynamicArea"); - - builder.UseMiddleware("OnPlayerEnterDynamicArea"); - builder.UseMiddleware("OnPlayerLeaveDynamicArea"); - - return builder; - } + builder.EnableEvent("OnPlayerEnterDynamicRaceCP"); + builder.EnableEvent("OnPlayerLeaveDynamicRaceCP"); + + builder.UseMiddleware("OnPlayerEnterDynamicRaceCP"); + builder.UseMiddleware("OnPlayerLeaveDynamicRaceCP"); + + return builder; + } + + /// + /// Enables all dynamic area related Streamer events. + /// + /// The builder. + /// The builder. + public static IEcsBuilder EnableDynamicAreaEvents(this IEcsBuilder builder) + { + builder.EnableEvent("OnPlayerEnterDynamicArea"); + builder.EnableEvent("OnPlayerLeaveDynamicArea"); + + builder.UseMiddleware("OnPlayerEnterDynamicArea"); + builder.UseMiddleware("OnPlayerLeaveDynamicArea"); + + return builder; } } \ No newline at end of file