Brunot
Loading...
Searching...
No Matches
AnimationSequence.h
Go to the documentation of this file.
1
11// ____ __ __ __
12// /\__ _\/\ \ /\ \/\ \
13// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
14// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
15// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
16// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
17// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
18
19#pragma once
20
21#include "Framework/Entity.h"
22
31{
45template <std::derived_from<Action> a>
46auto typical(const std::vector<Entity*>& intendedTargets, float delayBetweenGroups, int groups, a& intendedAction) -> void
47{
48 for (auto entity : intendedTargets)
49 {
50 // delayBetweenGroups += current action's initial delay * group
51 intendedAction.setInitialDelay(intendedAction.getInitialDelay() + (delayBetweenGroups * groups));
52 // attaches newly adjusted action to entity
53 entity->addAction(intendedAction);
54 }
55}
56
67template <std::derived_from<Action> a>
68auto standardStagger(const std::vector<Entity*>& intendedTargets, float gapBetweenActions, a& intendedAction) -> void
69{
70 auto originalInitialDelay = intendedAction.getInitialDelay();
71 for (auto i = 0u; i < intendedTargets.size(); ++i)
72 {
73 // delayBetweenGroups += current action's initial delay * group
74 intendedAction.setInitialDelay(originalInitialDelay + ((intendedAction.getDuration() + gapBetweenActions) * i));
75 // attaches newly adjusted action to entity
76 intendedTargets[i]->addAction(intendedAction);
77 }
78}
79
93template <std::derived_from<Action> a>
94auto slightOverlap(const std::vector<Entity*>& intendedTargets, float overlapAmount, a& intendedAction) -> void
95{
96 auto originalInitialDelay = intendedAction.getInitialDelay();
97 for (auto i = 0u; i < intendedTargets.size(); ++i)
98 {
99 // delayBetweenGroups += current action's initial delay * group
100 auto sumOfPreviousActions = (intendedAction.getDuration() - overlapAmount) * i;
101 intendedAction.setInitialDelay(originalInitialDelay + sumOfPreviousActions);
102 // attaches newly adjusted action to entity
103 intendedTargets[i]->addAction(intendedAction);
104 }
105}
106
119template <std::derived_from<Action> a>
120auto Staircase(const std::vector<Entity*>& intendedTargets, float delayBetweenActions, a& intendedAction) -> void
121{
122 for (auto i = 0u; i < intendedTargets.size(); ++i)
123 {
124 // Scale up the action duration depending on how many actions come before it
125 intendedAction.setDuration(delayBetweenActions + (delayBetweenActions * i));
126 // attaches newly adjusted action to entity
127 intendedTargets[i]->addAction(intendedAction);
128 }
129}
130
143template <std::derived_from<Action> a>
144auto Spiral(const std::vector<Entity*>& intendedTargets, float numberOfGroups, a& intendedAction) -> void
145{
146 for (auto i = 0u; i < intendedTargets.size(); ++i)
147 {
148 // Scale up the action duration depending on how many actions come before it
149 //intendedAction.setDuration(delayBetweenActions + (delayBetweenActions * i));
150 // attaches newly adjusted action to entity
151 intendedTargets[i]->addAction(intendedAction);
152 }
153}
154
163template <std::derived_from<Action> a>
164auto CreateStagger(const std::vector<a>& intendedAction, float delayBetweenActions) -> void
165{
166 for (int i = 0; i < static_cast<int>(intendedAction.size()); ++i)
167 {
168 intendedAction->setInitialDelay(delayBetweenActions * i);
169 }
170}
171
181template <std::derived_from<Action> a>
182auto SpreadAction(const std::vector<Entity*>& intendedTargets, const a& intendedAction) -> void
183{
184 for (auto entity : intendedTargets)
185 {
186 entity->addAction(intendedAction);
187 }
188}
189}
The class containing all entity elements.
Holds functions that are useful to synchronize actions such that specific visual effects occur.
Definition AnimationSequence.h:31
auto SpreadAction(const std::vector< Entity * > &intendedTargets, const a &intendedAction) -> void
Gives every single Entity the same action, with no special effects.
Definition AnimationSequence.h:182
auto Spiral(const std::vector< Entity * > &intendedTargets, float numberOfGroups, a &intendedAction) -> void
All actions start at the same time, but actions take longer and longer.
Definition AnimationSequence.h:144
auto standardStagger(const std::vector< Entity * > &intendedTargets, float gapBetweenActions, a &intendedAction) -> void
Adds an action to every entity, but sets it up such that each action will have a small gap between it...
Definition AnimationSequence.h:68
auto typical(const std::vector< Entity * > &intendedTargets, float delayBetweenGroups, int groups, a &intendedAction) -> void
Sets a group of actions to all have the same initial delay.
Definition AnimationSequence.h:46
auto Staircase(const std::vector< Entity * > &intendedTargets, float delayBetweenActions, a &intendedAction) -> void
All actions start at the same time, but actions take longer and longer.
Definition AnimationSequence.h:120
auto CreateStagger(const std::vector< a > &intendedAction, float delayBetweenActions) -> void
Creates a buffer between actions with the given delay.
Definition AnimationSequence.h:164
auto slightOverlap(const std::vector< Entity * > &intendedTargets, float overlapAmount, a &intendedAction) -> void
Adds an action to every entity, but sets it up such that each action will start a little bit before t...
Definition AnimationSequence.h:94