EntityTrigger.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreRoot.h>
  17. class Entity;
  18. /**
  19. * An entity trigger.
  20. */
  21. class EntityTrigger{
  22. public:
  23. /**
  24. * Constructor.
  25. *
  26. * @param name[in] The trigger name.
  27. */
  28. EntityTrigger(const Ogre::String& name);
  29. /**
  30. * Destructor.
  31. */
  32. virtual ~EntityTrigger();
  33. /**
  34. * Updates the trigger state with debug information.
  35. */
  36. void UpdateDebug();
  37. /**
  38. * Retrieves the trigger name.
  39. *
  40. * @return The trigger name.
  41. */
  42. const Ogre::String& GetName() const;
  43. /**
  44. * Enables or disables the trigger.
  45. *
  46. * When disabled, all the activators are removed.
  47. *
  48. * @param enabled[in] True to enable the trigger, false to disable it.
  49. */
  50. void SetEnabled(const bool enabled);
  51. /**
  52. * Checks if the trigger is enabled.
  53. *
  54. * @return True if it's enabled, false otherwise.
  55. */
  56. bool IsEnabled() const;
  57. /**
  58. * Adds an activator to the trigger.
  59. *
  60. * @param activator[in] Trigger activator entity.
  61. */
  62. void AddActivator(Entity* activator);
  63. /**
  64. * Removes an activator from the trigger.
  65. *
  66. * @param activator[in] Entity to remove as activator.
  67. */
  68. void RemoveActivator(Entity* activator);
  69. /**
  70. * Checks if an entity is an activator of the trigger.
  71. *
  72. * @param activator[in] Entity to test as an activator.
  73. * @return True if the entity is an activator, false otherwise.
  74. */
  75. bool IsActivator(Entity* activator);
  76. /**
  77. * Sets the vertices of the line that acts as the trigger.
  78. *
  79. * @param point1[in] One of the vertices of the line.
  80. * @param point2[in] One of the vertices of the line.
  81. */
  82. void SetPoints(
  83. const Ogre::Vector3& point1, const Ogre::Vector3& point2
  84. );
  85. /**
  86. * Retrieves the first vertex of the line that acts as trigger.
  87. *
  88. * @return The first vertex.
  89. */
  90. const Ogre::Vector3& GetPoint1() const;
  91. /**
  92. * Retrieves the second vertex of the line that acts as trigger.
  93. *
  94. * @return The second vertex.
  95. */
  96. const Ogre::Vector3& GetPoint2() const;
  97. protected:
  98. /**
  99. * The name of the trigger.
  100. */
  101. Ogre::String name_;
  102. /**
  103. * Indicates if the trigger is enabled or disabled.
  104. */
  105. bool enabled_;
  106. /**
  107. * List of activators of the trigger.
  108. */
  109. std::vector<Entity*> activators_;
  110. /**
  111. * One of the vertices of the trigger line.
  112. */
  113. Ogre::Vector3 point_1_;
  114. /**
  115. * One of the vertices of the trigger line.
  116. */
  117. Ogre::Vector3 point_2_;
  118. };