Removed useless constants for yaml fields/filenames.
This commit is contained in:
parent
9cc928e894
commit
d06efe5257
11 changed files with 13 additions and 51 deletions
|
@ -28,13 +28,13 @@ Character::Character(const sf::Vector2f& position, Category category,
|
||||||
Circle(position, category, mask, config),
|
Circle(position, category, mask, config),
|
||||||
mWorld(world),
|
mWorld(world),
|
||||||
mPathfinder(pathfinder),
|
mPathfinder(pathfinder),
|
||||||
mMaxHealth(config.get(YAML_KEY::HEALTH, YAML_DEFAULT::HEALTH)),
|
mMaxHealth(config.get("health", 100)),
|
||||||
mCurrentHealth(mMaxHealth),
|
mCurrentHealth(mMaxHealth),
|
||||||
mMovementSpeed(config.get(YAML_KEY::SPEED, YAML_DEFAULT::SPEED)),
|
mMovementSpeed(config.get("speed", 0.0f)),
|
||||||
mWeapon(new Weapon(world, *this,
|
mWeapon(new Weapon(world, *this,
|
||||||
Yaml(config.get(YAML_KEY::WEAPON, YAML_DEFAULT::WEAPON)))),
|
Yaml(config.get("weapon", std::string())))),
|
||||||
mLastPosition(getPosition()),
|
mLastPosition(getPosition()),
|
||||||
mFaction((Faction) config.get(YAML_KEY::FACTION, YAML_DEFAULT::FACTION)) {
|
mFaction((Faction) config.get("faction", 1)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Character::~Character() {
|
Character::~Character() {
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
Circle::Circle(const sf::Vector2f& position, Category category,
|
Circle::Circle(const sf::Vector2f& position, Category category,
|
||||||
unsigned short mask, const Yaml& config,
|
unsigned short mask, const Yaml& config,
|
||||||
const sf::Vector2f& direction) :
|
const sf::Vector2f& direction) :
|
||||||
Sprite(position, category, mask, config.get(YAML_KEY::SIZE, sf::Vector2f()),
|
Sprite(position, category, mask, config.get("size", sf::Vector2f()),
|
||||||
config.get(YAML_KEY::TEXTURE, std::string()), direction) {
|
config.get("texture", std::string()), direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
Rectangle::Rectangle(const sf::Vector2f& position, Category category,
|
Rectangle::Rectangle(const sf::Vector2f& position, Category category,
|
||||||
unsigned short mask, const Yaml& config,
|
unsigned short mask, const Yaml& config,
|
||||||
const sf::Vector2f& direction) :
|
const sf::Vector2f& direction) :
|
||||||
Sprite(position, category, mask, config.get(YAML_KEY::SIZE, sf::Vector2f()),
|
Sprite(position, category, mask, config.get("size", sf::Vector2f()),
|
||||||
config.get(YAML_KEY::TEXTURE, std::string()), direction) {
|
config.get("texture", std::string()), direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,8 +25,8 @@ Bullet::Bullet(const sf::Vector2f& position, Character& shooter,
|
||||||
Particle(position, CATEGORY_PARTICLE, ~CATEGORY_PARTICLE,
|
Particle(position, CATEGORY_PARTICLE, ~CATEGORY_PARTICLE,
|
||||||
config, thor::rotatedVector(direction, -90.0f)),
|
config, thor::rotatedVector(direction, -90.0f)),
|
||||||
mShooter(shooter),
|
mShooter(shooter),
|
||||||
mDamage(config.get(YAML_KEY::DAMAGE, YAML_DEFAULT::DAMAGE)),
|
mDamage(config.get("damage", 0)),
|
||||||
mSpeed(config.get(YAML_KEY::SPEED, YAML_DEFAULT::SPEED)) {
|
mSpeed(config.get("speed", 0.0f)) {
|
||||||
setSpeed(thor::rotatedVector(direction, -90.0f), mSpeed);
|
setSpeed(thor::rotatedVector(direction, -90.0f), mSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
|
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
const std::string Corpse::CONFIG = "corpse.yaml";
|
|
||||||
|
|
||||||
Corpse::Corpse(const sf::Vector2f& position) :
|
Corpse::Corpse(const sf::Vector2f& position) :
|
||||||
Circle(position, CATEGORY_NONSOLID, MASK_NONE, Yaml(CONFIG)) {
|
Circle(position, CATEGORY_NONSOLID, MASK_NONE, Yaml("corpse.yaml")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
class Corpse : public Circle {
|
class Corpse : public Circle {
|
||||||
public:
|
public:
|
||||||
explicit Corpse(const sf::Vector2f& position);
|
explicit Corpse(const sf::Vector2f& position);
|
||||||
|
|
||||||
private:
|
|
||||||
static const std::string CONFIG;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DG_CORPSE_H_ */
|
#endif /* DG_CORPSE_H_ */
|
||||||
|
|
|
@ -11,11 +11,9 @@
|
||||||
|
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
const std::string Enemy::CONFIG = "enemy.yaml";
|
|
||||||
|
|
||||||
Enemy::Enemy(World& world, Pathfinder& pathfinder,
|
Enemy::Enemy(World& world, Pathfinder& pathfinder,
|
||||||
const sf::Vector2f& position) :
|
const sf::Vector2f& position) :
|
||||||
Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml(CONFIG), world,
|
Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml("enemy.yaml"), world,
|
||||||
pathfinder) {
|
pathfinder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void onThink(int elapsed);
|
virtual void onThink(int elapsed);
|
||||||
|
|
||||||
private:
|
|
||||||
static const std::string CONFIG;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DG_ENEMY_H_ */
|
#endif /* DG_ENEMY_H_ */
|
||||||
|
|
|
@ -11,14 +11,12 @@
|
||||||
|
|
||||||
#include "../util/Yaml.h"
|
#include "../util/Yaml.h"
|
||||||
|
|
||||||
const std::string Player::CONFIG = "player.yaml";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes Sprite.
|
* Initializes Sprite.
|
||||||
*/
|
*/
|
||||||
Player::Player(World& world, Pathfinder& pathfinder,
|
Player::Player(World& world, Pathfinder& pathfinder,
|
||||||
const sf::Vector2f& position) :
|
const sf::Vector2f& position) :
|
||||||
Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml(CONFIG), world,
|
Character(position, CATEGORY_ACTOR, MASK_ALL, Yaml("player.yaml"), world,
|
||||||
pathfinder),
|
pathfinder),
|
||||||
mDirection(0) {
|
mDirection(0) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,6 @@ private:
|
||||||
void onThink(int elapsed);
|
void onThink(int elapsed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const std::string CONFIG;
|
|
||||||
|
|
||||||
sf::Vector2f mCrosshairPosition; //< Relative position of the point to fire at (mouse cursor).
|
sf::Vector2f mCrosshairPosition; //< Relative position of the point to fire at (mouse cursor).
|
||||||
unsigned char mDirection; //< Current movement direction for direct control.
|
unsigned char mDirection; //< Current movement direction for direct control.
|
||||||
};
|
};
|
||||||
|
|
|
@ -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_ */
|
#endif /* DG_YAML_H_ */
|
||||||
|
|
Reference in a new issue