CompanionShieldFactory Class - UQcsse3200/2023-studio-2 GitHub Wiki
Overview
The CompanionShieldFactory
class facilitates the creation and configuration of companion shield entities.The class offers a collection of static methods that streamline the process of creating these shield entities, simplifying game development tasks.The class manages weapon configurations, such as image paths, image scaling, and other properties specific to shields. These configurations are essential for defining the characteristics and appearance of the shield.
Constructors
The CompanionShieldFactory
class features a private constructor with no parameters. This ensures that the class remains a static utility and cannot be instantiated. Instead, the team is encouraged to utilise its static methods for creating companion shield entities.
Methods
createCompanionShield(WeaponType weaponType, Entity companion)
It enables the creation of companion shield entities with specific configurations.
Parameters
weaponType (WeaponType)
: Specifies the type of shield weapon to create. This parameter allows developers to choose the behaviour of the shield, as defensive capabilities.
companion (Entity)
: Identifies the companion entity that the shield will protect and follow. The shield's interactions and positioning are closely tied to this companion entity.
Returns
: The method returns an entity representing the newly created companion shield. This entity is fully configured according to the specified weapon type and is integrated into the game.
Usage
Create a companion shield for a companion entity
Entity companionEntity = ..;
To obtain the companion entity reference
Entity companionShield = CompanionShieldFactory.createCompanionShield(WeaponType.SHIELD, companionEntity);
The createCompanionShield
method allows for the creation of companion shields with different weapon types and automatically configures their appearance based on the specified weapon type.
Dependencies
WeaponControllerComponent
: This component contains logic related to how the shield functions, including aspects like durability, and any special abilities it might have.
WeaponTargetComponent
: This component is responsible for determining the target entity that the shield should follow and protect.
WeaponType
: This class is used to specify the type of shield being created, allowing for customisation and variation in shield behaviour.
Entity
: The shield entity is composed of various components, including the WeaponControllerComponent, WeaponTargetComponent, and possibly others.
WeaponConfig and WeaponConfigs
: WeaponConfigs is a collection of weapon configurations, and WeaponConfig likely represents a single weapon's configuration, including its image path and image scale.
TextureRenderComponent
: This component is used to render the shield's texture. It's responsible for displaying the shield's visual representation in the game world.
FileLoader
: The FileLoader class seems to be responsible for reading configuration data from external files, such as a JSON file containing weapon configurations.