OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Projectile.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_PROJECTILE_H
20 #define OPENXCOM_PROJECTILE_H
21 
22 #include <vector>
23 #include "Position.h"
24 #include "BattlescapeGame.h"
25 
26 namespace OpenXcom
27 {
28 
29 class ResourcePack;
30 class BattleItem;
31 class SavedBattleGame;
32 class Surface;
33 class Tile;
34 
40 {
41 private:
42  ResourcePack *_res;
43  SavedBattleGame *_save;
44  BattleAction _action;
45  Position _origin, _targetVoxel;
46  std::vector<Position> _trajectory;
47  size_t _position;
48  Surface *_sprite;
49  int _speed;
50  void applyAccuracy(const Position& origin, Position *target, double accuracy, bool keepRange, Tile *targetTile, bool extendLine);
51 public:
53  Projectile(ResourcePack *res, SavedBattleGame *save, BattleAction action, Position origin, Position target);
55  ~Projectile();
57  int calculateTrajectory(double accuracy);
58  int calculateTrajectory(double accuracy, Position originVoxel);
60  int calculateThrow(double accuracy);
62  bool move();
64  Position getPosition(int offset = 0) const;
66  int getParticle(int i) const;
68  BattleItem *getItem() const;
70  Surface *getSprite() const;
72  void skipTrajectory();
77 };
78 
79 }
80 
81 #endif
Definition: BattlescapeGame.h:45
void skipTrajectory()
Skips the bullet flight.
Definition: Projectile.cpp:399
A class that represents a projectile.
Definition: Projectile.h:39
Projectile(ResourcePack *res, SavedBattleGame *save, BattleAction action, Position origin, Position target)
Creates a new Projectile.
Definition: Projectile.cpp:52
Position getTarget()
Gets the targetted tile for the projectile.
Definition: Projectile.cpp:421
int calculateThrow(double accuracy)
Calculates the trajectory for a curved path.
Definition: Projectile.cpp:184
int calculateTrajectory(double accuracy)
Calculates the trajectory for a straight path.
Definition: Projectile.cpp:91
bool move()
Moves the projectile one step in its trajectory.
Definition: Projectile.cpp:331
Represents a single item in the battlescape.
Definition: BattleItem.h:39
BattleItem * getItem() const
Gets the item.
Definition: Projectile.cpp:379
~Projectile()
Cleans up the Projectile.
Definition: Projectile.cpp:80
Position getOrigin()
Gets the Position of origin for the projectile.
Definition: Projectile.cpp:408
Position getPosition(int offset=0) const
Gets the current position in voxel space.
Definition: Projectile.cpp:350
Basic element of which a battle map is build.
Definition: Tile.h:43
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
Packs of external game media.
Definition: ResourcePack.h:50
int getParticle(int i) const
Gets a particle from the particle array.
Definition: Projectile.cpp:364
Surface * getSprite() const
Gets the sprite.
Definition: Projectile.cpp:391
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:50
Easy handling of X-Y-Z coordinates.
Definition: Position.h:30