OpenXcom  1.0
Open-source clone of the original X-Com
UnitSprite.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 "../Engine/Surface.h"
21 
22 namespace OpenXcom
23 {
24 
25 class BattleUnit;
26 class BattleItem;
27 class SurfaceSet;
28 
33 class UnitSprite : public Surface
34 {
35 private:
36  BattleUnit *_unit;
37  BattleItem *_itemR, *_itemL;
38  SurfaceSet *_unitSurface, *_itemSurfaceR, *_itemSurfaceL;
39  int _part, _animationFrame, _drawingRoutine;
40  bool _helmet;
41  const std::pair<Uint8, Uint8> *_color;
42  int _colorSize;
43 
48  void drawRoutine0();
50  void drawRoutine1();
52  void drawRoutine2();
54  void drawRoutine3();
57  void drawRoutine4();
59  void drawRoutine5();
61  void drawRoutine6();
63  void drawRoutine7();
65  void drawRoutine8();
67  void drawRoutine9();
69  void drawRoutine11();
71  void drawRoutine12();
73  void drawRoutine19();
75  void drawRoutine20();
77  void drawRoutine21();
79  void sortRifles();
81  void drawRecolored(Surface *src);
82 public:
84  UnitSprite(int width, int height, int x, int y, bool helmet);
86  ~UnitSprite();
88  void setSurfaces(SurfaceSet *unitSurface, SurfaceSet *itemSurfaceA, SurfaceSet *itemSurfaceB);
90  void setBattleUnit(BattleUnit *unit, int part = 0);
92  void setAnimationFrame(int frame);
94  void draw();
95 };
96 
97 }
~UnitSprite()
Cleans up the UnitSprite.
Definition: UnitSprite.cpp:48
void setBattleUnit(BattleUnit *unit, int part=0)
Sets the battleunit to be rendered.
Definition: UnitSprite.cpp:72
UnitSprite(int width, int height, int x, int y, bool helmet)
Creates a new UnitSprite at the specified position and size.
Definition: UnitSprite.cpp:41
Container of a set of surfaces.
Definition: SurfaceSet.h:35
Represents a single item in the battlescape.
Definition: BattleItem.h:37
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
void draw()
Draws the unit.
Definition: UnitSprite.cpp:171
A class that renders a specific unit, given its render rules combining the right frames from the surf...
Definition: UnitSprite.h:33
void setAnimationFrame(int frame)
Sets the animation frame.
Definition: UnitSprite.cpp:162
void setSurfaces(SurfaceSet *unitSurface, SurfaceSet *itemSurfaceA, SurfaceSet *itemSurfaceB)
Sets surfacesets for rendering.
Definition: UnitSprite.cpp:59
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