MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / UpdateSmallSceneryAnimation

Function UpdateSmallSceneryAnimation

src/openrct2/world/MapAnimation.cpp:153–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151
152template<bool invalidate, bool invalidateAllViewports>
153static std::optional<UpdateType> UpdateSmallSceneryAnimation(
154 const SmallSceneryElement& scenery, const CoordsXYZ& loc, const int32_t baseZ, const Viewport* const viewport)
155{
156 const auto* const entry = scenery.GetEntry();
157 if (entry == nullptr)
158 {
159 return std::nullopt;
160 }
161
162 if (entry->flags.hasAny(
163 SmallSceneryFlag::isFountain, SmallSceneryFlag::isCupidFountain, SmallSceneryFlag::isSwampGoo,
164 SmallSceneryFlag::hasFrameOffsets, SmallSceneryFlag::isClock))
165 {
166 auto animationType = UpdateType::invalidate;
167 if (entry->flags.has(SmallSceneryFlag::isClock))
168 {
169 animationType = UpdateType::update;
170
171 // Don't apply anything to peeps when the scenery is a ghost.
172 if (!scenery.isGhost() && !(getGameState().currentTicks & 0x3FF))
173 {
174 const int32_t direction = scenery.getDirection();
175 auto quad = EntityTileList<Peep>(CoordsXY{ loc.x, loc.y } - CoordsDirectionDelta[direction]);
176 for (auto peep : quad)
177 {
178 if (peep->State != PeepState::walking || peep->z != baseZ || !peep->IsActionInterruptableSafely())
179 continue;
180 peep->Action = PeepActionType::checkTime;
181 peep->AnimationFrameNum = 0;
182 peep->AnimationImageIdOffset = 0;
183 peep->UpdateCurrentAnimationType();
184 if constexpr (invalidate)
185 {
186 peep->invalidate();
187 }
188 break;
189 }
190 if constexpr (invalidate)
191 {
192 Invalidate<invalidateAllViewports>(viewport, loc.x, loc.y, baseZ, scenery.getClearanceZ(), kMaxZoom);
193 }
194 }
195 }
196 else if constexpr (invalidate)
197 {
198 Invalidate<invalidateAllViewports>(viewport, loc.x, loc.y, baseZ, scenery.getClearanceZ(), kMaxZoom);
199 }
200 return std::optional(animationType);
201 }
202
203 return std::nullopt;
204}
205
206template<bool invalidate, bool invalidateAllViewports>
207static bool UpdateTrackAnimation(TrackElement& track, const CoordsXYZ& loc, const int32_t baseZ, const Viewport* const viewport)

Callers

nothing calls this directly

Calls 9

hasAnyMethod · 0.80
getClearanceZMethod · 0.80
hasMethod · 0.65
GetEntryMethod · 0.45
isGhostMethod · 0.45
getDirectionMethod · 0.45
invalidateMethod · 0.45

Tested by

no test coverage detected