22#ifndef HARVESTER_ENTITY_H
23#define HARVESTER_ENTITY_H
25#include "common/array.h"
26#include "common/rect.h"
27#include "common/str.h"
28#include "harvester/bitmap.h"
38uint32 getRuntimeClockTicks();
41 kEntityClassObject = 0,
42 kEntityClassAnimation = 1,
43 kEntityClassCursor = 2,
44 kEntityClassBackground = 3,
46 kEntityClassPlayer = 5,
47 kEntityClassMonster = 6,
48 kEntityClassRectHotspot = 0x15,
49 kEntityClassDisabledHotspot = 0x16,
50 kEntityClassTimer = 0x17,
51 kEntityClassRectHotspot18 = 0x18,
52 kEntityClassRectHotspot19 = 0x19
55enum EntityHitTestMode {
56 kEntityHitTestNone = 0,
57 kEntityHitTestBounds = 1,
58 kEntityHitTestOpaquePixels = 2
61enum EntityAnchorMode {
62 kEntityAnchorTopLeft = 0,
63 kEntityAnchorCentered = 1
74 void setClassId(
int classId) { _classId = classId; }
75 int getClassId()
const {
return _classId; }
76 void setAnchorMode(EntityAnchorMode anchorMode);
77 void setZExtent(
float zExtent) { _zExtent = zExtent; }
78 float getZExtent()
const {
return _zExtent; }
80 void setLooping(
bool looping) { _looping = looping; }
81 void setPingPong(
bool pingPong) { _pingPong = pingPong; }
82 void setPlayBackwards(
bool playBackwards) { _playBackwards = playBackwards; }
83 void setVisible(
bool visible) { _visible = visible; }
84 bool isVisible()
const {
return _visible; }
86 void setPosition(
int x,
int y,
float z);
87 int getX()
const {
return _x; }
88 int getY()
const {
return _y; }
89 float getZ()
const {
return _z; }
91 void setAnimationRate(
int rate);
92 int getAnimationRate()
const {
return _animationRate; }
93 void setAnimationEnabled(
bool enabled);
94 bool isAnimationEnabled()
const {
return _animationEnabled; }
95 void setCurrentFrame(
int frame,
bool preserveScreenBase =
false);
96 int getCurrentFrame()
const {
return _currentFrame; }
97 int getLastFrame()
const {
return _lastFrame; }
98 uint getFrameCount()
const {
return _frames.size(); }
99 bool didAnimationAdvanceLastTick()
const {
return _animationAdvancedLastTick; }
100 void setAnimationFrameRange(
int firstFrame,
int lastFrame,
bool looping);
101 void setAnimationSequence(
int sequence);
102 int getAnimationSequence()
const {
return _animationSequence; }
103 void configureHotspotBounds(
int width,
int height);
104 void setHitTestMode(EntityHitTestMode mode) { _hitTestMode = mode; }
105 int getBoundsWidth()
const {
return _boundsWidth; }
106 int getBoundsHeight()
const {
return _boundsHeight; }
107 bool getCurrentFrameMetrics(
int &width,
int &height,
int &xOffset,
int &yOffset)
const;
108 bool hasOpaqueFramesInRange(
int firstFrame,
int lastFrame)
const;
109 void setDepthScale(
float scale);
110 float getDepthScale()
const {
return _depthScale; }
112 void configureTimerCountdown(
int initialValue,
int currentValue,
bool enabled,
bool looping,
bool global);
114 void pauseTimerCountdown(uint32 now);
115 void resumeTimerCountdown(uint32 now);
116 void setTimerEnabled(
bool enabled);
117 bool isTimerEnabled()
const {
return _timerEnabled; }
118 bool isTimerLooping()
const {
return _timerLooping; }
119 bool isTimerGlobal()
const {
return _timerGlobal; }
120 int getTimerInitialValue()
const {
return _timerInitialValue; }
121 int getTimerCurrentValue()
const {
return _timerCurrentValue; }
123 bool hasFrames()
const {
return !_frames.empty(); }
124 bool tickVisualState(uint32 now);
127 bool overlapsEntity(
const Entity &other)
const;
129 bool measureCurrentFrameTransparency(uint32 &framePixels, uint32 &transparentPixels,
130 uint32 &preservedPixels)
const;
135 bool hasOpaqueFrame()
const;
137 void advanceAnimationFrame(
int directive);
138 void updateBoundsFromCurrentFrame();
139 void updateScreenBaseFromCurrentFrame();
140 void scaleCurrentFrame();
151 int _screenBaseX = 0;
152 int _screenBaseY = 0;
153 int _currentFrame = -1;
154 int _firstFrame = -1;
156 int _animationRate = 0;
157 uint32 _animationTickInterval = 0;
158 uint32 _nextAnimationTick = 0;
159 int _animationSequence = -1;
160 bool _looping =
true;
161 bool _pingPong =
false;
162 bool _playBackwards =
false;
163 bool _animationEnabled =
true;
164 bool _animationAdvancedLastTick =
false;
165 bool _visible =
true;
166 bool _drawEnabled =
true;
167 int _boundsWidth = 0;
168 int _boundsHeight = 0;
169 EntityHitTestMode _hitTestMode = kEntityHitTestNone;
170 EntityAnchorMode _anchorMode = kEntityAnchorTopLeft;
171 float _zExtent = 0.0f;
172 float _depthScale = 1.0f;
173 int _timerInitialValue = 0;
174 int _timerCurrentValue = 0;
175 uint32 _timerStartTick = 0;
176 uint32 _timerNextFireTick = 0;
177 uint32 _timerPauseTick = 0;
178 bool _timerEnabled =
false;
179 bool _timerLooping =
false;
180 bool _timerGlobal =
false;
181 bool _timerPaused =
false;
190 void clearSceneEntities(
bool preserveGlobalTimers =
false);
192 int classId,
const Common::Point &position,
float z,
int animationRate,
bool looping,
bool pingPong);
200 const Common::Point &position,
float z,
int animationRate,
bool active,
bool visible,
bool looping,
201 bool playBackwards,
bool pingPong,
int initialFrame = -1);
205 bool enabled,
bool looping,
bool global);
206 void configureSceneTimerEntity(
Entity &entity,
int initialValue,
int currentValue,
207 bool enabled,
bool looping,
bool global);
208 Entity *getCursorEntity()
const {
return _cursorEntity; }
211 void pauseTimerCountdowns();
212 void resumeTimerCountdowns();
214 bool tickSceneEntities();
215 bool syncCursorEntityPosition(
const Common::Point &position);
218 const Entity *findTopSceneEntityAt(
const Common::Point &point,
int classIdFilter = -1)
const;
221 int findSceneEntityDrawIndexByName(
const Common::String &name)
const;
225 void adoptSceneEntity(
Entity *entity);
226 void reinsertSceneEntity(
Entity *entity);
229 void insertSceneEntity(
Entity *entity);
234 Entity *_cursorEntity =
nullptr;
235 int _timerPauseDepth = 0;
Definition: resources.h:32
Definition: formatinfo.h:28
Definition: atari-screen.h:58