PlayerSkillComponent - UQdeco2800/2022-studio-2 GitHub Wiki
PlayerSkillComponent
Framework Design
This class was designed to accommodate all of the skill-based actions required of player actions. This accommodates the setting of new skills as well as any movement or attack based skills. One very important consideration when using this class is that the update function of this class must be called for each frame, otherwise all skill behaviour will potentially degenerate. This class was also designed to be a subcomponent of the player actions component, and aims to be controlled by this master component but also have all of it's internal working on the skills functions decoupled from the player actions component.
Update Function
This function needs to be called each frame as a part of the extended component class. This function in the case of this PlayerSkillComponent checks for the duration and completion of skills internally, and as such without calling this function each frame the duration of skills will be infinte and skill design will degenerate.
Starting the skill functionality
The skill starts were standardised within this file to have the handle name startX() where X is the name of the skill. This starts the skill state within the skill component. All skills and handles implemented are below:
- startInvulnerabilitySkill()
- startDash()
- startTeleport()
- startDodge()
- startBlock()
- startRoot()
- startUltimate()
- startProjectileSkill()
- startFireballUltimate()
- startBleed()
- startCharge()
- aoeAttack() (this should be standardised in future iterations)
Movement Modified Skill Activation
Movement Modification
The getModifiedMovement class aims to function as a black box design, with input base movement vector, and an output vector which contains all movement modifications based on the player skill state.
public Vector2 getModifiedMovement(Vector2 baseMovement)
This function can also be checked to see if it should be called based on the skill state by calling movementIsModified, which returns true if the skill state would alter the player movement, and false if getModifiedMovement doesn't need to be called based on the skill state.
public boolean movementIsModified()
Skill End Flags
The checkSkillEnd function allows for the skill completion to be registered externally, this function only returns true after completion and on the first call after completion of a skill. After this first call if not caught and used it will return false. As such this function was designed to be used as a continuously polled conditional, and using this in other ways may produce unexpected results.
/**
* Checks for the end of a skill, should be polled continuously in update.
* Note: if not polled continuously cannot guarantee correct behaviour.
* @param skillName - the name of the skill to check end condition
* @return true if the skill has ended and the flag has not been polled
* false if the skill end has been read
*/
public boolean checkSkillEnd(String skillName)