|
|
|
#pragma once
|
|
|
|
#include "dinkyecs.hpp"
|
|
|
|
#include "components.hpp"
|
|
|
|
#include "constants.hpp"
|
|
|
|
#include "config.hpp"
|
|
|
|
#include "dinky_components.hpp"
|
|
|
|
#include "point.hpp"
|
|
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
#include <SFML/Graphics/Rect.hpp>
|
|
|
|
|
|
|
|
namespace components {
|
|
|
|
struct Player {
|
|
|
|
DinkyECS::Entity entity;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Position {
|
|
|
|
Point location;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Motion {
|
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
bool random=false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Loot {
|
|
|
|
int amount;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Tile {
|
|
|
|
std::string display;
|
|
|
|
std::array<uint8_t, 3> foreground;
|
|
|
|
std::array<uint8_t, 3> background;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GameConfig {
|
|
|
|
Config game;
|
|
|
|
Config enemies;
|
|
|
|
Config items;
|
|
|
|
Config tiles;
|
|
|
|
Config devices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EnemyConfig {
|
|
|
|
int hearing_distance = 10;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Debug {
|
|
|
|
bool PATHS=false;
|
|
|
|
bool LIGHT=false;
|
|
|
|
bool FPS=false;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Weapon {
|
|
|
|
int damage = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Curative {
|
|
|
|
int hp = 10;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Combat {
|
|
|
|
int hp;
|
|
|
|
int max_hp;
|
|
|
|
int damage;
|
|
|
|
|
|
|
|
/* NOTE: This is used to _mark_ entities as dead, to detect ones that have just died. Don't make attack automatically set it.*/
|
|
|
|
bool dead = false;
|
|
|
|
|
|
|
|
int attack(Combat &target);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LightSource {
|
|
|
|
int strength = 0;
|
|
|
|
float radius = 1.0f;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Device {
|
|
|
|
json config;
|
|
|
|
std::vector<std::string> events;
|
|
|
|
|
|
|
|
void configure_events(std::vector<std::string> &event_names);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sprite {
|
|
|
|
string name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sound {
|
|
|
|
std::string attack;
|
|
|
|
std::string death;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Animation {
|
|
|
|
float scale = 0.0f;
|
|
|
|
bool simple = true;
|
|
|
|
int frames = 10;
|
|
|
|
float speed = 0.3f;
|
|
|
|
int current = 0;
|
|
|
|
bool playing = false;
|
|
|
|
float subframe = 0;
|
|
|
|
|
|
|
|
void play();
|
|
|
|
void step(sf::Vector2f& scale_out, sf::IntRect& rect_out);
|
|
|
|
};
|
|
|
|
|
|
|
|
void configure(ComponentMap& component_map);
|
|
|
|
|
|
|
|
// these need to be here if you're using components::convert outside of components.cpp
|
|
|
|
ENROLL_COMPONENT(Tile, display, foreground, background);
|
|
|
|
ENROLL_COMPONENT(Sprite, name);
|
|
|
|
ENROLL_COMPONENT(Curative, hp);
|
|
|
|
ENROLL_COMPONENT(LightSource, strength, radius);
|
|
|
|
ENROLL_COMPONENT(Weapon, damage);
|
|
|
|
ENROLL_COMPONENT(Loot, amount);
|
|
|
|
}
|