Class WeaponsFactory

java.lang.Object
com.csse3200.game.entities.factories.items.WeaponsFactory

public class WeaponsFactory extends Object
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 Details

    • createWeapon

      public static Entity createWeapon(Weapons weaponType)
      Creates a new weapon entity based on the given weapon type.

      This method retrieves the WeaponConfig for the provided Weapons type, builds an Entity 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

      public static Entity createWeaponWithAttachment(Weapons weaponType, boolean laser, boolean bullet)
      Creates a weapon with attachments on it
      Parameters:
      weaponType - the type of weapon
      laser - true if laser attachment is wanted
      bullet - true if bullet attachment is wanted
      Returns:
      the new weapon with attachments
    • createAnimation

      public static AnimationRenderComponent createAnimation(String atlasName, Entity player)
      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.