#include <Mutator.h>
Description
A piecewise function manager that changes inputs over time.
There are some instances where it is useful to model the transformation of a value in a complex manner. The Mutator component provides functionality for simple and complex easing. You can string easing functions together to achieve more complex behavior in one instance of a Mutator through the mutation interface. All times are delt with in seconds and the Mutator always begins at time 0.
Public Types | |
enum | Function { Constant, Linear, Quadratic, SquareRoot, Cubic, Sinusoidal, Logarithmic, RandomDistribution } |
enum | BindFunction { Set, Add, Subtract, Multiply, Divide } |
![]() | |
using | EventHandler = bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args) |
Functions | |
Mutator (float beginValue, float endValue, Function f, float duration) | |
void | Clear (float beginValue) |
void | NewMutation (float when, float value, Function travelFunction) |
void | NewRandomMutation (float when, float minValue, float MaxValue, Function travelFunction) |
void | SetMutationDestination (int mutationIndex, float newValue) |
void | Start () |
void | Stop () |
void | Loop (bool) |
bool | Expired () |
float | GetCurrentTime () |
float | GetEnd () |
float | GetAt (float time) |
float | Value () |
void | OnStep () |
std::string | GetInfo () |
void | Bind (float &, BindFunction f=BindFunction::Set) |
![]() | |
std::string | GetTag () |
Entity * | GetHost () const |
template<typename T > | |
T * | GetHostAs () const |
Entity::ID | GetHostID () const |
bool | EmitEvent (const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={}) |
bool | CanHandleEvent (const std::string &eventName) |
void | InstallHook (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHook (const std::string &eventName, EventHandler) |
void | InstallHandler (const std::string &eventName, EventHandler, void *data=nullptr) |
void | UninstallHandler (const std::string &eventName, EventHandler) |
std::vector< std::string > | GetKnownEvents () const |
Static Functions | |
static float | StepTowards (float current, float destination, float step=.5f, Function f=Function::Linear) |
Additional Inherited Members | |
![]() | |
virtual void | OnDraw () |
virtual void | OnAttach () |
void | InstallEvent (const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr) |
void | UninstallEvent (const std::string &) |
Member Enumeration Documentation
|
strong |
For constructing the Mutator's mutations, you must specify a mutation function. These are the various available.
|
strong |
Constructor & Destructor Documentation
Member Function Documentation
void Clear | ( | float | beginValue | ) |
Resets all mutations.
void NewMutation | ( | float | when, |
float | value, | ||
Function | travelFunction | ||
) |
Sets a new point of mutation.
When denotes when the Mutator will reach the given value, and travelFunction defines how this value is reached.
void NewRandomMutation | ( | float | when, |
float | minValue, | ||
float | MaxValue, | ||
Function | travelFunction | ||
) |
Like NewMutation(), except the destination value is random chosen upon start(). min / max bound the random value.
void SetMutationDestination | ( | int | mutationIndex, |
float | newValue | ||
) |
Sets a new destination value for the mutation.
void Start | ( | ) |
Begins the mutation lifetime.
If it was already started, this function starts the simulation from the beginning.
void Stop | ( | ) |
Stops the mutation.
Stopping the mutation brings it to its end value.
void Loop | ( | bool | ) |
Sets whether or not to automatically restart after the final value has been reached.
bool Expired | ( | ) |
Returns whether or not the terminal value has been reached.
float GetCurrentTime | ( | ) |
Returns the mutator's progress in seconds.
float GetEnd | ( | ) |
Returns the duration of the mutation.
float GetAt | ( | float | time | ) |
Returns the Mutator's mutation value at a specified time.
float Value | ( | ) |
Returns the current mutation value result.
void Bind | ( | float & | , |
BindFunction | f = BindFunction::Set |
||
) |
|
static |
Iteratively eases a value to another and returns the stepped value. This is known in other toolkits as the 'lerp' function.
|
virtual |
|
virtual |
Returns a string containing human-readable information on the state of the component.
Reimplemented from Component.
The documentation for this class was generated from the following file:
- /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Components/Mutator.h