Emergency 20 Dokumentation  4.2.0
CommandTargetComponent.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Forward declarations ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23  class Command;
24 }
25 namespace Ogre
26 {
27  class ManualObject;
28 }
29 
30 
31 //[-------------------------------------------------------]
32 //[ Namespace ]
33 //[-------------------------------------------------------]
34 namespace em5
35 {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Classes ]
40  //[-------------------------------------------------------]
46  {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Public definitions ]
51  //[-------------------------------------------------------]
52  public:
53  static const uint32 COMPONENT_ID;
54 
55 
56  //[-------------------------------------------------------]
57  //[ Public methods ]
58  //[-------------------------------------------------------]
59  public:
67  explicit CommandTargetComponent(qsf::Prototype* prototype);
68 
73  virtual ~CommandTargetComponent();
74 
79  inline const Command* getCommand() const { return mCommand; }
80 
85  void setCommand(const Command* command);
86 
87 
88  //[-------------------------------------------------------]
89  //[ Protected virtual qsf::Component methods ]
90  //[-------------------------------------------------------]
91  protected:
92  virtual void onShutdown() override;
93  virtual void onSetSimulating(bool simulating) override;
94 
95 
96  //[-------------------------------------------------------]
97  //[ Private methods ]
98  //[-------------------------------------------------------]
99  private:
100  void updateShownIcon(bool forceRecreation);
101 
102  glm::vec3 getIconWorldPosition() const;
103  bool projectToScreen(const glm::vec3& worldSpacePosition, const glm::vec2& screenSpaceSize, glm::vec2& outClipSpacePosition, glm::vec2& outClipSpaceSize) const;
104 
105  void destroyOgreManualObject();
106 
107 
108  //[-------------------------------------------------------]
109  //[ Private data ]
110  //[-------------------------------------------------------]
111  private:
112  const Command* mCommand;
113  Ogre::ManualObject* mOgreManualObject;
114 
115 
116  //[-------------------------------------------------------]
117  //[ CAMP reflection system ]
118  //[-------------------------------------------------------]
119  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
120 
121 
122  };
123 
124 
125 //[-------------------------------------------------------]
126 //[ Namespace ]
127 //[-------------------------------------------------------]
128 } // em5
129 
130 
131 //[-------------------------------------------------------]
132 //[ CAMP reflection system ]
133 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Abstract component class.
Definition: Component.h:105
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Abstract EMERGENCY 5 command base class.
Definition: Command.h:44
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
const Command * getCommand() const
Get command.
Definition: CommandTargetComponent.h:79
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const uint32 COMPONENT_ID
"em5::CommandTargetComponent" unique component ID
Definition: CommandTargetComponent.h:53
Prototype class.
Definition: Prototype.h:100
Definition: BuildingClippingManager.h:23
EMERGENCY 5 command target component.
Definition: CommandTargetComponent.h:45