Components
Components are the building blocks of entities. Each component has a specific purpose and can be used by multiple entities. By using a component-based architecture, components can easily be reused and combined to create new entities. In addition, this architecture makes it easier to test certain functionalities and to keep the codebase clean.
Components
Cooldown Component
The cooldown component is used to add a cooldown to an entity. This functionality can be used for different purposes, such as limiting the rate of interaction with an entity or preventing spamming of certain actions.
Damage Outline Component
The damage outline component is used to add a damage outline to an entity. It is using the rexOutlinePipeline to create the outline effect.
Interaction Component
The interaction has a trigger area. If a entity enters this area, the interaction component will show a trigger overlay. If the player triggers the interaction, the interaction component will execute a callback function.
Item Collection Animation Component
This component shows an animation when an item is collected.
Local Player Input Component
This component is used to handle the input for the local player and returns velocity values and the animation state based on the input.
Local Transform Sync Component
This component is used to synchronize the transform of the server entity with the local entity.
Remote Transform Sync Component
This component is used to synchronize the transform of the local entity with the server entity.
Player Animation Component
This component is used to play animations for the player entity based on the animation state.
Player Sound Component
This component is used to trigger sound effects on the sound manager based on the player's actions.
Box Sound Component
This component is used to trigger sound effects on the sound manager based on the box's actions.
Speech Bubble Component
This component is used to show a speech bubble above an entity.
Checkpoint Component
This component is used to store the last checkpoint position of an entity. It is intended to be used by the player entity to respawn at the last checkpoint position.
Interface Components
Some components require specific phaser objects. The problem is that Phaser objects are really hard to mock and test. Since most components only need a subset of the phaser object's methods, we can create interfaces for these objects. This way, we can easily mock these interfaces and test the components in isolation.
In TypeScript, interfaces can also be combined:
class SomeComponent {
/**
* This component requires a gameObject that has the
* TransformComponent and SizeComponent
* @param gameObject
*/
constructor(
private gameObject: TransformComponent & SizeComponent
) {}
}Transform Interface Component
This interface defines the methods that are required get and set the position of an entity.
Velocity Interface Component
This interface describes and game object that has a velocity.
Size Interface Component
This interface is used to get the size of a game object.