Class WeaponsFactory
java.lang.Object
com.csse3200.game.entities.factories.items.WeaponsFactory
Factory to create non-playable character (NPC) entities with predefined components.
Each NPC entity type should have a creation method that returns a corresponding entity. Predefined entity properties can be loaded from lightsaberConfigs stored as json files which are defined in "NPCConfigs".
If needed, this factory can be separated into more specific factories for entities with similar characteristics.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnimationRenderComponent
createAnimation
(String atlasName, Entity player) Creates an animation component that can be used with a weapon.static Entity
createWeapon
(Weapons weaponType) Creates a new weapon entity based on the given weapon type.static Entity
createWeaponWithAttachment
(Weapons weaponType, boolean laser, boolean bullet) Creates a weapon with attachments on it
-
Method Details
-
createWeapon
Creates a new weapon entity based on the given weapon type.This method retrieves the
WeaponConfig
for the providedWeapons
type, builds anEntity
using its texture, and attaches the appropriate components to configure its stats and item type (melee or ranged).- Parameters:
weaponType
- the type of weapon to create (defines stats and configuration)- Returns:
- a fully configured
Entity
representing the weapon
-
createWeaponWithAttachment
Creates a weapon with attachments on it- Parameters:
weaponType
- the type of weaponlaser
- true if laser attachment is wantedbullet
- true if bullet attachment is wanted- Returns:
- the new weapon with attachments
-
createAnimation
Creates an animation component that can be used with a weapon.- Parameters:
atlasName
- Name of the animation atlas.player
- Current player.- Returns:
- An AnimationRenderComponent that can be attached to a weapon.
-