serial.cxx 999 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // serial.cxx
  3. // danmaku
  4. //
  5. // Created by Sam Jaffe on 5/27/19.
  6. // Copyright © 2019 Sam Jaffe. All rights reserved.
  7. //
  8. #include "danmaku/serial.hpp"
  9. #include <json/json.h>
  10. #include "danmaku/actor.hpp"
  11. #include "danmaku/bullet_pattern.hpp"
  12. #include "danmaku/enemy.hpp"
  13. #include "resource_factory/prototype_factory.hpp"
  14. namespace danmaku {
  15. std::unique_ptr<actor> to_actor(Json::Value const & json,
  16. graphics::manager const & mgr) {
  17. auto & bp_factory = bullet_pattern_factory::instance();
  18. auto get_attack = [&](Json::Value const & j, actor * a) {
  19. return bp_factory.get(j["id"].asString(), std::move(a), j, mgr);
  20. };
  21. return actor_factory::instance().get(json["type"].asString(), json,
  22. engine::to_object(json, mgr),
  23. get_attack);
  24. }
  25. points_map to_points_map(Json::Value const & json) {
  26. return {json["damage"].asInt(), json["kill"].asInt()};
  27. }
  28. }