libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
ActionList.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
6#include "ship/core/Action.h"
7
8namespace Ship {
9
17class ActionList : public PartList<Action, std::shared_ptr<Action>> {
18 public:
19 using PartList<Action, std::shared_ptr<Action>>::PartList;
20 using PartList<Action, std::shared_ptr<Action>>::Has;
21 using PartList<Action, std::shared_ptr<Action>>::Get;
22 using PartList<Action, std::shared_ptr<Action>>::GetFirst;
23
24 protected:
30 void Added(std::shared_ptr<Action> action, const bool forced) override;
31
37 void Removed(std::shared_ptr<Action> action, const bool forced) override;
38};
39
40inline void ActionList::Added(std::shared_ptr<Action> action, const bool forced) {
41 if (action) {
42 action->Start();
43 }
44}
45
46inline void ActionList::Removed(std::shared_ptr<Action> action, const bool forced) {
47 if (action) {
48 action->Stop();
49 }
50}
51
52} // namespace Ship
Generic ordered container of Action instances.
Definition ActionList.h:17
void Added(std::shared_ptr< Action > action, const bool forced) override
Starts the action after insertion.
Definition ActionList.h:40
void Removed(std::shared_ptr< Action > action, const bool forced) override
Stops the action after removal.
Definition ActionList.h:46
Represents a discrete, repeatable operation run by a Tickable.
Definition Action.h:35
A thread-safe ordered list of Parts.
Definition PartList.h:114
bool Has() const
Checks whether any Part of type T is in the list.
Definition PartList.h:777
std::shared_ptr< std::vector< std::shared_ptr< Action > > > Get() const
Returns a snapshot (copy) of all currently live Parts in the list.
Definition PartList.h:825
std::shared_ptr< T > GetFirst() const
Returns the first Part that can be dynamic_cast to T.
Definition PartList.h:864
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14