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.cc 805B

1234567891011121314151617181920212223242526272829303132
  1. #include "Mod.h"
  2. #include <stdio.h>
  3. namespace Swan {
  4. void Mod::init(const std::string &name) {
  5. name_ = name;
  6. inited_ = true;
  7. fprintf(stderr, "Mod initing: %s\n", name_.c_str());
  8. }
  9. void Mod::registerTile(const std::string &name, Tile *tile) {
  10. tile->name_ = name_ + "::" + name;
  11. fprintf(stderr, "Adding tile: %s\n", tile->name_.c_str());
  12. std::string asset_path = path_ + "/" + tile->path_;
  13. if (!tile->image_.loadFromFile(asset_path)) {
  14. fprintf(stderr, "Tile %s: Failed to load image %s\n", tile->name_.c_str(), asset_path.c_str());
  15. tile->image_ = Tile::invalid_image;
  16. }
  17. tiles_.push_back(std::shared_ptr<Tile>(tile));
  18. }
  19. void Mod::registerWorldGen(const std::string &name, WorldGen::Factory *gen) {
  20. gen->name_ = name;
  21. worldgens_.push_back(std::shared_ptr<WorldGen::Factory>(gen));
  22. }
  23. }