supertux
lit_object.hpp
1 // SuperTux
2 // Copyright (C) 2022 A. Semphris <semphris@protonmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_OBJECT_LIT_OBJECT_HPP
18 #define HEADER_SUPERTUX_OBJECT_LIT_OBJECT_HPP
19 
20 #include "object/moving_sprite.hpp"
21 
22 class ReaderMapping;
23 
30 class LitObject final : public MovingSprite
31 {
32 public:
33  static void register_class(ssq::VM& vm);
34 
35 public:
36  LitObject(const ReaderMapping& reader);
37 
38  virtual void draw(DrawingContext& context) override;
39  virtual void update(float) override;
40 
41  virtual HitResponse collision(GameObject&, const CollisionHit&) override { return ABORT_MOVE; }
42 
43  static std::string class_name() { return "lit-object"; }
44  virtual std::string get_class_name() const override { return class_name(); }
45  virtual std::string get_exposed_class_name() const override { return "LitObject"; }
46  static std::string display_name() { return _("Lit object"); }
47  virtual std::string get_display_name() const override { return display_name(); }
48  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(LitObject)); }
49 
50  virtual ObjectSettings get_settings() override;
51  virtual void after_editor_set() override;
52 
53  virtual int get_layer() const override { return m_layer; }
54 
55  virtual void on_flip(float height) override;
56 
61  std::string get_light_action() const;
67  void set_light_action(const std::string& action);
68 
69 private:
70  Vector m_light_offset;
71  std::string m_light_sprite_name;
72  std::string m_sprite_action;
73  std::string m_light_sprite_action;
74  SpritePtr m_light_sprite;
75 
76 private:
77  LitObject(const LitObject&) = delete;
78  LitObject& operator=(const LitObject&) = delete;
79 };
80 
81 #endif
82 
83 /* EOF */
void set_light_action(const std::string &action)
Sets the light sprite action.
Definition: lit_object.cpp:108
int m_layer
Sprite&#39;s z-position.
Definition: moving_sprite.hpp:153
Definition: object_settings.hpp:39
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: lit_object.hpp:48
std::string get_light_action() const
Returns the current light sprite action.
Definition: lit_object.cpp:102
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: lit_object.hpp:47
virtual HitResponse collision(GameObject &, const CollisionHit &) override
this function is called when the object collided with any other object
Definition: lit_object.hpp:41
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: lit_object.cpp:54
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
A ""LitObject"" that was given a name can be controlled by scripts.
Definition: lit_object.hpp:30
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
virtual void update(float) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: lit_object.cpp:61
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: lit_object.cpp:95