Skip to content

Commit 3004bca

Browse files
committed
made all formatting match
1 parent e7fee98 commit 3004bca

19 files changed

+523
-503
lines changed

src/components/Component.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020

2121
#include <sol/sol.hpp>
2222

23-
template <typename T>
23+
template<typename T>
2424
class Component
2525
{
26-
public:
27-
Component(){};
28-
26+
public:
2927
virtual T FromLua(sol::object) = 0;
3028
};
3129

32-
#endif//COMPONENT_HPP_
30+
#endif // COMPONENT_HPP_
31+

src/components/Name.hpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
#ifndef NAME_HPP_
19-
#define NAME_HPP_
18+
#ifndef COMPONENT_NAME_HPP_
19+
#define COMPONENT_NAME_HPP_
2020

21-
#include "components/Component.hpp"
21+
#include "Component.hpp"
2222
#include <string>
2323

2424
struct Name : Component<Name>, entityx::Component<Name>
2525
{
26-
public:
27-
std::string name;
28-
Name(std::string _name) : name(_name) {}
29-
Name(void): name() {};
30-
31-
Name FromLua(sol::object ref)
32-
{
33-
if (ref.get_type() == sol::type::string) {
34-
this->name = ref.as<std::string>();
35-
} else {
36-
throw std::string("Name component not formatted properly");
37-
}
38-
return *this;
39-
}
26+
public:
27+
std::string name;
4028

29+
Name(std::string _name = std::string()) :
30+
name(_name) {}
31+
32+
Name FromLua(sol::object ref)
33+
{
34+
if (ref.get_type() == sol::type::string)
35+
this->name = ref.as<std::string>();
36+
else
37+
throw std::string("Name component not formatted properly");
38+
39+
return *this;
40+
}
4141
};
4242

43-
#endif//NAME_HPP_
43+
#endif // COMPONENT_NAME_HPP_
44+

src/components/Player.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
#ifndef PLAYER_HPP_
22-
#define PLAYER_HPP_
21+
#ifndef COMPONENT_PLAYER_HPP_
22+
#define COMPONENT_PLAYER_HPP_
2323

2424
#include "Component.hpp"
2525

2626
struct Player : Component<Player>, entityx::Component<Player>
2727
{
28-
Player FromLua([[maybe_unused]] sol::object ref)
29-
{
30-
return *this;
31-
}
28+
public:
29+
Player FromLua([[maybe_unused]] sol::object ref)
30+
{
31+
return *this;
32+
}
3233
};
3334

34-
#endif // PLAYER_HPP_
35+
#endif // COMPONENT_PLAYER_HPP_
36+

src/components/Position.hpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,33 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef POSITION_HPP_
20-
#define POSITION_HPP_
19+
#ifndef COMPONENT_POSITION_HPP_
20+
#define COMPONENT_POSITION_HPP_
2121

22-
#include "components/Component.hpp"
22+
#include "Component.hpp"
2323

