Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

World.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*!
  2. * \file include/World.h
  3. * \brief The game world (model)
  4. *
  5. * \author Mongoose
  6. * \author xythobuz
  7. */
  8. #ifndef _WORLD_H_
  9. #define _WORLD_H_
  10. #include <list>
  11. #include <vector>
  12. #include "Entity.h"
  13. #include "Room.h"
  14. #include "SkeletalModel.h"
  15. #include "Sprite.h"
  16. #include "WorldData.h"
  17. /*!
  18. * \brief The game world (model)
  19. */
  20. class World {
  21. public:
  22. /*!
  23. * \brief Deconstructs an object of World
  24. */
  25. ~World();
  26. /*!
  27. * \brief Clears all data in world
  28. */
  29. void destroy();
  30. void addRoom(Room &room);
  31. unsigned int sizeRoom();
  32. Room &getRoom(unsigned int index);
  33. void addSprite(SpriteSequence &sprite);
  34. unsigned int sizeSprite();
  35. SpriteSequence &getSprite(unsigned int index);
  36. void addEntity(Entity &entity);
  37. unsigned int sizeEntity();
  38. Entity &getEntity(unsigned int index);
  39. void addSkeletalModel(SkeletalModel &model);
  40. unsigned int sizeSkeletalModel();
  41. SkeletalModel &getSkeletalModel(unsigned int index);
  42. /*!
  43. * \brief Adds mesh to world
  44. * \param model mesh to add
  45. */
  46. void addMesh(model_mesh_t *model);
  47. model_mesh_t *getMesh(int index);
  48. /*!
  49. * \brief Move entity in given direction unless collision occurs
  50. * \param e entity to move
  51. * \param movement direction of movement ('f', 'b', 'l' or 'r')
  52. */
  53. void moveEntity(entity_t *e, char movement);
  54. /*!
  55. * \brief Find room a location is in.
  56. *
  57. * If it fails to be in a room it gives closest overlapping room.
  58. * \param index Guessed room index
  59. * \param x X coordinate
  60. * \param y Y coordinate
  61. * \param z Z coordinate
  62. * \returns correct room index or -1 for unknown
  63. */
  64. int getRoomByLocation(int index, float x, float y, float z);
  65. /*!
  66. * \brief Find room a location is in.
  67. *
  68. * If it fails to be in a room it gives closest overlapping room.
  69. * \param x X coordinate
  70. * \param y Y coordinate
  71. * \param z Z coordinate
  72. * \returns correct room index or -1 for unknown
  73. */
  74. int getRoomByLocation(float x, float y, float z);
  75. /*!
  76. * \brief Looks for portal crossings from xyz to xyz2 segment
  77. * from room[index]
  78. * \param index valid room index
  79. * \param x X coordinate of first point
  80. * \param y Y coordinate of first point
  81. * \param z Z coordinate of first point
  82. * \param x2 X coordinate of second point
  83. * \param y2 Y coordinate of second point
  84. * \param z2 Z coordinate of second point
  85. * \returns index of adjoined room or -1
  86. */
  87. int getAdjoiningRoom(int index,
  88. float x, float y, float z,
  89. float x2, float y2, float z2);
  90. /*!
  91. * \brief Gets the sector index of the position in room
  92. * \param room valid room index
  93. * \param x X coordinate in room
  94. * \param z Z coordinate in room
  95. * \returns sector index of position in room
  96. */
  97. int getSector(int room, float x, float z);
  98. int getSector(int room, float x, float z, float *floor, float *ceiling);
  99. unsigned int getRoomInfo(int room);
  100. /*!
  101. * \brief Check if sector is a wall
  102. * \param room valid room index
  103. * \param sector valid sector index
  104. * \returns true if this sector is a wall
  105. */
  106. bool isWall(int room, int sector);
  107. /*!
  108. * \brief Get the world height at a position
  109. * \param index valid room index
  110. * \param x X coordinate
  111. * \param y will be set to world height in that room
  112. * \param z Z coordinate
  113. */
  114. void getHeightAtPosition(int index, float x, float *y, float z);
  115. private:
  116. // Old World
  117. std::vector<model_mesh_t *> mMeshes; //!< Unanimated meshes
  118. // New World
  119. std::vector<Room *> mRooms;
  120. std::vector<SpriteSequence *> mSprites;
  121. std::vector<Entity *> mEntities;
  122. std::vector<SkeletalModel *> mModels;
  123. };
  124. #endif