Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCenterpoint.cc @ 12396

Last change on this file since 12396 was 12396, checked in by pomselj, 5 years ago

Jesus safed our souls and stopped the crashing. Hallowed be his name and hallowed be his followers sevy and aryo, first of their names, saviors of the andals the raynars and the first nerds. Fourier is love btw

File size: 1.9 KB
Line 
1#include "OrxoBloxCenterpoint.h"
2
3#include "core/CoreIncludes.h"
4#include "core/XMLPort.h"
5
6#include "OrxoBlox.h"
7
8namespace orxonox
9{
10    RegisterClass(OrxoBloxCenterpoint);
11
12    /**
13    @brief
14        Constructor. Registers and initializes the object and checks whether the gametype is actually OrxoBlox.
15    */
16    OrxoBloxCenterpoint::OrxoBloxCenterpoint(Context* context) : StaticEntity(context)
17    {
18        RegisterObject(OrxoBloxCenterpoint);
19
20        this->width_ = 100;
21        this->height_ = 50;
22        this->ballspeed_ = 100;
23        this->ballaccfactor_ = 1.0;
24       
25        this->checkGametype();
26    }
27
28    /**
29    @brief
30        Method to create a OrxoBloxCenterpoint through XML.
31    */
32    void OrxoBloxCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
33    {
34        SUPER(OrxoBloxCenterpoint, XMLPort, xmlelement, mode);
35
36        XMLPortParam(OrxoBloxCenterpoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
37        XMLPortParam(OrxoBloxCenterpoint, "balltemplate", setBalltemplate, getBalltemplate, xmlelement, mode);
38        XMLPortParam(OrxoBloxCenterpoint, "ballspeed", setBallSpeed, getBallSpeed, xmlelement, mode);
39        XMLPortParam(OrxoBloxCenterpoint, "ballaccfactor", setBallAccelerationFactor, getBallAccelerationFactor, xmlelement, mode);
40
41        XMLPortParam(OrxoBloxCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
42        XMLPortParam(OrxoBloxCenterpoint, "WallTemplate", setWallTemplate, getWallTemplate, xmlelement, mode);
43    }
44
45    /**
46    @brief
47        Checks whether the gametype is OrxoBlox and if it is, sets its centerpoint.
48    */
49    void OrxoBloxCenterpoint::checkGametype()
50    {
51        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
52        {
53            OrxoBlox* OrxoBloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
54            OrxoBloxGametype->setCenterpoint(this);
55        }
56    }
57}
Note: See TracBrowser for help on using the repository browser.