Removed useless constants for yaml fields/filenames.

This commit is contained in:
Felix Ableitner 2013-06-25 17:50:23 +02:00
parent 9cc928e894
commit d06efe5257
11 changed files with 13 additions and 51 deletions

View file

@ -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() {

View file

@ -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) {
}
/**

View file

@ -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) {
}
/**

View file

@ -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);
}

View file

@ -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")) {
}

View file

@ -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_ */

View file

@ -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) {
}

View file

@ -19,9 +19,6 @@ public:
private:
virtual void onThink(int elapsed);
private:
static const std::string CONFIG;
};
#endif /* DG_ENEMY_H_ */

View file

@ -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) {
}

View file

@ -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.
};

View file

@ -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_ */