Package com.csse3200.game.components
Class WeaponsStatsComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.WeaponsStatsComponent
Component used to store weapon-related combat statistics such as attack damage,
cooldown, upgrade stages, and cheat modifiers.
Any entity that uses weapons in combat should have an instance of this component.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWeaponsStatsComponent
(int baseAttack) Constructs aWeaponsStatsComponent
with a base attack value.WeaponsStatsComponent
(WeaponConfig config) Constructs aWeaponsStatsComponent
from a weapon configuration. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the current effective attack damage for this weapon.float
Gets the cooldown time between attacks.float
Gets the current damage multiplier applied to this weapon.int
Gets the maximum upgrade stage.Gets the texture path for this weapon's projectile, if applicable.int
Gets the current upgrade stage.boolean
Checks if this weapon is already fully upgraded.void
setBaseAttack
(int attack) Sets the base attack damage (before multipliers).void
setCoolDown
(float coolDown) Sets the cooldown time between attacks.void
setDamageMultiplier
(float multiplier) Sets the damage multiplier for this weapon.void
setDisableDamage
(boolean status) Enables or disables damage output for this weapon.void
setProjectileTexturePath
(String projectileTexturePath) Sets the texture path for this weapon's projectile, if applicable.void
upgrade()
Upgrades this weapon to the next stage, if not already maxed out.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
WeaponsStatsComponent
Constructs aWeaponsStatsComponent
from a weapon configuration.- Parameters:
config
- the weapon configuration (must specify non-negative damage)
-
WeaponsStatsComponent
public WeaponsStatsComponent(int baseAttack) Constructs aWeaponsStatsComponent
with a base attack value.- Parameters:
baseAttack
- the initial base attack damage (must be>= 0
)
-
-
Method Details
-
setCoolDown
public void setCoolDown(float coolDown) Sets the cooldown time between attacks.- Parameters:
coolDown
- cooldown in seconds (clamped to minimum 0)
-
getCoolDown
public float getCoolDown()Gets the cooldown time between attacks.- Returns:
- cooldown in seconds
-
getBaseAttack
public int getBaseAttack()Gets the current effective attack damage for this weapon.The effective damage is calculated as:
The value is clamped to the range of anbaseAttack × damageMultiplier
.int
.- Returns:
- effective attack damage
-
setBaseAttack
public void setBaseAttack(int attack) Sets the base attack damage (before multipliers).- Parameters:
attack
- base attack damage (must be>= 0
)
-
setProjectileTexturePath
Sets the texture path for this weapon's projectile, if applicable.- Parameters:
projectileTexturePath
- path to the projectile texture
-
getProjectileTexturePath
Gets the texture path for this weapon's projectile, if applicable.- Returns:
- projectile texture path, or
null
if none
-
getUpgradeStage
public int getUpgradeStage()Gets the current upgrade stage.- Returns:
- current upgrade stage (starts at 1)
-
getMaxUpgradeStage
public int getMaxUpgradeStage()Gets the maximum upgrade stage.- Returns:
- maximum upgrade stage
-
isMaxUpgraded
public boolean isMaxUpgraded()Checks if this weapon is already fully upgraded.- Returns:
true
if the upgrade stage is at maximum,false
otherwise
-
upgrade
public void upgrade()Upgrades this weapon to the next stage, if not already maxed out.Each upgrade doubles the base attack damage.
-
setDisableDamage
public void setDisableDamage(boolean status) Enables or disables damage output for this weapon.- Parameters:
status
-true
to disable damage,false
to allow damage
-
setDamageMultiplier
public void setDamageMultiplier(float multiplier) Sets the damage multiplier for this weapon.The multiplier must be non-negative and finite. For example:
1.0
= normal damage (default)2.0
= double damage0.5
= half damage
- Parameters:
multiplier
- the new damage multiplier
-
getDamageMultiplier
public float getDamageMultiplier()Gets the current damage multiplier applied to this weapon.- Returns:
- current damage multiplier (default
1.0
)
-