 |
Gorgon Game Engine
|
Go to the documentation of this file.
5 #include "../Animation.h"
28 basic_Storage(A_ &anim,
bool owner =
false) : anim(&anim), isowned(owner) { }
35 other.isowned =
false;
52 isowned = other.isowned;
54 other.isowned =
false;
62 return anim !=
nullptr;
71 throw std::runtime_error(
"Storage contains no animation");
89 this->isowned = owner;
96 anim = &value.MoveOutProvider();
131 return dynamic_cast<typename A_::AnimationType &
>(anim->CreateAnimation(timer));
133 throw std::runtime_error(
"Storage contains no animation");
138 virtual typename A_::AnimationType &
CreateAnimation(
bool create=
true)
const override {
140 return dynamic_cast<typename A_::AnimationType &
>(anim->CreateAnimation(create));
142 throw std::runtime_error(
"Storage contains no animation");
147 bool isowned =
false;
151 template<
class Target_,
class Original_>
155 if(!original.HasAnimation())
159 bool owned = original.
IsOwner();
160 Target_ *anim =
dynamic_cast<Target_*
>(original.Release());
162 throw std::runtime_error(
"Animation types are not compatible");
This class stores animations as a part of itself so that it can be moved around as a value rather tha...
Definition: Storage.h:21
basic_Instance< Target_ > AnimationCast(basic_Instance< Original_ > &&original)
Moves one type of animation into another.
Definition: Instance.h:130
virtual A_::AnimationType & CreateAnimation(bool create=true) const override
This function creates a new animation from the stored animation provider.
Definition: Storage.h:138
Controllers are required to progress animations.
Definition: Animation.h:65
bool IsOwner() const
Whether the stored animation is owned by this container.
Definition: Storage.h:123
void SetAnimation(A_ &&value)
Sets the animation stored in this container.
Definition: Storage.h:93
basic_Storage(basic_Storage &&other)
Move constructor.
Definition: Storage.h:34
void Remove()
Removes the animation stored in the container, if the container owns the animation,...
Definition: Storage.h:103
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This interface marks a class as animation provider.
Definition: Animation.h:283
A_ * operator->() const
Alias for GetAnimation.
Definition: Storage.h:80
A_ * Release()
Removes the animation from the storage without destroying it.
Definition: Storage.h:112
basic_Storage(const basic_Storage &)=delete
Copy constructor is disabled for ownership reasons.
void SetAnimation(A_ &value, bool owner=false)
Sets the animation stored in this container.
Definition: Storage.h:85
constexpr Type Animation
Definition: GID.h:187
Specializing this class allows code injection to animation storages.
Definition: Storage.h:13
bool HasAnimation() const
Check if this storage has an animation.
Definition: Storage.h:61
virtual A_::AnimationType & CreateAnimation(ControllerBase &timer) const override
This function creates a new animation from the stored animation provider.
Definition: Storage.h:129
A_ & operator*() const
Alias for GetAnimation.
Definition: Storage.h:75
basic_Storage(A_ &anim, bool owner=false)
Filling constructor.
Definition: Storage.h:28
basic_Storage & operator=(const basic_Storage &)=delete
Copy assignment.
basic_Storage()=default
Empty constructor.
virtual auto MoveOutProvider() -> decltype(*this) override
This function moves this animation provider into a new provider.
Definition: Storage.h:40
A_ & GetAnimation() const
Returns the animation stored in the object.
Definition: Storage.h:67