OpenXcom  1.0
Open-source clone of the original X-Com
BattleItem.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 RuleItem;
26 class RuleInventory;
27 class BattleUnit;
28 class Tile;
29 class Mod;
30 
38 {
39 private:
40  int _id;
41  RuleItem *_rules;
42  BattleUnit *_owner, *_previousOwner;
43  BattleUnit *_unit;
44  Tile *_tile;
45  RuleInventory *_inventorySlot;
46  int _inventoryX, _inventoryY;
47  BattleItem *_ammoItem;
48  int _fuseTimer, _ammoQuantity;
49  int _painKiller, _heal, _stimulant;
50  bool _XCOMProperty, _droppedOnAlienTurn, _isAmmo;
51 public:
53  BattleItem(RuleItem *rules, int *id);
55  ~BattleItem();
57  void load(const YAML::Node& node, Mod *mod);
59  YAML::Node save() const;
61  RuleItem *getRules() const;
63  int getAmmoQuantity() const;
65  void setAmmoQuantity(int qty);
67  int getFuseTimer() const;
69  void setFuseTimer(int turns);
71  bool spendBullet();
73  BattleUnit *getOwner() const;
77  void setOwner(BattleUnit *owner);
79  void setPreviousOwner(BattleUnit *owner);
81  void moveToOwner(BattleUnit *owner);
83  RuleInventory *getSlot() const;
85  void setSlot(RuleInventory *slot);
87  int getSlotX() const;
89  void setSlotX(int x);
91  int getSlotY() const;
93  void setSlotY(int y);
95  bool occupiesSlot(int x, int y, BattleItem *item = 0) const;
99  bool needsAmmo() const;
101  int setAmmoItem(BattleItem *item);
103  Tile *getTile() const;
105  void setTile(Tile *tile);
107  int getId() const;
109  BattleUnit *getUnit() const;
111  void setUnit(BattleUnit *unit);
113  void setHealQuantity (int heal);
115  int getHealQuantity() const;
117  void setPainKillerQuantity (int pk);
119  int getPainKillerQuantity() const;
121  void setStimulantQuantity (int stimulant);
123  int getStimulantQuantity() const;
125  void setXCOMProperty (bool flag);
127  bool getXCOMProperty() const;
129  bool getTurnFlag() const;
131  void setTurnFlag(bool flag);
133  void convertToCorpse(RuleItem *rules);
135  void setIsAmmo(bool ammo);
137  bool isAmmo() const;
138 };
139 
140 }
int getFuseTimer() const
Gets the turn until explosion.
Definition: BattleItem.cpp:149
void setAmmoQuantity(int qty)
Sets the item&#39;s ammo quantity.
Definition: BattleItem.cpp:180
RuleInventory * getSlot() const
Gets the item&#39;s inventory slot.
Definition: BattleItem.cpp:266
void setSlotX(int x)
Sets the item&#39;s inventory X position.
Definition: BattleItem.cpp:293
bool occupiesSlot(int x, int y, BattleItem *item=0) const
Checks if the item is occupying a slot.
Definition: BattleItem.cpp:323
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
int getAmmoQuantity() const
Gets the item&#39;s ammo quantity.
Definition: BattleItem.cpp:167
bool needsAmmo() const
Determines if this item uses ammo.
Definition: BattleItem.cpp:356
bool isAmmo() const
Checks a flag on the item to see if it&#39;s a clip in a weapon or not.
Definition: BattleItem.cpp:558
void setOwner(BattleUnit *owner)
Sets the owner.
Definition: BattleItem.cpp:222
int getPainKillerQuantity() const
Get medikit pain killers quantity.
Definition: BattleItem.cpp:472
void load(const YAML::Node &node, Mod *mod)
Loads the item from YAML.
Definition: BattleItem.cpp:67
YAML::Node save() const
Saves the item to YAML.
Definition: BattleItem.cpp:97
bool getTurnFlag() const
get the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:518
int getStimulantQuantity() const
Get medikit stimulant quantity.
Definition: BattleItem.cpp:490
BattleUnit * getUnit() const
Gets the corpse&#39;s unit.
Definition: BattleItem.cpp:427
void setPreviousOwner(BattleUnit *owner)
Sets the item&#39;s previous owner.
Definition: BattleItem.cpp:232
int getSlotX() const
Gets the item&#39;s inventory X position.
Definition: BattleItem.cpp:284
Represents a specific type of item.
Definition: RuleItem.h:40
int getHealQuantity() const
Get medikit heal quantity.
Definition: BattleItem.cpp:454
BattleItem * getAmmoItem()
Gets the item&#39;s ammo item.
Definition: BattleItem.cpp:347
Represents a single item in the battlescape.
Definition: BattleItem.h:37
void convertToCorpse(RuleItem *rules)
Sets the item&#39;s ruleset.
Definition: BattleItem.cpp:537
void setTurnFlag(bool flag)
set the flag representing "not dropped on player turn"
Definition: BattleItem.cpp:528
void setPainKillerQuantity(int pk)
Set medikit pain killers quantity.
Definition: BattleItem.cpp:463
void setTile(Tile *tile)
Sets the tile.
Definition: BattleItem.cpp:409
void setStimulantQuantity(int stimulant)
Set medikit stimulant quantity.
Definition: BattleItem.cpp:481
void setIsAmmo(bool ammo)
Sets a flag on the item indicating if this is a clip in a weapon or not.
Definition: BattleItem.cpp:549
BattleUnit * getPreviousOwner() const
Gets the item&#39;s previous owner.
Definition: BattleItem.cpp:213
int getSlotY() const
Gets the item&#39;s inventory Y position.
Definition: BattleItem.cpp:302
BattleUnit * getOwner() const
Gets the item&#39;s owner.
Definition: BattleItem.cpp:204
Basic element of which a battle map is build.
Definition: Tile.h:42
RuleItem * getRules() const
Gets the item&#39;s ruleset.
Definition: BattleItem.cpp:140
Tile * getTile() const
Gets the item&#39;s tile.
Definition: BattleItem.cpp:400
void setFuseTimer(int turns)
Sets the turns until explosion.
Definition: BattleItem.cpp:158
void setUnit(BattleUnit *unit)
Sets the corpse&#39;s unit.
Definition: BattleItem.cpp:436
bool getXCOMProperty() const
Get xcom property flag.
Definition: BattleItem.cpp:508
int getId() const
Gets it&#39;s unique id.
Definition: BattleItem.cpp:418
~BattleItem()
Cleans up the item.
Definition: BattleItem.cpp:58
BattleItem(RuleItem *rules, int *id)
Creates a item of the specified type.
Definition: BattleItem.cpp:34
int setAmmoItem(BattleItem *item)
Sets the item&#39;s ammo item.
Definition: BattleItem.cpp:366
bool spendBullet()
Spend one bullet.
Definition: BattleItem.cpp:189
void setSlotY(int y)
Sets the item&#39;s inventory Y position.
Definition: BattleItem.cpp:311
void setSlot(RuleInventory *slot)
Sets the item&#39;s inventory slot.
Definition: BattleItem.cpp:275
void setXCOMProperty(bool flag)
Set xcom property flag.
Definition: BattleItem.cpp:499
void setHealQuantity(int heal)
Set medikit Heal quantity.
Definition: BattleItem.cpp:445
Represents a moving unit in the battlescape, player controlled or AI controlled it holds info about i...
Definition: BattleUnit.h:59
Definition: BaseInfoState.cpp:40
void moveToOwner(BattleUnit *owner)
Removes the item from previous owner and moves to new owner.
Definition: BattleItem.cpp:241
Represents a specific section of the inventory, containing information like available slots and scree...
Definition: RuleInventory.h:42