Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/weapon/WeaponStation.cc @ 884

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

merged FICN back into trunk
awaiting release.

File size: 1.9 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 "OrxonoxStableHeaders.h"
29
30#include "BaseWeapon.h"
31#include "WeaponStation.h"
32
33
34namespace orxonox {
35  WeaponStation::WeaponStation(int stationSize)
36        : slots_(new BaseWeapon*[stationSize]),
37          lastActiveSlotIndex_(-1), stationSize_(stationSize)
38  {
39        //slots_ = new BaseWeapon*[stationSize];
40  }
41
42
43  WeaponStation::~WeaponStation()
44  {
45    if (slots_)
46      delete slots_;
47    // when factory available: delete weapons too
48  }
49
50
51  bool WeaponStation::addWeapon(BaseWeapon *weapon)
52  {
53    if (lastActiveSlotIndex_ == stationSize_ - 1)
54      return false;
55
56    // this is ugly, but for the time being, it has to fit.
57    slots_[++lastActiveSlotIndex_] = weapon;
58    selectedSlot_ = slots_ + lastActiveSlotIndex_;
59    return true;
60  }
61
62
63  BaseWeapon* WeaponStation::selectWeapon(int slotNumber)
64  {
65    if (slotNumber < lastActiveSlotIndex_)
66      return NULL;
67    return slots_[slotNumber];
68  }
69
70}
Note: See TracBrowser for help on using the repository browser.