/* base/patrol.h This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #ifndef __INCLUDED_BASE_PATROL_H__ #define __INCLUDED_BASE_PATROL_H__ #include "core/entity.h" #include "base/faction.h" #include "base/npc.h" #include "base/npctype.h" #include "base/waypoint.h" namespace game { /** * @brief a patrol entity manages a group of NPCs. * A Patrol instance is a server-side entity used to manage * a group of NPC ships. It manages group purpose, group commands * and respawning by giving orders to the member NPCs. * A Patrol can manage any kind of NPC group: * be it a patrol, a trade convoy or a player wing. * */ class Patrol: public core::Entity { public: /** * @brief Definse the general profile of the patrol * The NPC profile is set at creating time and can not be altered. * * Freelancer fallback value * Convoy Trade convoy member, prefers trade routes * Patrol Police or military, prefers patrol routes * Guard Guard an area * Wingman wingman, prefers protecting its leader * */ enum Profile { ProfileFreelancer = 0, ProfileConvoy = 1, ProfilePatrol = 2, ProfileGuard = 3, ProfileWingman = 4 }; typedef std::list WayPoints; typedef std::list NPCTypes; typedef std::list Members; Patrol(); virtual ~Patrol(); inline const Profile profile() const { return patrol_profile; } inline WayPoint * waypoint() const { if (patrol_waypoint_current == patrol_waypoints.end()) { return 0; } else { return (*patrol_waypoint_current); } } inline NPC *leader() const { return patrol_leader; } inline Faction *faction() const { return patrol_faction; } void set_profile(const Profile profile); void set_faction(Faction *faction); WayPoint *add_waypoint(); NPCType *add_npctype(); virtual void validate(); virtual void frame(const unsigned long elapsed); virtual void print() const; void add_member(NPC *npc); void erase_member(NPC *npc); private: void set_leader(); void create_patrol(); bool route_alive() const; WayPoints patrol_waypoints; WayPoints::iterator patrol_waypoint_current; Members patrol_members; NPCTypes patrol_npctypes; Profile patrol_profile; NPC *patrol_leader; unsigned long patrol_launch_timeout; Faction *patrol_faction; }; } // namespace game #endif // __INCLUDED_BASE_PATROL_H__