VisionApi class

API for managing vision/line-of-sight behavior.

Constructors

VisionApi(GameComponent _comp)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cleanCache() → void
Clears the cached vision polygon shapes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(Canvas canvas) → void
Renders the vision shape if drawVision is enabled.
seeAndMoveToAlly({required dynamic closeAlly(Ally), BoolCallback? notObserved, VoidCallback? observed, VoidCallback? notCanMove, double radiusVision = 32, double? visionAngle, double? angle, double margin = 10, bool runOnlyVisibleInScreen = true, MovementAxis movementAxis = MovementAxis.all}) → void
Checks whether the ally is within range. If so, move to it. visionAngle in radians. angle in radians.
seeAndMoveToAttackRange<T extends GameComponent>({dynamic positioned(T)?, BoolCallback? notObserved, dynamic observed(T)?, double radiusVision = 32, double? visionAngle, double? angle, double? minDistanceFromPlayer, bool useDiagonal = true}) → void
Checks whether the T components are within attack range. If so, move to them and call positioned when in range. visionAngle in radians. angle in radians.
seeAndMoveToEnemy({required dynamic closeEnemy(Enemy), BoolCallback? notObserved, VoidCallback? observed, VoidCallback? notCanMove, double radiusVision = 32, double? visionAngle, double? angle, double margin = 10, bool runOnlyVisibleInScreen = true, MovementAxis movementAxis = MovementAxis.all}) → void
Checks whether the enemy is within range. If so, move to it. visionAngle in radians. angle in radians.
seeAndMoveToPlayer({dynamic closePlayer(Player)?, BoolCallback? notObserved, VoidCallback? observed, VoidCallback? notCanMove, double radiusVision = 32, double margin = 2, double? visionAngle, double? angle, bool runOnlyVisibleInScreen = true, MovementAxis movementAxis = MovementAxis.all}) PolygonShape?
Checks if the player is within range. If so, move to it. visionAngle in radians. angle in radians.
seeComponent(GameComponent component, {required dynamic observed(GameComponent), VoidCallback? notObserved, double radiusVision = 32, double? visionAngle, double angle = 3.14159}) PolygonShape?
Checks if component is within vision range. visionAngle in radians. angle in radians.
seeComponentType<T extends GameComponent>({required void observed(List<T>), VoidCallback? notObserved, double radiusVision = 32, double? visionAngle, double angle = 3.14159}) PolygonShape?
Checks if any component of type T is within vision range. visionAngle in radians. angle in radians.
seeEnemy({required dynamic observed(List<Enemy>), VoidCallback? notObserved, double radiusVision = 32, double? visionAngle, double? angle}) PolygonShape?
Checks if any enemy is within vision range. visionAngle in radians. angle in radians.
seePlayer({required dynamic observed(Player), VoidCallback? notObserved, double radiusVision = 32, double? visionAngle, double? angle}) PolygonShape?
Checks if the player is within vision range. visionAngle in radians. angle in radians.
setup({Color? color, bool drawVision = false, bool checkWithRaycast = true, int countPolygonPoints = 20}) → void
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

VISION_360 → const double