Reading:
Plugin: Status Effects
Next: About this plugin
Introduction
The Status Effect Plugin is used to track and modify "Status Effect" values over time. In games examples of such values are: health points, player score, a hunger meter, a happiness meter. Create any effect.
This is especially useful in games and simulations where so many different effects can be created.
Modifiers can alter a Status Effect over time. For example, to remove stamina while running, or add health over time.
The Status Effects plugin is very compact and set up to make it simple to implement any effects and modifiers, through code and datatable.
The UI can be connected to display information of a Status Effect.
The example given on the image is a demo project, which is not included with the plugin.
Benefits
- Track and modify values over time.
- Compact and universal. Ideal for games and simulations.
- Simple to set up in code and datatable.
- Widgets can connect to Status Effects (add a health bar to your game).
- Multiple modifiers can alter a Status Effect over time.
Requirements
Installation
First follow the docs on how to install a plugin in general.
This plugin does not require any setup.
While not made a requirement, I strongly recommend using my plugins "Central UI", "UI Additions", for implementation of any UI.
Next: Usage
Status Effect
A Status Effect is a class which manages a single value (float). It tracks the current value, it's min / max amounts and broadcasts events for when the value changes, or when the value reaches its min / max amount. Status Effects are injected into a Status Effect Component. There they are named and track a value with a purpose, such as a character's health or stamina points. The Status Effect itself is injectable for any purpose, which is especially useful for games and simulations where many different effects can be created.
Status Effect Component
A Status Effect modifier will be removed automatically when its remaining duration reaches 0. Think of a fantasy game where you drink a magic potion to recover some health points for a few seconds.
Status Effect Info Widget
The "Status Effect Info Widget" visualizes data from a status effect. The example uses a bar style to display health / stamina points for a game character.
Widget designers have full freedom over their design. A bar widget is not required. Designers override the method "Update Status Effect Appearance" to implement a visual response to changes in values of the status effect.
A Status Effect needs to be tracked. This is done by calling the method "Bind Status Effect" on this widget. Status effects are retrieved from a "Status Effects Component". This component is usually added to a Pawn, or another actor.
Visibility of this widget is automatically managed. This widget will collapse when the status effect is removed from the Status Effect Component, and shown when inserted. If you want additional control over visibility of Status Effect Info widgets you should control visibility of a parent panel.
Status Effect Panel
The Status Effect Panel is a User Widget. It is an example asset which shows how to set up the "Status Effect Info Widget" on a panel, setting up their style and status effect binding in one place.
In the example I retrieved a Status Effect Component from a Pawn associated with the widget's controller. The Pawn was a logical place to attach the component, because this component tracks the Pawn's health and stamina Status Effects.
The simplest method to get the widget to show on your screen, is to add it to the viewport as shown on the image. If you are using my UI Additions plugin and follow best practices, you can follow its documentation to add this panel to the HUD in a different way. Its HUD class properly manages the entire UI.