Skip to content
Snippets Groups Projects
Commit fd586ba8 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

and entity types to entities and add mutators for entity types

parent a6fa70c1
No related branches found
No related tags found
No related merge requests found
Pipeline #2606 failed
...@@ -19,6 +19,10 @@ int32_t entity::get_property(const string& name, int32_t val) const { ...@@ -19,6 +19,10 @@ int32_t entity::get_property(const string& name, int32_t val) const {
} }
} }
void state::add_entity(entity entity){
entities.push_back(entity);
}
state::state() { state::state() {
this->turn = 0; this->turn = 0;
} }
......
...@@ -26,15 +26,30 @@ struct data { ...@@ -26,15 +26,30 @@ struct data {
int resource; int resource;
}; };
class entity_type {
private:
entity_type* parent;
property_map properties;
};
class entity { class entity {
public: public:
entity(): tag(0), pos(Hex(0,0,0)) {} entity(entity_type* type): tag(0), pos(Hex(0,0,0)) {
entity(entity const& rhs): tag(rhs.tag), pos(Hex(0,0,0)) {} this->type = type;
}
entity(entity const& rhs): tag(rhs.tag), pos(Hex(0,0,0)) {
type = rhs.type;
}
int32_t get_property(string const& name) const; int32_t get_property(string const& name) const;
int32_t get_property(string const& name, int32_t val) const; int32_t get_property(string const& name, int32_t val) const;
void set_property(string const& name, int32_t val);
private: private:
entity_type* type;
uint64_t tag; uint64_t tag;
location pos; location pos;
property_map properties; property_map properties;
...@@ -47,8 +62,11 @@ class state { ...@@ -47,8 +62,11 @@ class state {
entity entity_at(location location); entity entity_at(location location);
vector<entity> entities_at(location location); vector<entity> entities_at(location location);
void add_entity(entity entity);
uint32_t terrain_at(location location); uint32_t terrain_at(location location);
void set_terrain(location location, uint32_t t);
uint32_t resource_at(location location); uint32_t resource_at(location location);
private: private:
......
...@@ -15,10 +15,14 @@ void test(const entity& test){ ...@@ -15,10 +15,14 @@ void test(const entity& test){
} }
int main(int argc, char **argv){ int main(int argc, char **argv){
cout << "test" << endl;
entity t; entity_type type;
test(t); state state;
for (int i=0; i<10; i++){
entity e(&type);
state.add_entity(e);
}
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment