[CHORE] Util classes format and simple cleanup with generated resources (#2028)

- Did some basic formatting
- Some generated docs
- Cleaned header/impl Helper.css
- Moved PerfMonitor from util to bot/handler/command

Still a freaking mess though, but its a start i guess. Cant ask ppl to
add more or make use of those when its so messy.
This commit is contained in:
bashermens
2026-01-18 00:43:44 +01:00
committed by GitHub
parent 9f54d7e702
commit 6cf7f1aaef
7 changed files with 254 additions and 51 deletions

View File

@@ -13,11 +13,24 @@ class Unit;
class WorldObject;
class WorldPacket;
/**
* @brief Provides a simplified interface to server engine operations.
*
* ServerFacade acts as a wrapper around common server functions used by
* the Playerbot system. It centralizes utility methods for distance
* calculations, facing, chase target retrieval, and packet sending.
*/
class ServerFacade
{
public:
ServerFacade(){};
virtual ~ServerFacade(){};
ServerFacade() {}
virtual ~ServerFacade() {}
/**
* @brief Get singleton instance.
*
* @return ServerFacade* Pointer to the singleton instance.
*/
static ServerFacade* instance()
{
static ServerFacade instance;
@@ -25,19 +38,92 @@ public:
}
public:
/**
* @brief Get 2D distance between a unit and a world object.
*
* The result is rounded to one decimal place.
*
* @param unit Source unit.
* @param wo Target world object.
* @return float Distance in yards.
*/
float GetDistance2d(Unit* unit, WorldObject* wo);
/**
* @brief Get 2D distance between a unit and coordinates.
*
* The result is rounded to one decimal place.
*
* @param unit Source unit.
* @param x Target X coordinate.
* @param y Target Y coordinate.
* @return float Distance in yards.
*/
float GetDistance2d(Unit* unit, float x, float y);
/**
* @brief Compare two distances.
*
* @param dist1 First distance.
* @param dist2 Second distance.
* @return true if dist1 < dist2.
*/
bool IsDistanceLessThan(float dist1, float dist2);
/**
* @brief Compare two distances.
*
* @param dist1 First distance.
* @param dist2 Second distance.
* @return true if dist1 > dist2.
*/
bool IsDistanceGreaterThan(float dist1, float dist2);
/**
* @brief Compare two distances.
*
* @param dist1 First distance.
* @param dist2 Second distance.
* @return true if dist1 >= dist2.
*/
bool IsDistanceGreaterOrEqualThan(float dist1, float dist2);
/**
* @brief Compare two distances.
*
* @param dist1 First distance.
* @param dist2 Second distance.
* @return true if dist1 <= dist2.
*/
bool IsDistanceLessOrEqualThan(float dist1, float dist2);
/**
* @brief Set bot facing towards a world object.
*
* @param bot Player bot to rotate.
* @param wo Target world object.
* @param force If true, force facing even while moving.
*/
void SetFacingTo(Player* bot, WorldObject* wo, bool force = false);
/**
* @brief Get the current chase target of a unit.
*
* @param target Unit that is chasing.
* @return Unit* The chase target, or nullptr if not chasing.
*/
Unit* GetChaseTarget(Unit* target);
void SendPacket(Player *player, WorldPacket* packet);
/**
* @brief Send a raw packet to a player.
*
* @param player Player to receive the packet.
* @param packet Packet to send.
*/
void SendPacket(Player* player, WorldPacket* packet);
};
/** Global singleton accessor. */
#define sServerFacade ServerFacade::instance()
#endif