OpenXcom  1.0
Open-source clone of the original X-Com
Projectile.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 <vector>
21 #include "Position.h"
22 #include "BattlescapeGame.h"
23 
24 namespace OpenXcom
25 {
26 
27 class BattleItem;
28 class SavedBattleGame;
29 class Surface;
30 class Tile;
31 class Mod;
32 
38 {
39 private:
40  Mod *_mod;
41  SavedBattleGame *_save;
42  BattleAction _action;
43  Position _origin, _targetVoxel;
44  std::vector<Position> _trajectory;
45  size_t _position;
46  Surface *_sprite;
47  int _speed;
48  int _bulletSprite;
49  bool _reversed;
50  int _vaporColor, _vaporDensity, _vaporProbability;
51  void applyAccuracy(Position origin, Position *target, double accuracy, bool keepRange, bool extendLine);
52 public:
54  Projectile(Mod *mod, SavedBattleGame *save, BattleAction action, Position origin, Position target, BattleItem *ammo);
56  ~Projectile();
58  int calculateTrajectory(double accuracy);
59  int calculateTrajectory(double accuracy, const Position& originVoxel, bool excludeUnit = true);
61  int calculateThrow(double accuracy);
63  bool move();
65  Position getPosition(int offset = 0) const;
67  int getParticle(int i) const;
69  BattleItem *getItem() const;
71  Surface *getSprite() const;
73  void skipTrajectory();
75  Position getOrigin() const;
77  Position getTarget() const;
79  bool isReversed() const;
81  void addVaporCloud();
82 };
83 
84 }
int getParticle(int i) const
Gets a particle from the particle array.
Definition: Projectile.cpp:457
void addVaporCloud()
adds a cloud of particles at the projectile&#39;s location
Definition: Projectile.cpp:529
Position getOrigin() const
Gets the Position of origin for the projectile.
Definition: Projectile.cpp:499
Definition: BattlescapeGame.h:43
bool isReversed() const
Is this projectile being drawn back-to-front or front-to-back?
Definition: Projectile.cpp:521
void skipTrajectory()
Skips the bullet flight.
Definition: Projectile.cpp:490
A class that represents a projectile.
Definition: Projectile.h:37
Position getPosition(int offset=0) const
Gets the current position in voxel space.
Definition: Projectile.cpp:443
Contains all the game-specific static data that never changes throughout the game, like rulesets and resources.
Definition: Mod.h:87
int calculateThrow(double accuracy)
Calculates the trajectory for a curved path.
Definition: Projectile.cpp:216
int calculateTrajectory(double accuracy)
Calculates the trajectory for a straight path.
Definition: Projectile.cpp:114
bool move()
Moves the projectile one step in its trajectory.
Definition: Projectile.cpp:420
Represents a single item in the battlescape.
Definition: BattleItem.h:37
BattleItem * getItem() const
Gets the item.
Definition: Projectile.cpp:470
~Projectile()
Cleans up the Projectile.
Definition: Projectile.cpp:103
Projectile(Mod *mod, SavedBattleGame *save, BattleAction action, Position origin, Position target, BattleItem *ammo)
Creates a new Projectile.
Definition: Projectile.cpp:49
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
The battlescape data that gets written to disk when the game is saved.
Definition: SavedBattleGame.h:47
Position getTarget() const
Gets the targetted tile for the projectile.
Definition: Projectile.cpp:512
Surface * getSprite() const
Gets the sprite.
Definition: Projectile.cpp:482
Easy handling of X-Y-Z coordinates.
Definition: Position.h:28
Definition: BaseInfoState.cpp:40