Class FleeMap
Implements the concept of a "safety map", also known as "flee map", as described in the this article.
Inheritance
Inherited Members
Namespace: GoRogue.Pathing
Assembly: GoRogue.dll
Syntax
public class FleeMap : IMapView<double?>, IDisposable
Remarks
Takes a goal map, wherein any goals are treated as "threats" to be avoided. Automatically recalculated when the underlying goal map is recalculated. Implements IDisposable, so ensure that it is disposed of properly after use.
Constructors
| Improve this Doc View SourceFleeMap(GoalMap, Double)
Constructor. Takes a goal map where in all goals are treated as threats to be avoided, and a magnitude to use (defaulting to 1.2).
Declaration
public FleeMap(GoalMap baseMap, double magnitude = 1.2)
Parameters
Type | Name | Description |
---|---|---|
GoalMap | baseMap | The underlying goal map to use. |
System.Double | magnitude | Magnitude to multiply by during calculation. |
Properties
| Improve this Doc View SourceHeight
Height of the flee map.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Coord]
Returns the flee-map value for the given position.
Declaration
public double? this[Coord pos] { get; }
Parameters
Type | Name | Description |
---|---|---|
Coord | pos | The position to return the value for. |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> | The flee-map value for the given location. |
Item[Int32]
Returns the flee-map value for the given position.
Declaration
public double? this[int index1D] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index1D | The position to return the value for, as a 1D-array-style index. |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> | The flee-map value for the given location. |
Item[Int32, Int32]
Returns the goal-map value for the given position.
Declaration
public double? this[int x, int y] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x-value of the position to return the value for. |
System.Int32 | y | The y-value of the position to return the value for. |
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> | The flee-map value for the given location. |
Magnitude
The degree to which entities following this flee-map will prefer global safety to local safety. Higher values will make entities try to move past an approaching "threat" from farther away.
Declaration
public double Magnitude { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Width
Width of the flee map.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceDispose()
Function called to dispose of the class, automatically unlinking it from its goal map.
Declaration
public void Dispose()
Finalize()
Destructor for IDisposable implementation.
Declaration
protected void Finalize()
GetDirectionOfMinValue(Coord)
Gets the direction of the neighbor with the minimum flee-map value from the given position.
Declaration
public Direction GetDirectionOfMinValue(Coord position)
Parameters
Type | Name | Description |
---|---|---|
Coord | position | The position to get the minimum value for. |
Returns
Type | Description |
---|---|
Direction | The direction that has the minimum value in the goal-map, or NONE if the neighbors are all obstacles. |
GetDirectionOfMinValue(Int32, Int32)
Gets the direction of the neighbor with the minimum flee-map value from the given position.
Declaration
public Direction GetDirectionOfMinValue(int positionX, int positionY)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | positionX | The x-value of the position to get the minimum value for. |
System.Int32 | positionY | The y-value of the position to get the minimum value for. |
Returns
Type | Description |
---|---|
Direction | The direction that has the minimum value in the goal-map, or NONE if the neighbors are all obstacles. |
ToString()
Returns the flee-map values represented as a 2D grid-style string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representing the flee map values. |
Overrides
ToString(Int32)
Returns the flee-map values represented as a 2D-grid-style string, with the given field size.
Declaration
public string ToString(int fieldSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fieldSize | Number of characters allocated to each value in the string. |
Returns
Type | Description |
---|---|
System.String | A string representing the flee-map values. |
ToString(Int32, String)
Returns the flee-map values represented as a 2D-grid-style string, with the given field size, and any non-null values formatted using the given format string.
Declaration
public string ToString(int fieldSize, string formatString)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fieldSize | Number of characters allocated to each value in the string. |
System.String | formatString | Format string to use for non-null values. |
Returns
Type | Description |
---|---|
System.String | A string representing the flee-map values. |
ToString(String)
Returns the flee-map values represented as a 2D-grid-style string, where any value that isn't null is formatted as per the specified format string.
Declaration
public string ToString(string formatString)
Parameters
Type | Name | Description |
---|---|---|
System.String | formatString | Format string to use for non-null values. |
Returns
Type | Description |
---|---|
System.String | A string representing the flee-map values. |