2424
struct Position : Component<Position>, entityx::Component<Position>
2525
{
26-
public:
27-
double x, y;
28-
Position(double _x, double _y): x(_x), y(_y) {}
29-
Position(void): x(0), y(0) {}
30-
31-
Position FromLua(sol::object ref)
32-
{
33-
if (ref.get_type() == sol::type::table) {
34-
sol::table tab = ref;
35-
if (tab["x"] != nullptr)
36-
this->x = tab["x"];
37-
if (tab["y"] != nullptr)
38-
this->y = tab["y"];
39-
} else {
40-
throw std::string("Position table not formatted properly");
41-
}
42-
return *this;
26+
public:
27+
double x, y;
28+
29+
Position(double _x = 0, double _y = 0) :
30+
x(_x), y(_y) {}
31+
32+
Position FromLua(sol::object ref)
33+
{
34+
if (ref.get_type() == sol::type::table) {
35+
sol::table tab = ref;
36+
if (tab["x"] != nullptr)
37+
this->x = tab["x"];
38+
if (tab["y"] != nullptr)
39+
this->y = tab["y"];
40+
} else {
41+
throw std::string("Position table not formatted properly");
4342
}
43+
return *this;
44+
}
4445
};
4546

46-
#endif//POSITION_HPP_
47+
#endif // COMPONENT_POSITION_HPP_
48+

src/components/Render.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,38 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
#ifndef RENDERC_HPP_
19-
#define RENDERC_HPP_
18+
#ifndef COMPONENT_RENDER_HPP_
19+
#define COMPONENT_RENDER_HPP_
2020

21-
#include <components/Component.hpp>
21+
#include "Component.hpp"
2222

2323
struct Render : Component<Render>, entityx::Component<Render>
2424
{
25-
public:
26-
std::string texture;
27-
bool visible;
25+
public:
26+
std::string texture;
27+
bool visible;
2828

29-
Render(std::string _file): texture(_file), visible(true) {}
30-
Render(): texture(), visible(false) {}
29+
Render(std::string _file) :
30+
texture(_file), visible(true) {}
31+
Render(void) :
32+
texture(), visible(false) {}
3133

32-
Render FromLua(sol::object ref)
33-
{
34-
if (ref.get_type() == sol::type::table) {
35-
sol::table tab = ref;
36-
if (tab["visible"].get_type() == sol::type::boolean) {
37-
this->visible = tab["visible"];
38-
}
39-
if (tab["texture"].get_type() == sol::type::string) {
40-
this->texture = tab["texture"];
41-
}
42-
} else {
43-
throw std::string(
44-
"Render component table formatted incorrectly"
45-
);
46-
}
47-
return *this;
34+
Render FromLua(sol::object ref)
35+
{
36+
if (ref.get_type() == sol::type::table) {
37+
sol::table tab = ref;
38+
if (tab["visible"].get_type() == sol::type::boolean)
39+
this->visible = tab["visible"];
40+
if (tab["texture"].get_type() == sol::type::string)
41+
this->texture = tab["texture"];
42+
} else {
43+
throw std::string(
44+
"Render component table formatted incorrectly"
45+
);
4846
}
49-
47+
return *this;
48+
}
5049
};
5150

52-
#endif//RENDERC_HPP_
51+
#endif // COMPONENT_RENDER_HPP_
52+

src/components/Script.hpp

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,38 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#ifndef SCRIPT_COMPONENT_HPP_
20-
#define SCRIPT_COMPONENT_HPP_
19+
#ifndef COMPONENT_SCRIPT_HPP_
20+
#define COMPONENT_SCRIPT_HPP_
2121

22-
#include <components/Component.hpp>
22+
#include "Component.hpp"
2323

2424
struct Scripted : Component<Scripted>, entityx::Component<Scripted>
2525
{
26-
public:
27-
sol::table caller;
28-
Scripted() {}
29-
Scripted(sol::table call): caller(call) {}
30-
31-
32-
~Scripted()
33-
{}
34-
35-
void cleanup()
36-
{
37-
caller = sol::nil;
38-
}
39-
40-
Scripted FromLua(sol::object)
41-
{
42-
return *this;
43-
}
44-
45-
void exec() {
46-
if (caller["Idle"] == sol::type::function)
47-
caller["Idle"](caller); // Call idle function and pass itself
48-
// in or to fulfill the 'self' param
49-
}
26+
public:
27+
sol::table caller;
28+
29+
Scripted(void) {}
30+
Scripted(sol::table call) :
31+
caller(call) {}
32+
33+
~Scripted() {}
34+
35+
void cleanup(void)
36+
{
37+
caller = sol::nil;
38+
}
39+
40+
Scripted FromLua([[maybe_unused]] sol::object ref)
41+
{
42+
return *this;
43+
}
44+
45+
void exec(void) {
46+
if (caller["Idle"] == sol::type::function)
47+
caller["Idle"](caller); // Call idle function and pass itself
48+
// in or to fulfill the 'self' param
49+
}
5050
};
5151

52-
#endif//SCRIPT_COMPONENT_HPP_
52+
#endif // COMPONENT_SCRIPT_HPP_
53+

src/components/Velocity.hpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,33 @@
1717
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
#ifndef VELOCITY_HPP_
21-
#define VELOCITY_HPP_
20+
#ifndef COMPONENT_VELOCITY_HPP_
21+
#define COMPONENT_VELOCITY_HPP_
2222

23-
#include <components/Component.hpp>
23+
#include "Component.hpp"
2424

2525
struct Velocity : Component<Velocity>, entityx::Component<Velocity>
2626
{
27-
public:
28-
double x, y;
29-
Velocity(): x(0), y(0) {}
30-
Velocity(double _x, double _y): x(_x), y(_y) {}
27+
public:
28+
double x, y;
3129

32-
Velocity FromLua(sol::object ref)
33-
{
34-
if (ref.get_type() == sol::type::table) {
35-
sol::table tab = ref;
36-
if (tab["x"] != nullptr)
37-
this->x = tab["x"];
38-
if (tab["y"] != nullptr)
39-
this->y = tab["y"];
40-
} else {
41-
throw std::string("Velocity table not formatted properly");
42-
}
43-
return *this;
30+
Velocity(double _x = 0, double _y = 0) :
31+
x(_x), y(_y) {}
32+
33+
Velocity FromLua(sol::object ref)
34+
{
35+
if (ref.get_type() == sol::type::table) {
36+
sol::table tab = ref;
37+
if (tab["x"] != nullptr)
38+
this->x = tab["x"];
39+
if (tab["y"] != nullptr)
40+
this->y = tab["y"];
41+
} else {
42+
throw std::string("Velocity table not formatted properly");
4443
}
44+
return *this;
45+
}
4546
};
4647

47-
#endif//VELOCITY_HPP_
48+
#endif // COMPONENT_VELOCITY_HPP_
49+

0 commit comments

Comments
 (0)