Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(IsLibrary)' == 'True'">
<OutputPath>..\..\bin\$(Configuration)\</OutputPath>
<BaseOutputPath>..\..\bin\</BaseOutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
</PropertyGroup>
Expand All @@ -35,7 +35,7 @@
<PackageTags>gta samp sampsharp</PackageTags>
<PackageId>$(AssemblyName)</PackageId>
<Product>$(AssemblyName)</Product>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PublishRepositoryUrl Condition="'$(GITHUB_ACTIONS)' == 'true'">true</PublishRepositoryUrl>
</PropertyGroup>

<PropertyGroup Label="Versioning">
Expand All @@ -62,10 +62,10 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'True' and '$(MSBuildProjectExtension)' == '.csproj'">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.32.0.39516">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.32.0.39516">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- Symbols / source linking -->
Expand All @@ -74,16 +74,22 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<PropertyGroup Label="SourceLink">
<PropertyGroup Label="SourceLink" Condition="'$(GITHUB_ACTIONS)' == 'true'">
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<ItemGroup Condition="'$(IsLibrary)' == 'True'">
<ItemGroup Condition="'$(IsLibrary)' == 'True' and '$(GITHUB_ACTIONS)' == 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<!-- Detect UseLocalForks from parent VSRP build context -->
<PropertyGroup>
<UseLocalForks Condition="'$(UseLocalForks)' == ''">false</UseLocalForks>
</PropertyGroup>


</Project>
102 changes: 46 additions & 56 deletions src/SampSharp.Streamer.Entities/Components/DynamicArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Represents a component which provides the data and functionality of an dynamic area.
/// </summary>
public sealed class DynamicArea : Component
{
/// <summary>
/// Represents a component which provides the data and functionality of an dynamic area.
/// </summary>
public sealed class DynamicArea : Component
private DynamicArea()
{
private DynamicArea()
{
}

}
/// <summary>
/// Gets whether this dynamic area is valid.
/// </summary>
public bool IsValid => GetComponent<NativeDynamicArea>().IsValidDynamicArea();

/// <summary>
/// Gets whether this dynamic area is valid.
/// </summary>
public bool IsValid => GetComponent<NativeDynamicArea>().IsValidDynamicArea();
/// <summary>
/// Gets the dynamic area type.
/// </summary>
public AreaType AreaType => (AreaType)GetComponent<NativeDynamicArea>().GetDynamicAreaType();

/// <summary>
/// Gets the dynamic area type.
/// </summary>
public AreaType AreaType => (AreaType)GetComponent<NativeDynamicArea>().GetDynamicAreaType();
/// <summary>
/// Gets polygon points.
/// </summary>
public IEnumerable<Vector3> GetPolygonPoints()
{
var pointCount = GetPointsCount();
GetComponent<NativeDynamicArea>().GetDynamicPolygonPoints(out var points, pointCount * 2);

/// <summary>
/// Gets polygon points.
/// </summary>
public IEnumerable<Vector3> GetPolygonPoints()
if (points == null)
{
var pointCount = GetPointsCount();
GetComponent<NativeDynamicArea>().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;
}

/// <summary>
/// Gets number points.
/// </summary>
public int GetPointsCount()
for (var i = 0; i < points.Length - 1; i += 2)
{
return GetComponent<NativeDynamicArea>().GetDynamicPolygonNumberPoints();
yield return new Vector3(points[i], points[i + 1]);
}
}

/// <summary>
/// Gets any player in area.
/// </summary>
public bool IsAnyPlayerInArea(bool recheck = false)
{
return GetComponent<NativeDynamicArea>().IsAnyPlayerInDynamicArea(recheck);
}
/// <summary>
/// Gets number points.
/// </summary>
public int GetPointsCount() => GetComponent<NativeDynamicArea>().GetDynamicPolygonNumberPoints();

/// <summary>
/// Gets any player in any area.
/// </summary>
public bool IsAnyPlayerInAnyArea(bool recheck = false)
{
return GetComponent<NativeDynamicArea>().IsAnyPlayerInAnyDynamicArea(recheck);
}
/// <summary>
/// Gets any player in area.
/// </summary>
public bool IsAnyPlayerInArea(bool recheck = false) =>
GetComponent<NativeDynamicArea>().IsAnyPlayerInDynamicArea(recheck);

/// <inheritdoc />
protected override void OnDestroyComponent()
{
GetComponent<NativeDynamicArea>().DestroyDynamicArea();
}
}
}
/// <summary>
/// Gets any player in any area.
/// </summary>
public bool IsAnyPlayerInAnyArea(bool recheck = false) =>
GetComponent<NativeDynamicArea>().IsAnyPlayerInAnyDynamicArea(recheck);

/// <inheritdoc />
protected override void OnDestroyComponent() => GetComponent<NativeDynamicArea>().DestroyDynamicArea();
}
81 changes: 39 additions & 42 deletions src/SampSharp.Streamer.Entities/Components/DynamicCheckpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Represents a component which provides the data and functionality of an dynamic checkpoint.
/// </summary>
public sealed class DynamicCheckpoint : Component
{
/// <summary>
/// Represents a component which provides the data and functionality of an dynamic checkpoint.
/// </summary>
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;
}

/// <summary>
/// Gets whether this dynamic checkpoint is valid.
/// </summary>
public bool IsValid => GetComponent<NativeDynamicCheckpoint>().IsValidDynamicCP();
/// <summary>
/// Gets whether this dynamic checkpoint is valid.
/// </summary>
public bool IsValid => GetComponent<NativeDynamicCheckpoint>().IsValidDynamicCP();

/// <summary>
/// Gets the position of this checkpoint.
/// </summary>
public Vector3 Position { get; }
/// <summary>
/// Gets the position of this checkpoint.
/// </summary>
public Vector3 Position { get; }

/// <summary>
/// Gets the size of this checkpoint.
/// </summary>
public float Size { get; }
/// <summary>
/// Gets the size of this checkpoint.
/// </summary>
public float Size { get; }

/// <summary>
/// The toggle checkpoint for specific player.
/// </summary>
/// <param name="player">The player to toggle (or not) the checkpoint.</param>
/// <param name="toggle">TRUE to toggle.</param>
/// <returns>
/// <see cref="bool"/>
/// </returns>
public bool ToggleForPlayer(Player player, bool toggle)
/// <summary>
/// The toggle checkpoint for specific player.
/// </summary>
/// <param name="player">The player to toggle (or not) the checkpoint.</param>
/// <param name="toggle">TRUE to toggle.</param>
/// <returns>
/// <see cref="bool" />
/// </returns>
public bool ToggleForPlayer(Player player, bool toggle)
{
if (player == null)
{
if (player == null)
throw new ArgumentNullException(nameof(player));

return GetComponent<NativeDynamicWorldObject>().ToggleItem(
player.Entity.Handle, (int)StreamerType.Checkpoint, this.Entity.Handle, toggle);
throw new ArgumentNullException(nameof(player));
}

/// <inheritdoc />
protected override void OnDestroyComponent()
{
GetComponent<NativeDynamicCheckpoint>().DestroyDynamicCP();
}
return GetComponent<NativeDynamicWorldObject>().ToggleItem(
player.Entity.Handle, (int)StreamerType.Checkpoint, Entity.Handle, toggle);
}

/// <inheritdoc />
protected override void OnDestroyComponent() => GetComponent<NativeDynamicCheckpoint>().DestroyDynamicCP();
}
Loading