| 151 | |
| 152 | template<bool invalidate, bool invalidateAllViewports> |
| 153 | static 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 | |
| 206 | template<bool invalidate, bool invalidateAllViewports> |
| 207 | static bool UpdateTrackAnimation(TrackElement& track, const CoordsXYZ& loc, const int32_t baseZ, const Viewport* const viewport) |
nothing calls this directly
no test coverage detected