Class CollisionEffectComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.Environmental.CollisionEffectComponent
class containing collision effects defined by the CollisionEffect enum
Entities implementing this must also implement ColliderComponent, PhysicsComponent and EnvironmentalComponent
To make the effect AoE, a hitboxcomponent must also be added (change the size of hitboxcomponent to change AoE)
At this stage, only speed is supported as an AoE effect
By default, collision effects impact both players and NPCs. Use SetEffectTarget() to change this.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Collision effectstatic enum
Effect target -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCollisionEffectComponent
(CollisionEffectComponent.CollisionEffect collisionEffect, float speedModifier) -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
initialise the collisionEffect.boolean
isAoe()
honestly just put this in to test.void
setAoe
(boolean AoE) Sets AoE value to true - used in checks to confirm how to implement collision effect Will do nothing if the entity has no HitboxComponent attached (to avoid null pointer issues later on)sets collision effect.void
setDamage
(int damage) void
sets the entity/ies to be effectedvoid
setKnockbackForce
(float knockbackForce) Methods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CollisionEffectComponent
public CollisionEffectComponent(CollisionEffectComponent.CollisionEffect collisionEffect, float speedModifier)
-
-
Method Details
-
create
public void create()initialise the collisionEffect. Note this happens after entity has been attached damage and knockbackforce should be set separately, using setDamage() and setKnockbackForce() damage knocks back by default; set knockbackforce to zero to avoid this -
getCollisionEffect
-
setDamage
public void setDamage(int damage) -
setAoe
public void setAoe(boolean AoE) Sets AoE value to true - used in checks to confirm how to implement collision effect Will do nothing if the entity has no HitboxComponent attached (to avoid null pointer issues later on)- Parameters:
AoE
- whether the effect should be AoE or not
-
isAoe
public boolean isAoe()honestly just put this in to test.- Returns:
- whether this component uses AoE or collision
-
setKnockbackForce
public void setKnockbackForce(float knockbackForce) -
setEffectTarget
sets the entity/ies to be effected- Parameters:
target
- the target effect, from EffectTarget enum (PLAYER/NPC/ALL)
-
setCollisionEffect
sets collision effect. Requires entity to be attached to ColliderComponent Note that this changes ColliderComponent behaviour - may need to change this depending on desired behaviour- Parameters:
effect
- the effect to set, defined in CollisionEffectComponent.SetCollisionEffect enum- Returns:
- CollisionEffectComponent
-