activeobject.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef ACTIVEOBJECT_HEADER
  17. #define ACTIVEOBJECT_HEADER
  18. #include "irr_aabb3d.h"
  19. #include <string>
  20. #define ACTIVEOBJECT_TYPE_INVALID 0
  21. // Other types are defined in content_object.h
  22. struct ActiveObjectMessage
  23. {
  24. ActiveObjectMessage(u16 id_, bool reliable_=true, std::string data_=""):
  25. id(id_),
  26. reliable(reliable_),
  27. datastring(data_)
  28. {}
  29. u16 id;
  30. bool reliable;
  31. std::string datastring;
  32. };
  33. /*
  34. Parent class for ServerActiveObject and ClientActiveObject
  35. */
  36. class ActiveObject
  37. {
  38. public:
  39. ActiveObject(u16 id):
  40. m_id(id)
  41. {
  42. }
  43. u16 getId()
  44. {
  45. return m_id;
  46. }
  47. void setId(u16 id)
  48. {
  49. m_id = id;
  50. }
  51. virtual u8 getType() const = 0;
  52. virtual bool getCollisionBox(aabb3f *toset) = 0;
  53. virtual bool collideWithObjects() = 0;
  54. protected:
  55. u16 m_id; // 0 is invalid, "no id"
  56. };
  57. #endif