Table of Contents

Class LevelObjectUtility

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll

Helper functions for level objects.

public static class LevelObjectUtility
Inheritance
LevelObjectUtility
Inherited Members

Methods

Count the number of objects in the given radius matching an asset.

[Pure]
public static int CountObjects(IAssetLink<ObjectAsset> asset, int max = -1)

Parameters

asset IAssetLink<ObjectAsset>
max int

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

CountObjectsInRange(Vector3, float, int, bool)

Count the number of objects in the given radius.

[Pure]
public static int CountObjectsInRange(Vector3 position, float radius, int max = -1, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
max int
horizontalDistanceOnly bool

Returns

int

Exceptions

GameThreadException

Not on main thread.

Count the number of objects in the given radius matching an asset.

[Pure]
public static int CountObjectsInRange(Vector3 position, float radius, IAssetLink<ObjectAsset> asset, int max = -1, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
asset IAssetLink<ObjectAsset>
max int
horizontalDistanceOnly bool

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

CountObjectsWhere(Predicate<LevelObject>, int)

Count the number of objects in the given radius matching a predicate.

[Pure]
public static int CountObjectsWhere(Predicate<LevelObject> objectSelector, int max = -1)

Parameters

objectSelector Predicate<LevelObject>
max int

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

CountObjectsWhere(Vector3, float, Predicate<LevelObject>, int, bool)

Count the number of objects in the given radius matching a predicate.

[Pure]
public static int CountObjectsWhere(Vector3 position, float radius, Predicate<LevelObject> objectSelector, int max = -1, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
objectSelector Predicate<LevelObject>
max int
horizontalDistanceOnly bool

Returns

int

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

EnumerateObjects()

Enumerate through all level objects around the center of the level.

[Pure]
public static ObjectIterator EnumerateObjects()

Returns

ObjectIterator

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(RegionCoord)

Enumerate through all level objects around the given region.

[Pure]
public static ObjectIterator EnumerateObjects(RegionCoord region)

Parameters

region RegionCoord

Returns

ObjectIterator

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(RegionCoord, byte)

Enumerate through all level objects around the given region.

[Pure]
public static ObjectIterator EnumerateObjects(RegionCoord region, byte maxRegionDistance)

Parameters

region RegionCoord
maxRegionDistance byte

Returns

ObjectIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(byte, byte)

Enumerate through all level objects around the region x, y.

[Pure]
public static ObjectIterator EnumerateObjects(byte x, byte y)

Parameters

x byte
y byte

Returns

ObjectIterator

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(byte, byte, byte)

Enumerate through all level objects around the region x, y.

[Pure]
public static ObjectIterator EnumerateObjects(byte x, byte y, byte maxRegionDistance)

Parameters

x byte
y byte
maxRegionDistance byte

Returns

ObjectIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(Vector3)

Enumerate through all level objects around the center of the level.

[Pure]
public static ObjectIterator EnumerateObjects(Vector3 center)

Parameters

center Vector3

Returns

ObjectIterator

Exceptions

GameThreadException

Not on main thread.

EnumerateObjects(Vector3, byte)

Enumerate through all level objects around the center of the level.

[Pure]
public static ObjectIterator EnumerateObjects(Vector3 center, byte maxRegionDistance)

Parameters

center Vector3
maxRegionDistance byte

Returns

ObjectIterator

Remarks

The square enumerated will have a size of maxRegionDistance * 2 + 1 regions.

Exceptions

GameThreadException

Not on main thread.

FindObject(uint)

Find a object by it's instance ID.

[Pure]
public static ObjectInfo FindObject(uint instanceId)

Parameters

instanceId uint

Returns

ObjectInfo

Exceptions

GameThreadException

Not on main thread.

FindObject(uint, byte, byte)

Find a object by it's instance ID, with help from an expected region to prevent having to search every region.

[Pure]
public static ObjectInfo FindObject(uint instanceId, byte expectedRegionX, byte expectedRegionY)

Parameters

instanceId uint
expectedRegionX byte
expectedRegionY byte

Returns

ObjectInfo

Remarks

All regions will be searched if it's not found in the expected region.

Exceptions

GameThreadException

Not on main thread.

Find a object by it's instance ID, with help from an expected region to prevent having to search every region.

[Pure]
public static ObjectInfo FindObject(uint instanceId, IAssetLink<ObjectAsset> expectedAsset, Vector3 expectedPosition)

Parameters

instanceId uint
expectedAsset IAssetLink<ObjectAsset>
expectedPosition Vector3

Returns

ObjectInfo

All regions will be searched if it's not found in the expected region.

Exceptions

GameThreadException

Not on main thread.

FindObject(uint, Vector3)

Find a object by it's instance ID, with help from a position to prevent having to search every region.

[Pure]
public static ObjectInfo FindObject(uint instanceId, Vector3 expectedPosition)

Parameters

instanceId uint
expectedPosition Vector3

Returns

ObjectInfo

Remarks

All regions will be searched if it's not found near the expected position.

Exceptions

GameThreadException

Not on main thread.

FindObject(Transform)

Find a object by it's Unity UnityEngine.Transform.

[Pure]
public static ObjectInfo FindObject(Transform transform)

Parameters

transform Transform

Returns

ObjectInfo

Exceptions

GameThreadException

Not on main thread.

GetClosestObject(Vector3, bool)

Find the closest object to position.

[Pure]
public static ObjectInfo GetClosestObject(Vector3 position, bool horizontalDistanceOnly = false)

Parameters

position Vector3
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

GameThreadException

Not on main thread.

Find the closest object with the given asset to position.

[Pure]
public static ObjectInfo GetClosestObject(Vector3 position, IAssetLink<ObjectAsset> asset, bool horizontalDistanceOnly = false)

Parameters

position Vector3
asset IAssetLink<ObjectAsset>
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

GetClosestObjectInRange(Vector3, float, bool)

Find the closest object to position within the given radius.

[Pure]
public static ObjectInfo GetClosestObjectInRange(Vector3 position, float radius, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

GameThreadException

Not on main thread.

Find the closest object with the given asset to position within the given radius.

[Pure]
public static ObjectInfo GetClosestObjectInRange(Vector3 position, float radius, IAssetLink<ObjectAsset> asset, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
asset IAssetLink<ObjectAsset>
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

GetClosestObjectWhere(Vector3, Predicate<LevelObject>, bool)

Find the closest object matching a predicate to position.

[Pure]
public static ObjectInfo GetClosestObjectWhere(Vector3 position, Predicate<LevelObject> objectSelector, bool horizontalDistanceOnly = false)

Parameters

position Vector3
objectSelector Predicate<LevelObject>
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

GetClosestObjectWhere(Vector3, float, Predicate<LevelObject>, bool)

Find the closest object matching a predicate to position within a given radius.

[Pure]
public static ObjectInfo GetClosestObjectWhere(Vector3 position, float radius, Predicate<LevelObject> objectSelector, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
objectSelector Predicate<LevelObject>
horizontalDistanceOnly bool

Returns

ObjectInfo

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

GetPosition(LevelObject)

Safely get the position of the object in case the main model didn't load.

public static Vector3 GetPosition(LevelObject @object)

Parameters

object LevelObject

Returns

Vector3

IsObjectInRange(Vector3, float, bool)

Check for a nearby object to position within the given radius.

[Pure]
public static bool IsObjectInRange(Vector3 position, float radius, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
horizontalDistanceOnly bool

Returns

bool

Exceptions

GameThreadException

Not on main thread.

IsObjectInRange(Vector3, float, Predicate<LevelObject>, bool)

Check for a nearby object matching a predicate to position within the given radius.

[Pure]
public static bool IsObjectInRange(Vector3 position, float radius, Predicate<LevelObject> objectSelector, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
objectSelector Predicate<LevelObject>
horizontalDistanceOnly bool

Returns

bool

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.

Check for a nearby object with the given asset to position within the given radius.

[Pure]
public static bool IsObjectInRange(Vector3 position, float radius, IAssetLink<ObjectAsset> asset, bool horizontalDistanceOnly = false)

Parameters

position Vector3
radius float
asset IAssetLink<ObjectAsset>
horizontalDistanceOnly bool

Returns

bool

Exceptions

ArgumentNullException
GameThreadException

Not on main thread.