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.

Mod.h 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <stdint.h>
  3. #include <string>
  4. #include <vector>
  5. #include <memory>
  6. #include <SFML/Graphics/Image.hpp>
  7. #include "Tile.h"
  8. #include "Item.h"
  9. #include "WorldGen.h"
  10. #include "Entity.h"
  11. #include "Asset.h"
  12. namespace Swan {
  13. class Mod {
  14. public:
  15. using ModID = uint32_t;
  16. void init(const std::string &name);
  17. void registerTile(const std::string &name, Tile *tile);
  18. void registerItem(const std::string &name, Item *item);
  19. void registerWorldGen(const std::string &name, WorldGen::Factory *gen);
  20. void registerEntity(const std::string &name, Entity::Factory *ent);
  21. void registerAsset(const std::string &name, Asset *asset);
  22. std::unique_ptr<sf::Image> loadImage(const std::string &path);
  23. std::string name_;
  24. std::string path_;
  25. std::vector<std::shared_ptr<Tile>> tiles_;
  26. std::vector<std::shared_ptr<Item>> items_;
  27. std::vector<std::shared_ptr<WorldGen::Factory>> worldgens_;
  28. std::vector<std::shared_ptr<Entity::Factory>> entities_;
  29. std::vector<std::shared_ptr<Asset>> assets_;
  30. bool inited_ = false;
  31. };
  32. }