neoGFX
C++ GPU-oriented GUI library and app/game creation framework.
i_game_object.hpp
Go to the documentation of this file.
1 // i_game_object.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2015 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #pragma once
20 
21 #include <neogfx/neogfx.hpp>
22 #include <neolib/uuid.hpp>
23 
24 namespace neogfx
25 {
26  enum class object_category
27  {
28  Sprite,
30  Custom,
31  Shape // Shape must sort last
32  };
33 
35 
36  class i_shape;
37  class i_collidable_object;
38  class i_physical_object;
39 
41  {
42  public:
43  struct not_a_shape : std::logic_error { not_a_shape() : std::logic_error("neogfx::i_game_object::not_a_shape") {} };
44  struct not_a_collidable_object : std::logic_error { not_a_collidable_object() : std::logic_error("neogfx::i_game_object::not_a_collidable_object") {} };
45  struct not_a_physical_object : std::logic_error { not_a_physical_object() : std::logic_error("neogfx::i_game_object::not_a_physical_object") {} };
46  struct not_implemented : std::logic_error { not_implemented() : std::logic_error("neogfx::i_game_object::not_implemented") {} };
47  public:
48  virtual ~i_game_object() {}
49  public:
50  virtual object_category category() const = 0;
51  virtual const i_shape& as_shape() const = 0;
52  virtual i_shape& as_shape() = 0;
53  virtual const i_collidable_object& as_collidable_object() const = 0;
54  virtual i_collidable_object& as_collidable_object() = 0;
55  virtual const i_physical_object& as_physical_object() const = 0;
56  virtual i_physical_object& as_physical_object() = 0;
57  virtual const object_type& type() const { static object_type sNullTypeId = {}; return sNullTypeId; }
58  virtual bool killed() const = 0;
59  virtual void kill() = 0;
60  };
61 }
neolib::uuid object_type
virtual const object_type & type() const