29#ifndef NOMLIB_ACTIONS_IACTION_OBJECT_HPP
30#define NOMLIB_ACTIONS_IACTION_OBJECT_HPP
35#include "nomlib/config.hpp"
36#include "nomlib/system/Timer.hpp"
44 typedef IActionObject self_type;
67 const std::string&
name()
const;
106 virtual std::unique_ptr<IActionObject>
clone()
const = 0;
142 virtual void pause(real32 delta_time) = 0;
153 virtual void resume(real32 delta_time) = 0;
165 virtual void rewind(real32 delta_time) = 0;
208 real32 duration_ = 0.0f;
209 real32 speed_ = 1.0f;
223template<
typename ObjectType,
typename... ObjectArgs>
229 return( std::shared_ptr<ObjectType>(
230 new ObjectType( std::forward<ObjectArgs>(args) ... ) ) );
250template<
typename ObjectType>
251std::shared_ptr<ObjectType>
257 return( std::shared_ptr<ObjectType>(
new ObjectType(actions) ) );
Pure virtual base class interface for actions.
void set_duration(real32 seconds)
Set the duration of the action.
virtual void set_speed(real32 speed)
Set the speed factor of the action.
real32 elapsed_frames_
Internal frames counter.
Timer timer_
Internal time clock (milliseconds resolution).
virtual void release()=0
Free externally referenced resources held by the action.
const std::string & name() const
Get the unique identifier of the action.
std::shared_ptr< ObjectType > create_action(const action_list &actions)
Constructor function for creating an action that uses a collection of actions.
virtual IActionObject::FrameState prev_frame(real32 delta_time)=0
Play the action backwards in time by one time step.
void set_status(FrameState state)
Set the state of the action.
std::shared_ptr< ObjectType > create_action(ObjectArgs &&... args)
Constructor function for creating an action.
virtual IActionObject::FrameState next_frame(real32 delta_time)=0
Play the action forward in time by one time step.
FrameState
The update status of the action.
@ COMPLETED
The action has finished its update loop.
@ PLAYING
The action is still updating; duration remains.
std::function< real32(real32, real32, real32, real32)> timing_curve_func
A function pointer to a timing mode.
virtual std::unique_ptr< IActionObject > clone() const =0
Create a deep copy instance of the action.
virtual void resume(real32 delta_time)=0
Resume the internal state of the action.
virtual void rewind(real32 delta_time)=0
Reset the internal state of the action back to its initial starting values.
IActionObject::FrameState status() const
Get the current state of the action.
void set_name(const std::string &action_id)
Set the unique identifier of the action.
real32 speed() const
Get the speed modifier of the action.
virtual void pause(real32 delta_time)=0
Freeze the action's internal state.
std::vector< std::shared_ptr< IActionObject > > action_list
A collection of actions.
real32 duration() const
Get the duration of the action.
virtual void set_timing_curve(const IActionObject::timing_curve_func &mode)
Set the timing mode of the action.
const IActionObject::timing_curve_func & timing_curve() const
Get the timing mode function used by the action.