Table of Contents

Class PolygonProximity

Namespace
Uncreated.Warfare.Proximity
Assembly
Uncreated.Warfare.dll

Defines a proximity outlined by a 2D polygon.

public class PolygonProximity : IPolygonProximity, INearestPointProximity, IAttachableProximity<IAttachedPolygonProximity>, IProximity, IShapeVolume, ICloneable, IFormattable
Inheritance
PolygonProximity
Implements
IShapeVolume
Inherited Members
Extension Methods

Constructors

PolygonProximity(IEnumerable<Vector2>, float?, float?)

Create a polygon with a set of points.

public PolygonProximity(IEnumerable<Vector2> points, float? minHeight, float? maxHeight)

Parameters

points IEnumerable<Vector2>

A set of points with at least 3 elements.

minHeight float?

Optional minimum Y value.

maxHeight float?

Optional maximum Y value.

Exceptions

ArgumentException

points has less than 3 elements or one of the points isn't finite.

Properties

Area

The 2D area of the shape when looking down.

public float Area { get; }

Property Value

float

MaxHeight

Maximum Y value of the polygon.

public float? MaxHeight { get; }

Property Value

float?

MinHeight

Minimum Y value of the polygon.

public float? MinHeight { get; }

Property Value

float?

Points

Ordered list of all points in the polygon.

public IReadOnlyList<Vector2> Points { get; }

Property Value

IReadOnlyList<Vector2>

internalVolume

Internal cubic meter volume.

public float internalVolume { get; }

Property Value

float

surfaceArea

Surface square meters area.

public float surfaceArea { get; }

Property Value

float

worldBounds

Not necessarily cheap to calculate - probably best to cache.

public Bounds worldBounds { get; }

Property Value

Bounds

Methods

Clone()

Creates a new object that is a copy of the current instance.

public object Clone()

Returns

object

A new object that is a copy of this instance.

TestPoint(in Vector2)

Check if a position is within the proximity while ignoring Y position.

public bool TestPoint(in Vector2 position)

Parameters

position Vector2

Returns

bool

TestPoint(in Vector3)

Check if a position is within the proximity.

public bool TestPoint(in Vector3 position)

Parameters

position Vector3

Returns

bool

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified format.

public string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.
-or-
A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.
-or-
A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.