Brunot
Loading...
Searching...
No Matches
TranslateActionMessage.h
Go to the documentation of this file.
1// File: TranslateActionMessage.h
2// Description: The base class of all messages. All derived messages should hold information, this class exists
3// so we can polymorphically pass around messages
4// Author(s): Ori Balashov (ori.balashov@digipen.edu)
5// 2025 / 10 / 24
6// (C) Digipen 2025
7// ____ __ __ __
8// /\__ _\/\ \ /\ \/\ \
9// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
10// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
11// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
12// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
13// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
14#pragma once
15#include "Message.h"
17
18struct Vector4D;
19
20namespace sys
21{
22class Json;
23}
24
25using Stream = sys::Json;
26
27using Point2D = Vector4D;
28
29// Note: This implementation is inspired by Ravi Richards' (Man O' Ware) Message class, although no code has been copied
30
32{
33
34 TranslateActionMessage(unsigned int uuid, float actionDuration, Point2D destination,
35 const std::function<float(float, float)>& easeFunction);
39 auto operator=(TranslateActionMessage&& other) noexcept -> TranslateActionMessage& = default;
40 ~TranslateActionMessage() override = default;
41
42 auto clone() const -> std::unique_ptr<Message> override
43 {
44 return std::make_unique<TranslateActionMessage>(*this);
45 }
46
47 auto load(Stream& stream) -> void override;
48 auto save(Stream& stream) const -> void override;
49
50 auto getObjectID() const -> unsigned int;
51 auto getDuration() const -> float;
52 auto getEndGoal() const -> const Point2D&;
53 auto getEasingFunction() const -> const std::function<float(float, float)>&;
54
55private:
56 unsigned int objectID;
57 float duration;
60 std::function<float(float, float)> easingFunction;
61};
sys::Json Stream
Definition AudioObject.h:20
Vector4D Point2D
Definition Transform.h:21
Definition Json.h:32
the type of elements in a basic_json container
Definition GameObject.h:32
Message()=default
auto operator=(TranslateActionMessage &&other) noexcept -> TranslateActionMessage &=default
auto load(Stream &stream) -> void override
Definition TranslateActionMessage.cpp:29
std::function< float(float, float)> easingFunction
Definition TranslateActionMessage.h:60
TranslateActionMessage(TranslateActionMessage &&other) noexcept=default
Point2D startPoint
Definition TranslateActionMessage.h:58
auto getObjectID() const -> unsigned int
Definition TranslateActionMessage.cpp:38
auto getDuration() const -> float
Definition TranslateActionMessage.cpp:43
TranslateActionMessage(unsigned int uuid, float actionDuration, Point2D destination, const std::function< float(float, float)> &easeFunction)
Definition TranslateActionMessage.cpp:20
TranslateActionMessage(const TranslateActionMessage &other)=default
auto getEndGoal() const -> const Point2D &
Definition TranslateActionMessage.cpp:48
auto operator=(const TranslateActionMessage &other) -> TranslateActionMessage &=default
auto save(Stream &stream) const -> void override
Definition TranslateActionMessage.cpp:34
auto clone() const -> std::unique_ptr< Message > override
Definition TranslateActionMessage.h:42
Point2D endGoal
Definition TranslateActionMessage.h:59
~TranslateActionMessage() override=default
float duration
Definition TranslateActionMessage.h:57
auto getEasingFunction() const -> const std::function< float(float, float)> &
Definition TranslateActionMessage.cpp:53
unsigned int objectID
Definition TranslateActionMessage.h:56
Definition Vector4D.h:23