EntityManager.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef ENTITY_MANAGER_H
  2. #define ENTITY_MANAGER_H
  3. #include <OgreSingleton.h>
  4. #include "Background2D.h"
  5. #include "Entity.h"
  6. #include "EntityPoint.h"
  7. #include "EntityTrigger.h"
  8. #include "Event.h"
  9. #include "Walkmesh.h"
  10. class EntityManager : public Ogre::Singleton< EntityManager >
  11. {
  12. public:
  13. EntityManager();
  14. virtual ~EntityManager();
  15. void Input(const QGears::Event& event);
  16. void Update();
  17. void UpdateDebug();
  18. void OnResize();
  19. void Clear();
  20. void ScriptSetPaused( const bool paused );
  21. Walkmesh* GetWalkmesh();
  22. Background2D* GetBackground2D();
  23. void AddEntity( const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position, const Ogre::Degree& direction );
  24. void AddEntity( const Ogre::String& name, const Ogre::String& file_name, const Ogre::Vector3& position, const Ogre::Degree& rotation, const Ogre::Vector3& scale, const Ogre::Quaternion& root_orientation );
  25. void ScriptAddEntity( const char* name, const char* file_name, const float x, const float y, const float z, const float direction );
  26. void AddEntityTrigger( const Ogre::String& name, const Ogre::Vector3& point1, const Ogre::Vector3& point2, const bool enabled );
  27. void AddEntityPoint( const Ogre::String& name, const Ogre::Vector3& position, const float rotation );
  28. void AddEntityScript( const Ogre::String& name );
  29. void ScriptAddEntityScript( const char* name );
  30. Entity* GetEntity( const Ogre::String& name ) const;
  31. Entity* ScriptGetEntity( const char* name ) const;
  32. EntityPoint* ScriptGetEntityPoint( const char* name ) const;
  33. void ScriptSetPlayerEntity( const char* name );
  34. void ScriptUnsetPlayerEntity();
  35. void ScriptPlayerLock( const bool lock );
  36. void SetPlayerMoveRotation( const Ogre::Radian rotation );
  37. private:
  38. // movement
  39. bool SetEntityOnWalkmesh( Entity* entity );
  40. bool PerformWalkmeshMove( Entity* entity, const float speed );
  41. bool WalkmeshBorderCross( Entity* entity, Ogre::Vector3& position, const Ogre::Vector2& move_vector );
  42. bool CheckSolidCollisions( Entity* entity, Ogre::Vector3& position );
  43. void SetEntityDirectionByVector( Entity* entity, const Ogre::Vector2& vector );
  44. void CheckTriggers( Entity* entity, Ogre::Vector3& position );
  45. void CheckEntityInteract();
  46. void SetNextOffsetStep( Entity* entity );
  47. void SetNextTurnStep( Entity* entity );
  48. void SetNextLinearStep( Entity* entity );
  49. void SetNextJumpStep( Entity* entity );
  50. void SetNextScrollStep();
  51. private:
  52. bool m_Paused;
  53. Walkmesh m_Walkmesh;
  54. Background2D m_Background2D;
  55. Ogre::String m_EntityTableName;
  56. std::vector< Entity* > m_Entity;
  57. Entity* m_PlayerEntity;
  58. Ogre::Vector3 m_PlayerMove;
  59. Ogre::Radian m_PlayerMoveRotation;
  60. bool m_PlayerLock;
  61. bool m_PlayerRun;
  62. std::vector< EntityTrigger* > m_EntityTriggers;
  63. std::vector< EntityPoint* > m_EntityPoints;
  64. std::vector< Ogre::String > m_EntityScripts;
  65. Ogre::SceneNode* m_SceneNode;
  66. Ogre::Entity* m_Grid;
  67. Ogre::Entity* m_Axis;
  68. };
  69. #endif // ENTITY_MANAGER_H