17#ifndef _FGE_C_OBJECT_HPP_INCLUDED
18#define _FGE_C_OBJECT_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "C_childObjectsAccessor.hpp"
22#include "FastEngine/C_event.hpp"
23#include "FastEngine/C_propertyList.hpp"
24#include "FastEngine/C_quad.hpp"
25#include "FastEngine/C_rect.hpp"
26#include "FastEngine/C_tagList.hpp"
27#include "FastEngine/graphic/C_drawable.hpp"
28#include "FastEngine/graphic/C_transformable.hpp"
29#include "FastEngine/network/C_networkType.hpp"
30#include "FastEngine/object/C_objectAnchor.hpp"
31#include "FastEngine/vulkan/C_context.hpp"
37#define FGE_OBJ_BADCLASSNAME "NULL"
38#define FGE_OBJ_NOSCENE nullptr
39#define FGE_OBJ_DEFAULT_COPYMETHOD(objClass) \
40 fge::Object* copy() override \
42 return new objClass(*this); \
46 #define FGE_OBJ_UPDATE_DECLARE \
47 void update(fge::Event& event, const std::chrono::microseconds& deltaTime, fge::Scene& scene) override;
49 #define FGE_OBJ_UPDATE_DECLARE \
50 void update(fge::RenderWindow& screen, fge::Event& event, const std::chrono::microseconds& deltaTime, \
51 fge::Scene& scene) override;
55 #define FGE_OBJ_UPDATE_BODY(class_) \
56 void class_::update([[maybe_unused]] fge::Event& event, \
57 [[maybe_unused]] const std::chrono::microseconds& deltaTime, \
58 [[maybe_unused]] fge::Scene& scene)
60 #define FGE_OBJ_UPDATE_CALL(object_) object_.update(event, deltaTime, scene)
61 #define FGE_OBJ_UPDATE_PTRCALL(object_) object_->update(event, deltaTime, scene)
63 #define FGE_OBJ_UPDATE_BODY(class_) \
64 void class_::update([[maybe_unused]] fge::RenderWindow& screen, [[maybe_unused]] fge::Event& event, \
65 [[maybe_unused]] const std::chrono::microseconds& deltaTime, \
66 [[maybe_unused]] fge::Scene& scene)
68 #define FGE_OBJ_UPDATE_CALL(object_) object_.update(screen, event, deltaTime, scene)
69 #define FGE_OBJ_UPDATE_PTRCALL(object_) object_->update(screen, event, deltaTime, scene)
73 #define FGE_OBJ_DRAW_DECLARE
75 #define FGE_OBJ_DRAW_DECLARE void draw(fge::RenderTarget& target, const fge::RenderStates& states) const override;
78#define FGE_OBJ_DRAW_BODY(class_) void class_::draw(fge::RenderTarget& target, const fge::RenderStates& states) const
83class GuiElementHandler;
89using ObjectDataWeak = std::weak_ptr<fge::ObjectData>;
90using ObjectDataShared = std::shared_ptr<fge::ObjectData>;
151 virtual void update(
fge::Event& event, std::chrono::microseconds
const& deltaTime,
fge::Scene& scene);
152 void update(
fge::Event& event, std::chrono::microseconds
const& deltaTime);
164#ifndef FGE_DEF_SERVER
170 virtual void networkRegister();
231 [[nodiscard]]
virtual fge::Quad getGlobalQuad()
const;
238 [[nodiscard]]
virtual fge::Quad getLocalQuad()
const;
295 enum class DrawModes : uint8_t
301 DRAW_DEFAULT = DRAW_IF_ON_TARGET
303 fge::Object::DrawModes _drawMode{
304 fge::Object::DrawModes::DRAW_DEFAULT};
306 enum class CallbackContextModes : uint8_t
311 CONTEXT_DEFAULT = CONTEXT_AUTO
313 fge::Object::CallbackContextModes _callbackContextMode{
314 fge::Object::CallbackContextModes::
319 enum ChildrenControlFlags : uint8_t
321 CHILDREN_AUTO_CLEAR_ON_REMOVE = 1 << 0,
322 CHILDREN_AUTO_UPDATE = 1 << 1,
323 CHILDREN_AUTO_DRAW = 1 << 2,
325 CHILDREN_DEFAULT = CHILDREN_AUTO_CLEAR_ON_REMOVE
327 using ChildrenControlFlags_t = std::underlying_type_t<ChildrenControlFlags>;
329 ChildrenControlFlags_t _childrenControlFlags{CHILDREN_DEFAULT};
Definition C_objectAnchor.hpp:40
Definition C_childObjectsAccessor.hpp:40
Definition C_drawable.hpp:36
This class is a wrapper for SDL events.
Definition C_event.hpp:59
A class to handle highest priority selection of GUI elements.
Definition C_guiElement.hpp:235
A base class for all GUI elements.
Definition C_guiElement.hpp:120
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
fge::net::NetworkTypeHandler _netList
The network types container of the object.
Definition C_object.hpp:289
fge::Vector2f getParentsScale() const
Retrieve recursively all parents scale by combining them.
bool saveInFile(std::string const &path)
Save the object in a file.
virtual void draw(fge::RenderTarget &target, fge::RenderStates const &states) const override
Method called every frame to draw the object.
virtual fge::Object * copy()
Duplicate the object.
fge::TagList _tags
The tags of the object.
Definition C_object.hpp:284
bool loadFromFile(std::string const &path)
Load the object from a file.
virtual void first(fge::Scene &scene)
Method called when the object is added to a scene for initialization purposes.
virtual char const * getClassName() const
Get the unique class name of the object.
virtual char const * getReadableClassName() const
Get a readable version of the class name.
virtual void update(fge::RenderWindow &screen, fge::Event &event, std::chrono::microseconds const &deltaTime, fge::Scene &scene)
Main method called every frame.
virtual fge::RectFloat getGlobalBounds() const
Get the global bounds of the object.
fge::ObjectDataWeak _myObjectData
The object data of the object (valid only if the object is in a scene)
Definition C_object.hpp:293
virtual void save(nlohmann::json &jsonObject, fge::Scene *scene)
Save the object to a json object.
fge::ChildObjectsAccessor _children
An access to child objects of this object.
Definition C_object.hpp:330
virtual void netSignaled(int8_t signal)
Method called when the object is signaled by the network.
virtual void pack(fge::net::Packet &pck)
Pack the object into a packet.
static fge::Object * LoadFromFile(std::string const &path)
Static form of the loadFromFile method.
virtual fge::RectFloat getLocalBounds() const
Get the local bounds of the object (without any transformations)
virtual fge::GuiElement * getGuiElement()
Get the GuiElement attached to this object if there is one.
fge::PropertyList _properties
The properties of the object.
Definition C_object.hpp:285
virtual void unpack(fge::net::Packet const &pck)
Unpack the object from a packet.
virtual void removed(fge::Scene &scene)
Method called when the object is removed from a scene.
virtual void load(nlohmann::json &jsonObject, fge::Scene *scene)
Load the object from a json object.
virtual void callbackRegister(fge::Event &event, fge::GuiElementHandler *guiElementHandlerPtr)
Ask the object to register all callbacks it needs to receive events.
glm::mat4 getParentsTransform() const
Retrieve recursively all parents transform by combining them.
virtual void transfered(fge::Scene &oldScene, fge::Scene &newScene)
Method called when the object is transferred from a scene to another.
A class that map a string to a Property.
Definition C_propertyList.hpp:35
The RenderStates class contains all the information needed to render something.
Definition C_renderStates.hpp:412
Definition C_renderTarget.hpp:56
Definition C_renderWindow.hpp:51
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
Definition C_tagList.hpp:28
A regroupment of network types.
Definition C_networkType.hpp:590
Definition C_packet.hpp:70