OpenXcom  1.0
Open-source clone of the original X-Com
CraftWeapon.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <yaml-cpp/yaml.h>
21 
22 namespace OpenXcom
23 {
24 
25 class RuleCraftWeapon;
26 class CraftWeaponProjectile;
27 class Mod;
28 
35 {
36 private:
37  RuleCraftWeapon *_rules;
38  int _ammo;
39  bool _rearming;
40 public:
42  CraftWeapon(RuleCraftWeapon *rules, int ammo);
44  ~CraftWeapon();
46  void load(const YAML::Node& node);
48  YAML::Node save() const;
50  RuleCraftWeapon *getRules() const;
52  int getAmmo() const;
54  bool setAmmo(int ammo);
56  bool isRearming() const;
58  void setRearming(bool rearming);
60  int rearm(const int available, const int clipSize);
62  CraftWeaponProjectile* fire() const;
64  int getClipsLoaded(const Mod *mod) const;
65 
66 };
67 
68 }
int rearm(const int available, const int clipSize)
Rearms the craft weapon.
Definition: CraftWeapon.cpp:133
void setRearming(bool rearming)
Sets the craft weapon&#39;s rearming status.
Definition: CraftWeapon.cpp:122
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
Represents a craft weapon equipped by a craft.
Definition: CraftWeapon.h:34
CraftWeapon(RuleCraftWeapon *rules, int ammo)
Creates a craft weapon of the specified type.
Definition: CraftWeapon.cpp:35
int getAmmo() const
Gets the craft weapon&#39;s ammo.
Definition: CraftWeapon.cpp:83
bool isRearming() const
Gets the craft weapon&#39;s rearming status.
Definition: CraftWeapon.cpp:112
int getClipsLoaded(const Mod *mod) const
get how many clips are loaded into this weapon.
Definition: CraftWeapon.cpp:170
CraftWeaponProjectile * fire() const
Fires the craft weapon. Used during dogfights.
Definition: CraftWeapon.cpp:154
YAML::Node save() const
Saves the craft weapon to YAML.
Definition: CraftWeapon.cpp:60
~CraftWeapon()
Cleans up the craft weapon.
Definition: CraftWeapon.cpp:42
RuleCraftWeapon * getRules() const
Gets the craft weapon&#39;s ruleset.
Definition: CraftWeapon.cpp:74
void load(const YAML::Node &node)
Loads the craft weapon from YAML.
Definition: CraftWeapon.cpp:50
Represents a specific type of craft weapon.
Definition: RuleCraftWeapon.h:35
bool setAmmo(int ammo)
Sets the craft weapon&#39;s ammo.
Definition: CraftWeapon.cpp:93
Definition: BaseInfoState.cpp:40
Definition: CraftWeaponProjectile.h:32