A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Entity.h 737B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <memory>
  3. #include <optional>
  4. #include "common.h"
  5. #include "SRF.h"
  6. #include "BoundingBox.h"
  7. namespace Swan {
  8. class World;
  9. class WorldPlane;
  10. class Game;
  11. class Entity {
  12. public:
  13. class Factory {
  14. public:
  15. virtual ~Factory() = default;
  16. virtual Entity *create(const Context &ctx, const SRF &params) = 0;
  17. std::string name_;
  18. };
  19. virtual ~Entity() = default;
  20. virtual std::optional<BoundingBox> getBounds() { return std::nullopt; }
  21. virtual void draw(const Context &ctx, Win &win) {}
  22. virtual void update(const Context &ctx, float dt) {}
  23. virtual void tick() {}
  24. virtual void readSRF(const Swan::Context &ctx, const SRF &srf) {}
  25. virtual SRF *writeSRF(const Swan::Context &ctx) { return new SRFNone(); }
  26. };
  27. }