MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
areaeffect.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine 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  The Mezzanine Engine 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 The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _areaeffect_h
41 #define _areaeffect_h
42 
43 #include "worldobject.h"
44 #include "colourvalue.h"
45 
46 namespace Mezzanine
47 {
48  namespace Graphics
49  {
50  class EntityProxy;
51  class ParticleSystemProxy;
52  }
53  namespace Physics
54  {
55  class GhostProxy;
56  }
57  ///////////////////////////////////////////////////////////////////////////////
58  /// @brief This class is used to define area's in the world that have unique effects.
59  /// @details Common uses for this class are for gravity fields, and explosions. But can be made to do more. @n
60  /// Note: This is a base class intended to be derived from. This class cannot be created itself. To make an
61  /// AreaEffect class that does what you want it to, simple inherit from this class with an AE class of your own,
62  /// and define the ApplyEffect() function to do what you want your effect to do.
63  ///////////////////////////////////////
65  {
66  public:
67  /// @brief Basic container type for Object storage by this class.
68  typedef std::vector< WorldObject* > ObjectContainer;
69  /// @brief Iterator type for Object instances stored by this class.
70  typedef ObjectContainer::iterator ObjectIterator;
71  /// @brief Const Iterator type for Object instances stored by this class.
72  typedef ObjectContainer::const_iterator ConstObjectIterator;
73  protected:
74  /// @internal
75  /// @brief Container for actors within the field area.
77  /// @internal
78  /// @brief Container of actors that have been added since last frame.
80  /// @internal
81  /// @brief Container of actors that have been removed since last frame.
83  /// @internal
84  /// @brief Container of proxies that representing this AE field.
85  ProxyContainer AEProxies;
86  /// @internal
87  /// @brief A pointer to the ghost powering this AE field.
89 
90  /// @internal
91  /// @brief Common constructor method for AreaEffect base class.
92  virtual void CreateAreaEffect();
93  /// @internal
94  /// @brief Common destructor method for AreaEffect base class.
95  virtual void DestroyAreaEffect();
96  public:
97  /// @brief Blank constructor.
98  /// @param TheWorld A pointer to the world this object belongs to.
99  AreaEffect(World* TheWorld);
100  /// @brief Class constructor.
101  /// @param Name The name to be given to this object.
102  /// @param TheWorld A pointer to the world this object belongs to.
103  AreaEffect(const String& Name, World* TheWorld);
104  /// @brief Class destructor.
105  virtual ~AreaEffect();
106 
107  ///////////////////////////////////////////////////////////////////////////////
108  // Utility
109 
110  /// @copydoc Mezzanine::WorldObject::GetType() const
111  virtual WorldObjectType GetType() const;
112 
113  /// @brief Gets a pointer to the physics portion of this AreaEffect.
114  /// @return Returns a pointer to the Ghost proxy representing the physics portion of this AreaEffect.
115  virtual Physics::GhostProxy* GetGhostProxy() const;
116 
117  /// @brief Defines and applies the effect of the field.
118  /// @details When inheriting this class, this function is what defines the effect the field has. @n
119  /// This function will be called on by the physics manager and shouldn't be called manually.
120  virtual void ApplyEffect() = 0;
121 
122  /// @copydoc Mezzanine::WorldObject::IsInWorld() const
123  virtual Boolean IsInWorld() const;
124 
125  /// @copydoc Mezzanine::WorldObject::IsStatic() const
126  virtual Boolean IsStatic() const;
127  /// @copydoc Mezzanine::WorldObject::IsKinematic() const
128  virtual Boolean IsKinematic() const;
129 
130  /// @copydoc Mezzanine::WorldObject::GetProxies(ProxyContainer&)
131  virtual void GetProxies(ProxyContainer& Proxies);
132  /// @copydoc Mezzanine::WorldObject::GetProxies(const UInt32, ProxyContainer&)
133  virtual void GetProxies(const UInt32 Types, ProxyContainer& Proxies);
134 
135  ///////////////////////////////////////////////////////////////////////////////
136  // Working with the World
137 
138  /// @copydoc Mezzanine::WorldObject::AddToWorld()
139  virtual void AddToWorld();
140  /// @copydoc Mezzanine::WorldObject::RemoveFromWorld()
141  virtual void RemoveFromWorld();
142 
143  ///////////////////////////////////////////////////////////////////////////////
144  // Overlapping Object Management
145 
146  /// @brief Gets the number of objects currently overlapping with this AE.
147  /// @return Returns the number of objects inside this AE.
148  UInt32 GetNumOverlappingObjects() const;
149  /// @brief Gets the number of objects added to this AE since the last update.
150  /// @note Updates are usually once per frame, but can be manipulated to be more or less frequent.
151  /// @return Returns the number of new objects overlapping with this AE.
152  UInt32 GetNumAddedObjects() const;
153  /// @brief Gets the number of objects removed from this AE since the last update.
154  /// @note Updates are usually once per frame, but can be manipulated to be more or less frequent.
155  /// @return Returns the number of objects that were found to no longer be overlapping during the last update.
156  UInt32 GetNumRemovedObjects() const;
157  /// @brief Gets the list of objects within this field.
158  /// @return Returns the list of objects contained within this field.
159  ObjectContainer& GetOverlappingObjects();
160  /// @brief Gets the list of objects that have been added to the list since the last simulation step.
161  /// @return Returns the vector storing all the objects that have been added to the list since the last simulation step.
162  ObjectContainer& GetAddedObjects();
163  /// @brief Gets the list of objects that have been removed from the list since the last simulation step.
164  /// @return Returns the vector storing all the objects that have been removed from the list since the last simulation step.
165  ObjectContainer& GetRemovedObjects();
166 
167  ///////////////////////////////////////////////////////////////////////////////
168  // AreaEffect Properties
169 
170  ///////////////////////////////////////////////////////////////////////////////
171  // Transform Methods
172 
173  /// @copydoc TransformableObject::SetLocation(const Vector3&)
174  virtual void SetLocation(const Vector3& Loc);
175  /// @copydoc TransformableObject::SetLocation(const Real, const Real, const Real)
176  virtual void SetLocation(const Real X, const Real Y, const Real Z);
177  /// @copydoc TransformableObject::GetLocation() const
178  virtual Vector3 GetLocation() const;
179  /// @copydoc TransformableObject::SetOrientation(const Quaternion&)
180  virtual void SetOrientation(const Quaternion& Ori);
181  /// @copydoc TransformableObject::SetOrientation(const Real, const Real, const Real, const Real)
182  virtual void SetOrientation(const Real X, const Real Y, const Real Z, const Real W);
183  /// @copydoc TransformableObject::GetOrientation() const
184  virtual Quaternion GetOrientation() const;
185  /// @copydoc TransformableObject::SetScale(const Vector3&)
186  virtual void SetScale(const Vector3& Sc);
187  /// @copydoc TransformableObject::SetScale(const Real, const Real, const Real)
188  virtual void SetScale(const Real X, const Real Y, const Real Z);
189  /// @copydoc TransformableObject::GetScale() const
190  virtual Vector3 GetScale() const;
191 
192  /// @copydoc TransformableObject::Translate(const Vector3&)
193  virtual void Translate(const Vector3& Trans);
194  /// @copydoc TransformableObject::Translate(const Real, const Real, const Real)
195  virtual void Translate(const Real X, const Real Y, const Real Z);
196  /// @copydoc TransformableObject::Yaw(const Real)
197  virtual void Yaw(const Real Angle);
198  /// @copydoc TransformableObject::Pitch(const Real)
199  virtual void Pitch(const Real Angle);
200  /// @copydoc TransformableObject::Roll(const Real)
201  virtual void Roll(const Real Angle);
202  /// @copydoc TransformableObject::Rotate(const Vector3&, const Real)
203  virtual void Rotate(const Vector3& Axis, const Real Angle);
204  /// @copydoc TransformableObject::Rotate(const Quaternion&)
205  virtual void Rotate(const Quaternion& Rotation);
206  /// @copydoc TransformableObject::Scale(const Vector3&)
207  virtual void Scale(const Vector3& Scale);
208  /// @copydoc TransformableObject::Scale(const Real, const Real, const Real)
209  virtual void Scale(const Real X, const Real Y, const Real Z);
210 
211  ///////////////////////////////////////////////////////////////////////////////
212  // Serialization
213 
214  /// @copydoc Mezzanine::WorldObject::ProtoSerializeProperties(XML::Node& SelfRoot) const
215  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
216  /// @copydoc Mezzanine::WorldObject::ProtoSerializeProxies(XML::Node&) const
217  virtual void ProtoSerializeProxies(XML::Node& SelfRoot) const;
218 
219  /// @copydoc Mezzanine::WorldObject::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
220  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
221  /// @copydoc Mezzanine::WorldObject::ProtoDeSerializeProxies(const XML::Node&)
222  virtual void ProtoDeSerializeProxies(const XML::Node& SelfRoot);
223 
224  /// @copydoc Mezzanine::WorldObject::GetDerivedSerializableName() const
225  virtual String GetDerivedSerializableName() const;
226  /// @copydoc Mezzanine::WorldObject::GetSerializableName()
227  static String GetSerializableName();
228 
229  ///////////////////////////////////////////////////////////////////////////////
230  // Internal Methods
231 
232  /// @copydoc Mezzanine::WorldObject::_Update()
233  virtual void _Update();
234  /// @copydoc Mezzanine::WorldObject::_NotifyProxyDestroyed(WorldProxy*)
235  virtual void _NotifyProxyDestroyed(WorldProxy* ToBeDestroyed);
236  };//AreaEffect
237 
238  ///////////////////////////////////////////////////////////////////////////////
239  /// @brief A base factory type for the creation of AreaEffect objects.
240  /// @details
241  ///////////////////////////////////////
243  {
244  public:
245  /// @brief Class constructor.
247  /// @brief Class destructor.
248  virtual ~AreaEffectFactory() { }
249 
250  /// @brief Gets the name of the AreaEffect that is created by this factory.
251  /// @return Returns the typename of the AreaEffect created by this factory.
252  virtual String GetTypeName() const = 0;
253 
254  /// @brief Creates a AreaEffect of the type represented by this factory.
255  /// @param Name The name to be given to this object.
256  /// @param TheWorld A pointer to the world this object belongs to.
257  /// @param Params A NameValuePairList containing the params to be applied during construction.
258  /// @return Returns a pointer to the AreaEffect created.
259  virtual AreaEffect* CreateAreaEffect(const String& Name, World* TheWorld, const NameValuePairMap& Params) = 0;
260  /// @brief Creates a AreaEffect from XML.
261  /// @param XMLNode The node of the xml document to construct from.
262  /// @param TheWorld A pointer to the world this object belongs to.
263  /// @return Returns a pointer to the AreaEffect created.
264  virtual AreaEffect* CreateAreaEffect(const XML::Node& XMLNode, World* TheWorld) = 0;
265  /// @brief Destroys a AreaEffect created by this factory.
266  /// @param ToBeDestroyed A pointer to the AreaEffect to be destroyed.
267  virtual void DestroyAreaEffect(AreaEffect* ToBeDestroyed) = 0;
268  };//AreaEffectFactory
269 }//Mezzanine
270 
271 #endif