-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
87 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using CitizenFX.Core; | ||
using PolyZone.Zones.Interfaces; | ||
|
||
namespace PolyZone.Extensions; | ||
|
||
public static class EntityExtensions | ||
{ | ||
/// <inheritdoc cref="IZone.Contains"/> | ||
public static bool IsInside(this Entity entity, IZone zone) => zone.Contains(entity); | ||
|
||
/// <inheritdoc cref="IZone.DistanceFrom"/> | ||
public static float DistanceTo(this Entity entity, IZone zone) => zone.DistanceFrom(entity); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using CitizenFX.Core; | ||
using PolyZone.Shapes.Interfaces; | ||
|
||
namespace PolyZone.Extensions; | ||
|
||
public static class VectorExtensions | ||
{ | ||
/// <inheritdoc cref="ISpatial2dShape.Contains"/> | ||
public static bool IsInside(this Vector2 vector2, in ISpatial2dShape shape) => shape.Contains(vector2); | ||
|
||
/// <inheritdoc cref="ISpatial2dShape.DistanceFrom"/> | ||
public static float DistanceTo(this Vector2 vector2, in ISpatial2dShape shape) => shape.DistanceFrom(vector2); | ||
|
||
/// <inheritdoc cref="ISpatial3dShape.Contains"/> | ||
public static bool IsInside(this Vector3 vector2, in ISpatial3dShape shape) => shape.Contains(vector2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using CitizenFX.Core; | ||
|
||
namespace PolyZone.Internal; | ||
|
||
internal static class VectorExtensions | ||
{ | ||
internal static Vector2 ToVector2(in this Vector3 vector3) => new() { X = vector3.X, Y = vector3.Y }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using CitizenFX.Core; | ||
using PolyZone.Internal; | ||
using PolyZone.Shapes; | ||
using PolyZone.Zones.Interfaces; | ||
|
||
namespace PolyZone.Zones; | ||
|
||
// IZone or ISpatial2dZone> | ||
// Contains(player / character) | ||
// IZone + IDrawableZone? | ||
// Maybe have a simple constructor option? x, y, radius? | ||
|
||
public class CircleZone(in Vector2 center, float radius) : Circle(in center, radius), IZone | ||
{ | ||
public CircleZone(float centerX, float centerY, float radius) : this(new Vector2 { X = centerX, Y = centerY }, radius) { } | ||
|
||
/// <inheritdoc /> | ||
public bool Contains(in Entity entity) => Contains(entity.Position.ToVector2()); | ||
|
||
/// <inheritdoc /> | ||
public float DistanceFrom(in Entity entity) => DistanceFrom(entity.Position.ToVector2()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using CitizenFX.Core; | ||
|
||
namespace PolyZone.Zones.Interfaces; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public interface IZone | ||
{ | ||
/// <summary> | ||
/// Spatially tests a given <see cref="Entity"/>'s position to determine if it lies within the <see cref="IZone"/> | ||
/// </summary> | ||
/// <param name="entity">A entity, like a vehicle, object, prop, or character</param> | ||
/// <returns>True if the <see cref="Entity"/>'s position lies within the <see cref="IZone"/></returns> | ||
public bool Contains(in Entity entity); | ||
|
||
/// <summary> | ||
/// Calculates the float-accurate distance from a <see cref="Entity"/>'s position to the <see cref="IZone"/> | ||
/// </summary> | ||
/// <param name="entity">A entity, like a vehicle, object, prop, or character</param> | ||
/// <returns>The float-accurate distance from a <see cref="Entity"/>'s position to the <see cref="IZone"/></returns> | ||
public float DistanceFrom(in Entity entity); | ||
} |