IContext is an abstract base class that provides an interface for managing game state and interactions between different systems. It serves as a central point for operations related to entities, such as creation, destruction, and manipulation.class IContext {
public:
IContext() = default;
IContext(std::shared_ptr<INetwork> network) : _network(network) {}
virtual ~IContext() = default;
virtual void destroyObject(int id) = 0;
virtual void createEnemy(int id) = 0;
virtual void animationObject(int id, const ecs::component::Animations &rect) = 0;
virtual void moveObject(int id, int x, int y) = 0;
virtual void createProjectile(int id, const rtype::protocol::ObjectTypes &type) = 0;
virtual void createMilespates(int id) = 0;
virtual void createBoss(int id) = 0;
virtual void createBossProjectile(int id, const rtype::protocol::ObjectTypes &type) = 0;
std::shared_ptr<INetwork> _network = nullptr;
protected:
};
IContext():
Default constructor.
IContext(std::shared_ptr<INetwork> network):
Constructor that initializes the context with a network interface.
virtual ~IContext() = default;:(Virtual destructor to allow for proper cleanup of derived classes.)
destroyObject(int id):
Pure virtual function for destroying an object identified by its ID.
createEnemy(int id):
Pure virtual function for creating an enemy entity with the specified ID.
animationObject(int id, const ecs::component::Animations &rect):
Pure virtual function for applying animations to an object based on its ID.
moveObject(int id, int x, int y):
Pure virtual function for moving an object to a new position specified by coordinates.
createProjectile(int id, const rtype::protocol::ObjectTypes &type):
Pure virtual function for creating a projectile of a specified type for the given ID.
createMilespates(int id):
Pure virtual function for creating milestones associated with the specified ID.
createBoss(int id):
Pure virtual function for creating a boss entity with the specified ID.
createBossProjectile(int id, const rtype::protocol::ObjectTypes &type):
Pure virtual function for creating a projectile specific to a boss entity.
std::shared_ptr<INetwork> _network:A shared pointer to a network interface, allowing for networked game functionality.