Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/merger/src/weapon/weapon_station.cc @ 300

Last change on this file since 300 was 300, checked in by nicolasc, 17 years ago

initial merge of main_reto

File size: 2.0 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software: you can redistribute it and/or modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *   Author:
22 *      Reto Grieder
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "OgreMath.h"
29#include "OgreVector3.h"
30#include "OgreStringConverter.h"
31#include "OgreSceneNode.h"
32#include "OgreEntity.h"
33#include "OgreSceneManager.h"
34
35#include "base_weapon.h"
36
37#include "weapon_station.h"
38
39
40namespace orxonox {
41namespace weapon {
42  using namespace Ogre;
43
44  WeaponStation::WeaponStation(int stationSize)
45        : stationSize_(stationSize), lastActiveSlotIndex_(-1),
46        slots_(new BaseWeapon*[stationSize])
47  {
48        //slots_ = new BaseWeapon*[stationSize];
49  }
50
51
52  WeaponStation::~WeaponStation()
53  {
54    if (slots_)
55      delete slots_;
56    // when factory available: delete weapons too
57  }
58
59
60  bool WeaponStation::addWeapon(BaseWeapon *weapon)
61  {
62    if (lastActiveSlotIndex_ = stationSize_ - 1)
63      return false;
64
65    // this is ugly, but for the time being, it has to fit.
66    slots_[++lastActiveSlotIndex_] = weapon;
67    selectedSlot_ = slots_ + lastActiveSlotIndex_;
68    return true;
69  }
70
71
72  BaseWeapon* WeaponStation::selectWeapon(int slotNumber)
73  {
74    if (slotNumber < lastActiveSlotIndex_)
75      return NULL;
76    return slots_[slotNumber];
77  }
78
79}
80}
Note: See TracBrowser for help on using the repository browser.