Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/objects/weapon_system/weapon_station.cc @ 637

Last change on this file since 637 was 637, checked in by rgrieder, 16 years ago
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
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (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, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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 {
41  using namespace Ogre;
42
43  WeaponStation::WeaponStation(int stationSize)
44        : stationSize_(stationSize), lastActiveSlotIndex_(-1),
45        slots_(new BaseWeapon*[stationSize])
46  {
47        //slots_ = new BaseWeapon*[stationSize];
48  }
49
50
51  WeaponStation::~WeaponStation()
52  {
53    if (slots_)
54      delete slots_;
55    // when factory available: delete weapons too
56  }
57
58
59  bool WeaponStation::addWeapon(BaseWeapon *weapon)
60  {
61    if (lastActiveSlotIndex_ = stationSize_ - 1)
62      return false;
63
64    // this is ugly, but for the time being, it has to fit.
65    slots_[++lastActiveSlotIndex_] = weapon;
66    selectedSlot_ = slots_ + lastActiveSlotIndex_;
67    return true;
68  }
69
70
71  BaseWeapon* WeaponStation::selectWeapon(int slotNumber)
72  {
73    if (slotNumber < lastActiveSlotIndex_)
74      return NULL;
75    return slots_[slotNumber];
76  }
77
78}
Note: See TracBrowser for help on using the repository browser.