Class LaserEmitterComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.lasers.LaserEmitterComponent
This component constructs a list of points where a laser beam would collide with objects.
If the "beam" were to collide with a collider that has the
PhysicsLayer.LASER_REFLECTOR layer
than it calculates the reflected angle based on the normal of the surface and incoming angle.
The laser beam is limited to a max number of rebounds defined by MAX_REBOUNDS as well as a max distance
defined by MAX_DISTANCE. If either of these limits are hit than the laser stops prematurely.
Additionally the laser will attempt to deal a set amount of damage to any entity with the PhysicsLayer.PLAYER
layer, this can be extended to try to deal damage to other targets with different physics layers too.
The list of points in world space is then exposed globally by a getter method which can be accessed by the dedicated laser renderer to render lines between the points.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.voiddispose()Called when the component is disposed.booleanList<com.badlogic.gdx.math.Vector2> Gets the list of collision positions generated from the laser emitter which can be used to render lines between the points.voidupdate()Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
LaserEmitterComponent
public LaserEmitterComponent() -
LaserEmitterComponent
public LaserEmitterComponent(float dir)
-
-
Method Details
-
getEnable
public boolean getEnable() -
create
public void create()Description copied from class:ComponentCalled when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
update
public void update()Description copied from class:ComponentCalled once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
getPositions
Gets the list of collision positions generated from the laser emitter which can be used to render lines between the points.- Returns:
- the list of collision points
-
dispose
public void dispose()Description copied from class:ComponentCalled when the component is disposed. Dispose of any internal resources here.
-