ScummVM API documentation
weapon_overlay.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program 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  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef WORLD_ACTORS_WEAPONOVERLAY_H
23 #define WORLD_ACTORS_WEAPONOVERLAY_H
24 
25 #include "ultima/shared/std/containers.h"
26 
27 namespace Ultima {
28 namespace Ultima8 {
29 
31  int32 _xOff;
32  int32 _yOff;
33  uint32 _frame;
34 };
35 
36 struct WeaponOverlay {
37  unsigned int _dirCount;
38  Std::vector<WeaponOverlayFrame> *_frames; // 8 or 16 directions
39 
40  WeaponOverlay() : _frames(nullptr), _dirCount(0) {
41  }
42  ~WeaponOverlay() {
43  delete[] _frames;
44  }
45 };
46 
53  const WeaponOverlayFrame *getFrame(unsigned int type,
54  Direction direction,
55  unsigned int frame) const {
56  if (type >= _overlay.size())
57  return nullptr;
58 
59  assert(direction != dir_invalid);
60 
61  uint32 diroff;
62  if (_overlay[type]._dirCount == 8)
63  diroff = static_cast<uint32>(direction) / 2;
64  else
65  diroff = static_cast<uint32>(direction);
66 
67  if (diroff >= _overlay[type]._dirCount)
68  return nullptr;
69  if (frame >= _overlay[type]._frames[diroff].size())
70  return nullptr;
71  return &(_overlay[type]._frames[diroff][frame]);
72  }
73 
75 };
76 
77 } // End of namespace Ultima8
78 } // End of namespace Ultima
79 
80 #endif
const WeaponOverlayFrame * getFrame(unsigned int type, Direction direction, unsigned int frame) const
Definition: weapon_overlay.h:53
Definition: weapon_overlay.h:30
Definition: detection.h:27
Definition: weapon_overlay.h:36
Definition: containers.h:38
Definition: weapon_overlay.h:47