Class LaserShowerComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.lasers.LaserShowerComponent
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
ConstructorsConstructorDescriptiondefault constructorLaserShowerComponent(float dir) Creates a laser emitter pointing in the specified direction. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.voiddispose()Called when the component is disposed.voidList<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
-
LaserShowerComponent
public LaserShowerComponent()default constructor -
LaserShowerComponent
public LaserShowerComponent(float dir) Creates a laser emitter pointing in the specified direction.- Parameters:
dir- initial laser angle in degrees
-
-
Method Details
-
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. -
fireLaser
public void fireLaser() -
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.
-