From 210d3b213c70250c8ad5bd831ae18bb85112a5e0 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Fri, 30 Aug 2019 00:13:51 -0400 Subject: Created name component --- src/components/Name.hpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/components/Name.hpp (limited to 'src/components') diff --git a/src/components/Name.hpp b/src/components/Name.hpp new file mode 100644 index 0000000..c472cbb --- /dev/null +++ b/src/components/Name.hpp @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2019 Belle-Isle, Andrew + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef NAME_HPP_ +#define NAME_HPP_ + +#include "components/Component.hpp" +#include + +struct Name : Component, entityx::Component +{ + public: + std::string name; + Name(std::string _name) : name(_name) {} + Name(void): name() {}; + + Name FromLua(sol::object ref) + { + if (ref.get_type() == sol::type::string) { + this->name = ref.as(); + } else { + throw std::string("Name component not formatted properly"); + } + return *this; + } + +}; + +#endif//NAME_HPP_ -- cgit v1.2.3