diff --git a/source/abstract/Character.cpp b/source/abstract/Character.cpp index c279a4c..05b208a 100644 --- a/source/abstract/Character.cpp +++ b/source/abstract/Character.cpp @@ -28,13 +28,13 @@ Character::Character(const sf::Vector2f& position, Category category, Circle(position, category, mask, config), mWorld(world), mPathfinder(pathfinder), - mMaxHealth(config.get(YAML_KEY::HEALTH, YAML_DEFAULT::HEALTH)), + mMaxHealth(config.get("health", 100)), mCurrentHealth(mMaxHealth), - mMovementSpeed(config.get(YAML_KEY::SPEED, YAML_DEFAULT::SPEED)), + mMovementSpeed(config.get("speed", 0.0f)), mWeapon(new Weapon(world, *this, - Yaml(config.get(YAML_KEY::WEAPON, YAML_DEFAULT::WEAPON)))), + Yaml(config.get("weapon", std::string())))), mLastPosition(getPosition()), - mFaction((Faction) config.get(YAML_KEY::FACTION, YAML_DEFAULT::FACTION)) { + mFaction((Faction) config.get("faction", 1)) { } Character::~Character() { diff --git a/source/abstract/Circle.cpp b/source/abstract/Circle.cpp index 30e6cb8..b50c1a8 100644 --- a/source/abstract/Circle.cpp +++ b/source/abstract/Circle.cpp @@ -13,8 +13,8 @@ Circle::Circle(const sf::Vector2f& position, Category category, unsigned short mask, const Yaml& config, const sf::Vector2f& direction) : - Sprite(position, category, mask, config.get(YAML_KEY::SIZE, sf::Vector2f()), - config.get(YAML_KEY::TEXTURE, std::string()), direction) { + Sprite(position, category, mask, config.get("size", sf::Vector2f()), + config.get("texture", std::string()), direction) { } /** diff --git a/source/abstract/Rectangle.cpp b/source/abstract/Rectangle.cpp index 1179faf..f47cc40 100644 --- a/source/abstract/Rectangle.cpp +++ b/source/abstract/Rectangle.cpp @@ -13,8 +13,8 @@ Rectangle::Rectangle(const sf::Vector2f& position, Category category, unsigned short mask, const Yaml& config, const sf::Vector2f& direction) : - Sprite(position, category, mask, config.get(YAML_KEY::SIZE, sf::Vector2f()), - config.get(YAML_KEY::TEXTURE, std::string()), direction) { + Sprite(position, category, mask, config.get("size", sf::Vector2f()), + config.get("texture", std::string()), direction) { } /** diff --git a/source/effects/Bullet.cpp b/source/effects/Bullet.cpp index 6dee287..10ec1f1 100755 --- a/source/effects/Bullet.cpp +++ b/source/effects/Bullet.cpp @@ -25,8 +25,8 @@ Bullet::Bullet(const sf::Vector2f& position, Character& shooter, Particle(position, CATEGORY_PARTICLE, ~CATEGORY_PARTICLE, config, thor::rotatedVector(direction, -90.0f)), mShooter(shooter), - mDamage(config.get(YAML_KEY::DAMAGE, YAML_DEFAULT::DAMAGE)), - mSpeed(config.get(YAML_KEY::SPEED, YAML_DEFAULT::SPEED)) { + mDamage(config.get("damage", 0)), + mSpeed(config.get("speed", 0.0f)) { setSpeed(thor::rotatedVector(direction, -90.0f), mSpeed); } diff --git a/source/sprites/Corpse.cpp b/source/sprites/Corpse.cpp index 6710d1e..95e86cb 100644 --- a/source/sprites/Corpse.cpp +++ b/source/sprites/Corpse.cpp @@ -9,9 +9,7 @@ #include "../util/Yaml.h" -const std::string Corpse::CONFIG = "corpse.yaml"; - Corpse::Corpse(const sf::Vector2f& position) : - Circle(position, CATEGORY_NONSOLID, MASK_NONE, Yaml(CONFIG)) { + Circle(position, CATEGORY_NONSOLID, MASK_NONE, Yaml("corpse.yaml")) { } diff --git a/source/sprites/Corpse.h b/source/sprites/Corpse.h index a11b260..6f1980e 100644 --- a/source/sprites/Corpse.h +++ b/source/sprites/Corpse.h @@ -13,9 +13,6 @@ class Corpse : public Circle { public: explicit Corpse(const sf::Vector2f& position); - -private: - static const std::string CONFIG; }; #endif /* DG_CORPSE_H_ */ diff --git a/source/sprites/Enemy.cpp b/source/sprites/Enemy.cpp index 39e5fc8..82401ca 100644 --- a/source/sprites/Enemy.cpp +++ b/source/sprites/Enemy.cpp @@ -11,11 +11,9 @@ #include "../util/Yaml.h" -const std::string Enemy::CONFIG = "enemy.yaml"; - Enemy::Enemy(World& world, Pathfinder& pathfinder, const sf::Vector2f& position) : - Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml(CONFIG), world, + Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml("enemy.yaml"), world, pathfinder) { } diff --git a/source/sprites/Enemy.h b/source/sprites/Enemy.h index d3dd5a4..8b56c03 100644 --- a/source/sprites/Enemy.h +++ b/source/sprites/Enemy.h @@ -19,9 +19,6 @@ public: private: virtual void onThink(int elapsed); - -private: - static const std::string CONFIG; }; #endif /* DG_ENEMY_H_ */ diff --git a/source/sprites/Player.cpp b/source/sprites/Player.cpp index 6498ab2..dc5c559 100644 --- a/source/sprites/Player.cpp +++ b/source/sprites/Player.cpp @@ -11,14 +11,12 @@ #include "../util/Yaml.h" -const std::string Player::CONFIG = "player.yaml"; - /** * Initializes Sprite. */ Player::Player(World& world, Pathfinder& pathfinder, const sf::Vector2f& position) : - Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml(CONFIG), world, + Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml("player.yaml"), world, pathfinder), mDirection(0) { } diff --git a/source/sprites/Player.h b/source/sprites/Player.h index d21fe08..ffc4e35 100644 --- a/source/sprites/Player.h +++ b/source/sprites/Player.h @@ -44,8 +44,6 @@ private: void onThink(int elapsed); private: - static const std::string CONFIG; - sf::Vector2f mCrosshairPosition; //< Relative position of the point to fire at (mouse cursor). unsigned char mDirection; //< Current movement direction for direct control. }; diff --git a/source/util/Yaml.h b/source/util/Yaml.h index 972771c..2691fa8 100644 --- a/source/util/Yaml.h +++ b/source/util/Yaml.h @@ -79,28 +79,4 @@ T Yaml::get(const std::string& key, const T& defaultValue) const { } }; -namespace YAML_KEY { - // Sprite - const std::string SIZE = "size"; - const std::string RADIUS = "radius"; - const std::string TEXTURE = "texture"; - - // Character - const std::string HEALTH = "health"; - const std::string SPEED = "speed"; - const std::string WEAPON = "weapon"; - const std::string FACTION = "faction"; - - // Bullet - const std::string DAMAGE = "damage"; -} - -namespace YAML_DEFAULT { - const int HEALTH = 100; - const float SPEED = 100; - const std::string WEAPON = "weapon.yaml"; - const int DAMAGE = 10; - const int FACTION = 1; -} - #endif /* DG_YAML_H_ */