Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapons/src/orxonox/objects/weaponsystem/WeaponSystem.h @ 3065

Last change on this file since 3065 was 2918, checked in by landauf, 16 years ago

Added many new features in the Munition class:

  • there are now 3 modes: a) every weapon has it's own magazine b) all weapons use the same magazin c) no magazines, just a big munition pool
  • the Munition class handles the reloading of the magazine

Split the Weapon class into Weapon and WeaponMode. WeaponMode creates the fire of the Weapon. A weapon can own several WeaponModes (for example primary and secondary fire). But it's also possible to have a weapon with several muzzles which all fire at the same time (there's a WeaponMode for each muzzle).

Renamed LaserGun to LaserFire and Fusion to FusionFire. They inherit now from WeaponMode.

Changed the code in the Weapon class to use the new Munition functionality.

Added ReplenishingMunition, a subclass of Munition that replenishes itself (used for LaserGunMunition).

Added a reload command to reload magazines.

  • Property svn:eol-style set to native
  • Property svn:mergeinfo set to (toggle deleted branches)
    /code/branches/lodfinal/src/orxonox/objects/weaponSystem/WeaponSystem.hmergedeligible
    /code/branches/pickups/src/orxonox/objects/weaponSystem/WeaponSystem.hmergedeligible
    /code/branches/pickups2/src/orxonox/objects/weaponSystem/WeaponSystem.hmergedeligible
    /code/branches/buildsystem2/src/orxonox/objects/weaponSystem/WeaponSystem.h2506-2658
    /code/branches/buildsystem3/src/orxonox/objects/weaponSystem/WeaponSystem.h2662-2708
    /code/branches/gui/src/orxonox/objects/weaponSystem/WeaponSystem.h2795-2894
    /code/branches/miniprojects/src/orxonox/objects/weaponSystem/WeaponSystem.h2754-2824
    /code/branches/network/src/orxonox/objects/weaponSystem/WeaponSystem.h2356
    /code/branches/network64/src/orxonox/objects/weaponSystem/WeaponSystem.h2210-2355
    /code/branches/objecthierarchy/src/orxonox/objects/weaponSystem/WeaponSystem.h2110-2169
    /code/branches/objecthierarchy2/src/orxonox/objects/weaponSystem/WeaponSystem.h2171-2479
    /code/branches/overlay/src/orxonox/objects/weaponSystem/WeaponSystem.h2117-2385
    /code/branches/physics/src/orxonox/objects/weaponSystem/WeaponSystem.h1912-2055,​2107-2439
    /code/branches/physics_merge/src/orxonox/objects/weaponSystem/WeaponSystem.h2436-2457
    /code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.h2369-2652,​2654-2660
    /code/branches/questsystem2/src/orxonox/objects/weaponSystem/WeaponSystem.h2107-2259
    /code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h2107-2488
    /code/branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h2742-2890
File size: 3.4 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Martin Polak
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29
30#ifndef _WeaponSystem_H__
31#define _WeaponSystem_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <set>
36#include <map>
37#include <vector>
38
39#include "core/BaseObject.h"
40
41namespace orxonox
42{
43    class _OrxonoxExport WeaponSystem : public BaseObject
44    {
45        public:
46            WeaponSystem(BaseObject* creator);
47            virtual ~WeaponSystem();
48
49            // adding and removing WeaponSlots
50            void addWeaponSlot(WeaponSlot * wSlot);
51            void removeWeaponSlot(WeaponSlot * wSlot);
52            WeaponSlot * getWeaponSlot(unsigned int index) const;
53
54            // adding and removing WeaponSets
55            bool addWeaponSet(WeaponSet * wSet);
56            bool addWeaponSet(WeaponSet * wSet, unsigned int firemode);
57            void removeWeaponSet(WeaponSet * wSet);
58            WeaponSet * getWeaponSet(unsigned int index) const;
59
60            // adding and removing WeaponPacks
61            bool canAddWeaponPack(WeaponPack * wPack);
62            bool addWeaponPack(WeaponPack * wPack);
63            void removeWeaponPack(WeaponPack * wPack);
64            WeaponPack * getWeaponPack(unsigned int index) const;
65
66            // configure slots and firemodes
67            bool swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2);
68            void changeWeaponmode(WeaponPack * wPack, WeaponSet * wSet, unsigned int weaponmode);
69
70            void fire(unsigned int firemode);
71            void reload();
72
73            Munition * getMunition(SubclassIdentifier<Munition> * identifier);
74
75            inline void setPawn(Pawn * pawn)
76                { this->pawn_ = pawn; }
77            inline Pawn * getPawn() const
78                { return this->pawn_; }
79
80            inline int getWeaponSlotSize() const
81                { return this->weaponSlots_.size(); }
82
83            static inline unsigned int getFiremodeMask(unsigned int firemode)
84                { return (0x1 << firemode); }
85
86            static const unsigned int MAX_FIRE_MODES = 8;
87            static const unsigned int FIRE_MODE_UNASSIGNED = (unsigned int)-1;
88
89            static const unsigned int MAX_WEAPON_MODES = 8;
90            static const unsigned int WEAPON_MODE_UNASSIGNED = (unsigned int)-1;
91
92        private:
93            std::map<unsigned int, WeaponSet *> weaponSets_;
94            std::vector<WeaponSlot *> weaponSlots_;
95            std::set<WeaponPack *> weaponPacks_;
96            std::map<Identifier *, Munition *> munitions_;
97            Pawn * pawn_;
98    };
99}
100
101#endif /* _WeaponSystem_H__ */
Note: See TracBrowser for help on using the repository browser.