FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_objSwitch.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_OBJSWITCH_HPP_INCLUDED
18#define _FGE_C_OBJSWITCH_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "C_objSprite.hpp"
22#include "C_object.hpp"
23#include "FastEngine/C_flag.hpp"
24
25#define FGE_OBJSWITCH_CLASSNAME "FGE:OBJ:SWITCH"
26
27namespace fge
28{
29
30class FGE_API ObjSwitch : public fge::Object
31{
32public:
33 ObjSwitch();
34 ObjSwitch(fge::Texture const& t_on, fge::Texture const& t_off, fge::Vector2f const& pos = fge::Vector2f());
35
36 FGE_OBJ_DEFAULT_COPYMETHOD(fge::ObjSwitch)
37
38 fge::Texture const& getTextureOn() const;
39 fge::Texture const& getTextureOff() const;
40 void setTextureOn(fge::Texture const& t_on);
41 void setTextureOff(fge::Texture const& t_off);
42
43 void setColor(fge::Color const& color);
44
45 void setActiveStat(bool active);
46 bool getActiveStat() const;
47
48 FGE_OBJ_UPDATE_DECLARE
49 FGE_OBJ_DRAW_DECLARE
50
51 void save(nlohmann::json& jsonObject, fge::Scene* scene) override;
52 void load(nlohmann::json& jsonObject, fge::Scene* scene) override;
53 void pack(fge::net::Packet& pck) override;
54 void unpack(fge::net::Packet const& pck) override;
55
56 char const* getClassName() const override;
57 char const* getReadableClassName() const override;
58
61
62private:
63 mutable fge::ObjSprite g_sprite;
64
65 fge::Texture g_textureOn;
66 fge::Texture g_textureOff;
67
68 fge::Color g_color;
69
70 bool g_statMouseOn = false;
71 bool g_statActive = false;
72
73 fge::Flag g_flag = false;
74};
75
76} // namespace fge
77
78#endif // _FGE_C_OBJSWITCH_HPP_INCLUDED
Definition C_color.hpp:35
A class to handle flags.
Definition C_flag.hpp:31
Definition C_objSprite.hpp:30
Definition C_objSwitch.hpp:31
void unpack(fge::net::Packet const &pck) override
Unpack the object from a packet.
void load(nlohmann::json &jsonObject, fge::Scene *scene) override
Load the object from a json object.
char const * getReadableClassName() const override
Get a readable version of the class name.
void save(nlohmann::json &jsonObject, fge::Scene *scene) override
Save the object to a json object.
fge::RectFloat getGlobalBounds() const override
Get the global bounds of the object.
char const * getClassName() const override
Get the unique class name of the object.
fge::RectFloat getLocalBounds() const override
Get the local bounds of the object (without any transformations)
void pack(fge::net::Packet &pck) override
Pack the object into a packet.
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
Definition C_packet.hpp:70