RaycastSystem class
ECS system that provides ray-vs-collider intersection tests against every entity that has a TransformComponent and a RaycastColliderComponent.
This system performs no automatic per-frame work — it is a pure query API called on-demand (e.g. when a bullet is fired).
Usage:
final raycastSys = RaycastSystem();
world.addSystem(raycastSys);
final ray = Ray(origin: playerPos, direction: aimDir);
final hit = raycastSys.castRay(ray, filterTag: 'enemy');
if (hit != null) { /* apply damage */ }
Constructors
Properties
-
entities
→ Iterable<
Entity> -
Get all entities that match this system's requirements
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isActive ↔ bool
-
Whether this system is active
getter/setter pairinherited
- priority ↔ int
-
Priority for system execution order (higher = earlier)
getter/setter pairinherited
-
requiredComponents
→ List<
Type> -
Required component types for this system
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- world ↔ World
-
World this system belongs to
getter/setter pairinherited
Methods
-
castRay(
Ray ray, {String? filterTag}) → RaycastHit? -
Cast
rayand return the closest hit entity, ornullif no entity is intersected withinray.maxDistance. -
castRayAll(
Ray ray, {String? filterTag}) → List< RaycastHit> -
Cast
rayand return all intersected entities, sorted nearest-first. -
dispose(
) → void -
Dispose system resources
inherited
-
forEach(
void action(Entity entity)) → void -
Execute a function for each matching entity
inherited
-
hasLineOfSight(
Offset from, Offset to, {String? ignoreTag}) → bool -
Returns
trueif there is no blocking collider betweenfromandto(line-of-sight / LOS check). -
initialize(
) → void -
Initialize the system
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAddedToWorld(
) → void -
Called when system is added to world
inherited
-
onRemovedFromWorld(
) → void -
Called when system is removed from world
inherited
-
render(
Canvas canvas, Size size) → void -
Render the system (optional)
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double deltaTime) → void -
This system is query-only; no per-frame logic is required.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited