22 #ifndef HARVESTER_RUNTIME_ENTITY_H 23 #define HARVESTER_RUNTIME_ENTITY_H 25 #include "common/array.h" 26 #include "common/rect.h" 27 #include "common/str.h" 28 #include "harvester/art.h" 36 class ResourceManager;
38 enum RuntimeEntityClass {
39 kRuntimeEntityClassObject = 0,
40 kRuntimeEntityClassAnimation = 1,
41 kRuntimeEntityClassCursor = 2,
42 kRuntimeEntityClassBackground = 3,
43 kRuntimeEntityClassNpc = 4,
44 kRuntimeEntityClassPlayer = 5,
45 kRuntimeEntityClassMonster = 6,
46 kRuntimeEntityClassRectHotspot = 0x15,
47 kRuntimeEntityClassDisabledHotspot = 0x16,
48 kRuntimeEntityClassTimer = 0x17,
49 kRuntimeEntityClassRectHotspot18 = 0x18,
50 kRuntimeEntityClassRectHotspot19 = 0x19
53 enum RuntimeEntityHitTestMode {
54 kRuntimeEntityHitTestNone = 0,
55 kRuntimeEntityHitTestBounds = 1,
56 kRuntimeEntityHitTestOpaquePixels = 2
59 enum RuntimeEntityAnchorMode {
60 kRuntimeEntityAnchorTopLeft = 0,
61 kRuntimeEntityAnchorCentered = 1
72 void setClassId(
int classId) { _classId = classId; }
73 int getClassId()
const {
return _classId; }
74 void setAnchorMode(RuntimeEntityAnchorMode anchorMode);
75 void setZExtent(
float zExtent) { _zExtent = zExtent; }
76 float getZExtent()
const {
return _zExtent; }
78 void setLooping(
bool looping) { _looping = looping; }
79 void setPingPong(
bool pingPong) { _pingPong = pingPong; }
80 void setPlayBackwards(
bool playBackwards) { _playBackwards = playBackwards; }
81 void setVisible(
bool visible) { _visible = visible; }
82 bool isVisible()
const {
return _visible; }
84 void setPosition(
int x,
int y,
float z);
85 int getX()
const {
return _x; }
86 int getY()
const {
return _y; }
87 float getZ()
const {
return _z; }
89 void setAnimationRate(
int rate);
90 int getAnimationRate()
const {
return _animationRate; }
91 void setAnimationEnabled(
bool enabled);
92 bool isAnimationEnabled()
const {
return _animationEnabled; }
93 void setCurrentFrame(
int frame);
94 int getCurrentFrame()
const {
return _currentFrame; }
95 int getLastFrame()
const {
return _lastFrame; }
96 uint getFrameCount()
const {
return _frames.size(); }
97 bool didAnimationAdvanceLastTick()
const {
return _animationAdvancedLastTick; }
98 void setAnimationFrameRange(
int firstFrame,
int lastFrame,
bool looping);
99 void setAnimationSequence(
int sequence);
100 int getAnimationSequence()
const {
return _animationSequence; }
101 void configureHotspotBounds(
int width,
int height);
102 void setHitTestMode(RuntimeEntityHitTestMode mode) { _hitTestMode = mode; }
103 int getBoundsWidth()
const {
return _boundsWidth; }
104 int getBoundsHeight()
const {
return _boundsHeight; }
105 bool getCurrentFrameMetrics(
int &width,
int &height,
int &xOffset,
int &yOffset)
const;
106 bool hasOpaqueFramesInRange(
int firstFrame,
int lastFrame)
const;
107 void setDepthScale(
float scale);
108 float getDepthScale()
const {
return _depthScale; }
110 void configureTimerCountdown(
int initialValue,
int currentValue,
bool enabled,
bool looping,
bool global);
112 void pauseTimerCountdown(uint32 now);
113 void resumeTimerCountdown(uint32 now);
114 void setTimerEnabled(
bool enabled);
115 bool isTimerEnabled()
const {
return _timerEnabled; }
116 bool isTimerLooping()
const {
return _timerLooping; }
117 bool isTimerGlobal()
const {
return _timerGlobal; }
118 int getTimerInitialValue()
const {
return _timerInitialValue; }
119 int getTimerCurrentValue()
const {
return _timerCurrentValue; }
121 bool hasFrames()
const {
return !_frames.empty(); }
122 bool tickVisualState(uint32 now);
125 bool overlapsEntity(
const Entity &other)
const;
126 bool measureCurrentFrameTransparency(uint32 &framePixels, uint32 &transparentPixels,
127 uint32 &preservedPixels)
const;
132 bool hasOpaqueFrame()
const;
134 void advanceAnimationFrame(
int directive);
135 void updateBoundsFromCurrentFrame();
136 void updateScreenBaseFromCurrentFrame();
137 void rebuildScaledFrames();
147 int _screenBaseX = 0;
148 int _screenBaseY = 0;
149 int _currentFrame = -1;
150 int _firstFrame = -1;
152 int _animationRate = 0;
153 uint32 _animationTickInterval = 0;
154 uint32 _nextAnimationTick = 0;
155 int _animationSequence = -1;
156 bool _looping =
true;
157 bool _pingPong =
false;
158 bool _playBackwards =
false;
159 bool _animationEnabled =
true;
160 bool _animationAdvancedLastTick =
false;
161 bool _visible =
true;
162 bool _drawEnabled =
true;
163 int _boundsWidth = 0;
164 int _boundsHeight = 0;
165 RuntimeEntityHitTestMode _hitTestMode = kRuntimeEntityHitTestNone;
166 RuntimeEntityAnchorMode _anchorMode = kRuntimeEntityAnchorTopLeft;
167 float _zExtent = 0.0f;
168 float _depthScale = 1.0f;
169 int _timerInitialValue = 0;
170 int _timerCurrentValue = 0;
171 uint32 _timerStartTick = 0;
172 uint32 _timerNextFireTick = 0;
173 uint32 _timerPauseTick = 0;
174 bool _timerEnabled =
false;
175 bool _timerLooping =
false;
176 bool _timerGlobal =
false;
177 bool _timerPaused =
false;
186 void clearSceneEntities(
bool preserveGlobalTimers =
false);
188 int classId,
const Common::Point &position,
float z,
int animationRate,
bool looping,
bool pingPong);
196 const Common::Point &position,
float z,
int animationRate,
bool active,
bool visible,
bool looping,
197 bool playBackwards,
bool pingPong,
int initialFrame = -1);
201 bool enabled,
bool looping,
bool global);
202 void configureSceneTimerEntity(
Entity &entity,
int initialValue,
int currentValue,
203 bool enabled,
bool looping,
bool global);
204 Entity *getCursorEntity()
const {
return _cursorEntity; }
207 void pauseTimerCountdowns();
208 void resumeTimerCountdowns();
210 bool tickSceneEntities();
211 bool syncCursorEntityPosition(
const Common::Point &position);
214 const Entity *findTopSceneEntityAt(
const Common::Point &point,
int classIdFilter = -1)
const;
215 int findSceneEntityDrawIndexByName(
const Common::String &name)
const;
219 void adoptSceneEntity(
Entity *entity);
220 void reinsertSceneEntity(
Entity *entity);
223 void insertSceneEntity(
Entity *entity);
228 Entity *_cursorEntity =
nullptr;
229 int _timerPauseDepth = 0;
234 #endif // HARVESTER_RUNTIME_ENTITY_H
Definition: atari-screen.h:58
Definition: runtime_entity.h:64
Definition: runtime_entity.h:180
Definition: formatinfo.h:28
Definition: resources.h:32