Helper Scripts Collection 1.3.1
API documentation for the helper scripts compatible with Unity3D
Static Public Member Functions | List of all members
NikosAssets.Helpers.TargetingHelper Class Reference

A helper class for Component targeting and list sorting by distance measures More...

Static Public Member Functions

static List< T > GetCompsSortedByDist< T > (List< T > targets, T checkAgainst)
 Sorts the passed targets by distance checking against the checkAgainst Component. If you dont want to sort the original list, make a copy of it. More...
 
static T GetCompAtMedianDist< T > (List< T > targets, T checkAgainst)
 Get the Component that is closest to the median distance to checkAgainst . If you dont want to sort the original list, make a copy of it. More...
 
static T GetCompAtAverageDist< T > (List< T > targets, T checkAgainst)
 Get the Component that is approx at the average distance to checkAgainst relative to the other targets . The given list will not be sorted and remains unchanged. More...
 
static T GetRandomComp< T > (List< T > targets)
 Get a random Component from the given list More...
 
static float GetDistSquaredSum< T > (List< T > targets, T checkAgainst)
 Get the summed squared distance of the targets to the checkAgainst Component More...
 
static float GetAverageDistSquared< T > (List< T > targets, T checkAgainst)
 Get the average squared distance of the targets to the checkAgainst Component More...
 
static int CompareTargetsByDistanceTo< T > (T a, T b, T checkAgainst)
 A helper method to compare 2 Components against another one based on their distance to it More...
 
static T CalcAverageComp< T > (List< T > targets, T checkAgainst)
 
static float CalcDistSquaredSum< T > (List< T > targets, T checkAgainst)
 
static float CalcAverageDistSquared< T > (List< T > targets, T checkAgainst)
 

Detailed Description

A helper class for Component targeting and list sorting by distance measures

Member Function Documentation

◆ CalcAverageComp< T >()

static T NikosAssets.Helpers.TargetingHelper.CalcAverageComp< T > ( List< T >  targets,
checkAgainst 
)
static
Type Constraints
T :Component 

◆ CalcAverageDistSquared< T >()

static float NikosAssets.Helpers.TargetingHelper.CalcAverageDistSquared< T > ( List< T >  targets,
checkAgainst 
)
static
Type Constraints
T :Component 

◆ CalcDistSquaredSum< T >()

static float NikosAssets.Helpers.TargetingHelper.CalcDistSquaredSum< T > ( List< T >  targets,
checkAgainst 
)
static
Type Constraints
T :Component 

◆ CompareTargetsByDistanceTo< T >()

static int NikosAssets.Helpers.TargetingHelper.CompareTargetsByDistanceTo< T > ( a,
b,
checkAgainst 
)
static

A helper method to compare 2 Components against another one based on their distance to it

Parameters
a
b
checkAgainst
Template Parameters
T
Returns
Type Constraints
T :Component 

◆ GetAverageDistSquared< T >()

static float NikosAssets.Helpers.TargetingHelper.GetAverageDistSquared< T > ( List< T >  targets,
checkAgainst 
)
static

Get the average squared distance of the targets to the checkAgainst Component

Parameters
targets
checkAgainst
Template Parameters
T
Returns
0 if list is empty or null, otherwise the average squared distance
Type Constraints
T :Component 

◆ GetCompAtAverageDist< T >()

static T NikosAssets.Helpers.TargetingHelper.GetCompAtAverageDist< T > ( List< T >  targets,
checkAgainst 
)
static

Get the Component that is approx at the average distance to checkAgainst relative to the other targets . The given list will not be sorted and remains unchanged.

Parameters
targets
checkAgainst
Template Parameters
T
Returns
Null if the list is null or empty, otherwise a Component
Type Constraints
T :Component 

◆ GetCompAtMedianDist< T >()

static T NikosAssets.Helpers.TargetingHelper.GetCompAtMedianDist< T > ( List< T >  targets,
checkAgainst 
)
static

Get the Component that is closest to the median distance to checkAgainst . If you dont want to sort the original list, make a copy of it.

Parameters
targetsThe Component to pick from
checkAgainstThe Component to check the targets against
Template Parameters
T
Returns
Null if the list is empty or null, otherwise the Component at median distance to checkAgainst
Type Constraints
T :Component 

◆ GetCompsSortedByDist< T >()

static List< T > NikosAssets.Helpers.TargetingHelper.GetCompsSortedByDist< T > ( List< T >  targets,
checkAgainst 
)
static

Sorts the passed targets by distance checking against the checkAgainst Component. If you dont want to sort the original list, make a copy of it.

Parameters
targets
checkAgainst
Template Parameters
T
Returns
The sorted (same) list by distance to checkAgainst . The same list, if only 1 element is found in the list or the list is null.
Type Constraints
T :Component 

◆ GetDistSquaredSum< T >()

static float NikosAssets.Helpers.TargetingHelper.GetDistSquaredSum< T > ( List< T >  targets,
checkAgainst 
)
static

Get the summed squared distance of the targets to the checkAgainst Component

Parameters
targets
checkAgainst
Template Parameters
T
Returns
The summed squared distance float value
Type Constraints
T :Component 

◆ GetRandomComp< T >()

static T NikosAssets.Helpers.TargetingHelper.GetRandomComp< T > ( List< T >  targets)
static

Get a random Component from the given list

Parameters
targets
Template Parameters
T
Returns
Null if list is empty or null, otherwise a random Component
Type Constraints
T :Component