Package com.csse3200.game.components
Class TouchAttackComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.TouchAttackComponent
- Direct Known Subclasses:
ProjectileAttackComponent
When this entity touches a valid enemy's hitbox, deal damage to them and apply a knockback.
Requires CombatStatsComponent, HitboxComponent on this entity.
Damage is only applied if target entity has a CombatStatsComponent. Knockback is only applied if target entity has a PhysicsComponent.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CombatStatsComponent
protected HitboxComponent
protected short
-
Constructor Summary
ConstructorsConstructorDescriptionTouchAttackComponent
(short targetLayer) Create a component which attacks entities on collision, without knockback. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkHitboxAndLayer
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) void
create()
Called when the entity is created and registered.protected void
onCollisionStart
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
targetLayer
protected short targetLayer -
combatStats
-
hitboxComponent
-
-
Constructor Details
-
TouchAttackComponent
public TouchAttackComponent(short targetLayer) Create a component which attacks entities on collision, without knockback.- Parameters:
targetLayer
- The physics layer of the target's collider.
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called 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. -
checkHitboxAndLayer
protected boolean checkHitboxAndLayer(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) -
onCollisionStart
protected void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other)
-