Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/weapons/src/orxonox/objects/weaponSystem/Weapon.h @ 2912

Last change on this file since 2912 was 2912, checked in by landauf, 15 years ago

Several small adjustments in the weaponsystem (like additional const keyword, includes moved from .h to .cc where possible, …)

Firemode is now an unsigned int instead of an Enum. Instead of "fire" and "altFire" use "fire 0" and "fire 1"

  • Property svn:eol-style set to native
File size: 4.0 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#ifndef _Weapon_H__
30#define _Weapon_H__
31
32#include "OrxonoxPrereqs.h"
33#include "objects/worldentities/StaticEntity.h"
34
35#include "tools/Timer.h"
36#include "core/Identifier.h"
37
38namespace orxonox
39{
40    class _OrxonoxExport Weapon : public StaticEntity
41    {
42        public:
43            Weapon(BaseObject* creator);
44            virtual ~Weapon();
45
46            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
47
48            virtual void fire();
49            void attachNeededMunition(const std::string& munitionType);
50            Munition * getAttachedMunition(const std::string& munitiontype);
51
52            //reloading
53            void bulletTimer(float bulletLoadingTime);
54            void magazineTimer(float magazineLoadingTime);
55            void bulletReloaded();
56            void magazineReloaded();
57
58            //XMLPort functions
59            virtual void setMunitionType(const std::string& munitionType);
60            virtual const std::string& getMunitionType() const;
61            virtual void setBulletLoadingTime(float loadingTime);
62            virtual const float getBulletLoadingTime() const;
63            virtual void setMagazineLoadingTime(float loadingTime);
64            virtual const float getMagazineLoadingTime() const;
65            virtual void setBulletAmount(unsigned int amount);
66            virtual const unsigned int getBulletAmount() const;
67            virtual void setMagazineAmount(unsigned int amount);
68            virtual const unsigned int getMagazineAmount() const;
69            virtual void setUnlimitedMunition(bool unlimitedMunition);
70            virtual const bool getUnlimitedMunition() const;
71
72            //weapon actions
73            virtual void takeBullets();
74            virtual void takeMagazines();
75            virtual void createProjectile();
76            virtual void reloadBullet();
77            virtual void reloadMagazine();
78
79            //manually set or reset
80            virtual void setWeapon();
81            virtual void setMunition();
82
83            inline void setWeaponSystem(WeaponSystem *weaponSystem)
84                { this->weaponSystem_ = weaponSystem; };
85            inline WeaponSystem * getWeaponSystem() const
86                { return this->weaponSystem_; };
87
88            inline void setAttachedToWeaponSlot(WeaponSlot * wSlot)
89                { this->attachedToWeaponSlot_ = wSlot; }
90            inline WeaponSlot * getAttachedToWeaponSlot() const
91                { return this->attachedToWeaponSlot_; }
92
93        protected:
94            bool bReloading_;
95            bool bulletReadyToShoot_;
96            bool magazineReadyToShoot_;
97            bool unlimitedMunition_;
98            float bulletLoadingTime_;
99            float magazineLoadingTime_;
100            unsigned int bulletAmount_;
101            unsigned int magazineAmount_;
102            std::string munitionType_;
103
104            WeaponSlot * attachedToWeaponSlot_;
105            Munition * munition_;
106            WeaponSystem * weaponSystem_;
107
108            SubclassIdentifier<Munition> munitionIdentifier_;
109
110            Timer<Weapon> bulletReloadTimer_;
111            Timer<Weapon> magazineReloadTimer_;
112    };
113}
114
115#endif /* _Weapon_H__ */
Note: See TracBrowser for help on using the repository browser.