| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // serial.cxx
- // danmaku
- //
- // Created by Sam Jaffe on 5/27/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #include "danmaku/serial.hpp"
- #include <json/json.h>
- #include "danmaku/actor.hpp"
- #include "danmaku/bullet_pattern.hpp"
- #include "danmaku/enemy.hpp"
- #include "danmaku/player.hpp"
- #include "resource_factory/prototype_factory.hpp"
- namespace danmaku {
- std::unique_ptr<actor> to_actor(Json::Value const & json,
- graphics::manager const & mgr) {
- auto & bp_factory = bullet_pattern_factory::instance();
- auto get_attack = [&](Json::Value const & j, actor * a) {
- return bp_factory.get(j["id"].asString(), std::move(a), j, mgr);
- };
- return actor_factory::instance().get(json["type"].asString(), json,
- engine::to_object(json, mgr),
- get_attack);
- }
- std::unique_ptr<player> to_player(Json::Value const & json,
- graphics::manager const & mgr) {
- auto & bp_factory = bullet_pattern_factory::instance();
- auto get_attack = [&](Json::Value const & j, actor * a) {
- return bp_factory.get(j["id"].asString(), std::move(a), j, mgr);
- };
- return std::make_unique<player>(json, engine::to_object(json, mgr),
- get_attack);
- }
- points_map to_points_map(Json::Value const & json) {
- return {json["damage"].asInt(), json["kill"].asInt()};
- }
- }
|