]> git.localhorst.tv Git - l2e.git/blob - src/battle/PartyLayout.cpp
added "profile" build configuration
[l2e.git] / src / battle / PartyLayout.cpp
1 #include "PartyLayout.h"
2
3 #include "../loader/Interpreter.h"
4 #include "../loader/TypeDescription.h"
5
6 using math::Vector;
7 using loader::FieldDescription;
8 using loader::Interpreter;
9 using loader::TypeDescription;
10 using std::vector;
11
12 namespace battle {
13
14 Vector<int> PartyLayout::CalculatePosition(int index, int width, int height) const {
15         assert(index >= 0 && index < numPositions);
16         return Vector<int>(
17                         positions[index].X() * width / 255,
18                         positions[index].Y() * height / 223
19                         );
20 }
21
22 void PartyLayout::CalculatePositions(int width, int height, vector<Vector<int> > &dest) const {
23         dest.clear();
24         dest.reserve(numPositions);
25         for (int i(0); i < numPositions; ++i) {
26                 dest.push_back(Vector<int>(
27                                 positions[i].X() * width / 255,
28                                 positions[i].Y() * height / 223
29                                 ));
30         }
31 }
32
33
34 void PartyLayout::CreateTypeDescription() {
35         PartyLayout p;
36
37         TypeDescription &td(TypeDescription::Create(TYPE_ID, "PartyLayout"));
38         td.SetDescription("Positions of party members");
39         td.SetConstructor(&Construct);
40         td.SetSize(sizeof(PartyLayout));
41
42         td.AddField("positions", FieldDescription(((char *)&p.positions) - ((char *)&p), Interpreter::VECTOR_ID).SetReferenced().SetAggregate().SetDescription("the members' positions"));
43 }
44
45 void PartyLayout::Construct(void *data) {
46         new (data) PartyLayout;
47 }
48
49 }