Hittables Manager

Presented by IHittablesManager interface, this system stores collection of all active Hittable objects in game, sorted by teams. It helps to find nearest hittables in certain point within certain radius.

To use this system, inject IHittablesManager interface into your class, as shown below:

[Inject] private IHittablesManager hittablesManager;

This system is not presented on LoadingScene, so you should add it onto the needed scenes where battles will occur.

Available methods

void RegisterHittable(Hittable hittable)

This method registers hittable object in manager. Other characters and projectiles will be able to find it.

This method is automatically called from Hittable class during its appearance, so you don't need to call it from your classes inherited from Hittable, in most of cases.

void UnregisterHittable(Hittable hittable)

This method unregisters hittable object from manager. Other characters and projectiles will not be able to find it.

This method is automatically called from Hittable class during its death, so you don't need to call it from your classes inherited from Hittable, in most of cases.


List<Hittable> GetHittablesInRadius(Vector3 from, float radius)

This method returns all Hittable objects in certain radius from given point.

Example:

var foundHittables = hittablesManager.GetHittablesInRadius(transform.position, 10f);

List<Hittable> GetOtherTeamsHittablesInRadius(Vector3 from, float radius, TeamType excludedTeam)

This method returns all Hittable objects in certain radius from given point, from all teams except excludedTeam.

Example:

var foundEnemies = hittablesManager.GetOtherTeamsHittablesInRadius(
    transform.position,
    10f,
    TeamType.Player);

List<Hittable> GetTeamHittablesInRadius(Vector3 from, float radius, TeamType teamType)

This method returns all Hittable objects in certain radius from given point, from certain team.

This method can be useful for seraching allies near the certain character.


void KillTeam(TeamType teamType)

This method instantly kills all Hittable objects of certain team.

Last updated