9
3

Widget.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator 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. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __EQ2_WIDGET__
  17. #define __EQ2_WIDGET__
  18. #include "Spawn.h"
  19. #include "client.h"
  20. #include <string.h>
  21. #include <mutex>
  22. using namespace std;
  23. #define WIDGET_TYPE_GENERIC 0
  24. #define WIDGET_TYPE_DOOR 1
  25. #define WIDGET_TYPE_LIFT 2
  26. class Widget : public Spawn{
  27. public:
  28. Widget();
  29. virtual ~Widget();
  30. bool IsWidget(){ return true; }
  31. int32 GetWidgetID();
  32. void SetWidgetID(int32 val);
  33. void SetWidgetX(float val);
  34. float GetWidgetX();
  35. void SetWidgetY(float val);
  36. float GetWidgetY();
  37. void SetWidgetZ(float val);
  38. float GetWidgetZ();
  39. void SetIncludeLocation(bool val);
  40. bool GetIncludeLocation();
  41. void SetIncludeHeading(bool val);
  42. bool GetIncludeHeading();
  43. void SetWidgetIcon(int8 val);
  44. Widget* Copy();
  45. EQ2Packet* serialize(Player* player, int16 version);
  46. void HandleTimerUpdate();
  47. void OpenDoor();
  48. void CloseDoor();
  49. void HandleUse(Client* client, string command, int8 overrideWidgetType=0xFF);
  50. float GetOpenHeading();
  51. void SetOpenHeading(float val);
  52. float GetClosedHeading();
  53. void SetClosedHeading(float val);
  54. float GetOpenY();
  55. void SetOpenY(float val);
  56. float GetCloseY();
  57. void SetCloseY(float val);
  58. float GetOpenX(){return open_x;}
  59. float GetOpenZ(){return open_z;}
  60. float GetCloseX(){return close_x;}
  61. float GetCloseZ(){return close_z;}
  62. void SetOpenX(float x){open_x = x;}
  63. void SetOpenZ(float z){open_z = z;}
  64. void SetCloseX(float x){close_x = x;}
  65. void SetCloseZ(float z){close_z = z;}
  66. int8 GetWidgetType();
  67. void SetWidgetType(int8 val);
  68. bool IsOpen();
  69. int32 GetActionSpawnID();
  70. void SetActionSpawnID(int32 id);
  71. int32 GetLinkedSpawnID();
  72. void SetLinkedSpawnID(int32 id);
  73. const char* GetOpenSound();
  74. void SetOpenSound(const char* name);
  75. const char* GetCloseSound();
  76. void SetCloseSound(const char* name);
  77. void SetOpenDuration(int16 val);
  78. int16 GetOpenDuration();
  79. void ProcessUse(Spawn* caller=nullptr);
  80. void SetHouseID(int32 val) { m_houseID = val; }
  81. int32 GetHouseID() { return m_houseID; }
  82. void SetMultiFloorLift(bool val) { multi_floor_lift = val; }
  83. bool GetMultiFloorLift() { return multi_floor_lift; }
  84. static string GetWidgetTypeNameByTypeID(int8 type)
  85. {
  86. switch (type)
  87. {
  88. case WIDGET_TYPE_DOOR:
  89. return string("Door");
  90. break;
  91. case WIDGET_TYPE_LIFT:
  92. return string("Lift");
  93. break;
  94. }
  95. return string("Generic");
  96. }
  97. private:
  98. int8 widget_type;
  99. bool include_location;
  100. bool include_heading;
  101. float widget_x;
  102. float widget_y;
  103. float widget_z;
  104. int32 widget_id;
  105. float open_heading;
  106. float closed_heading;
  107. float open_y;
  108. float close_y;
  109. Widget* action_spawn;
  110. int32 action_spawn_id;
  111. Widget* linked_spawn;
  112. int32 linked_spawn_id;
  113. bool is_open;
  114. string open_sound;
  115. string close_sound;
  116. int16 open_duration;
  117. int32 m_houseID;
  118. float open_x;
  119. float open_z;
  120. float close_x;
  121. float close_z;
  122. bool multi_floor_lift;
  123. std::mutex MWidgetMutex;
  124. };
  125. #endif