[jasper/world] Make World::updateObj return error
All checks were successful
Build / build (push) Successful in 3m55s
All checks were successful
Build / build (push) Successful in 3m55s
This commit is contained in:
parent
a986ab5734
commit
d5d22372e1
@ -37,7 +37,7 @@ class World {
|
||||
void setupTile(uint32_t lyr, uint32_t x, uint32_t y) noexcept;
|
||||
|
||||
private:
|
||||
turbine::TimeMs updateObj(ObjState &state) noexcept;
|
||||
ox::Result<turbine::TimeMs> updateObj(ObjState &state) noexcept;
|
||||
|
||||
void setupLayer(uint_t lyr, uint_t cbb) noexcept;
|
||||
|
||||
|
@ -55,7 +55,8 @@ ox::Result<int> World::update() noexcept {
|
||||
turbine::TimeMs nextUpdateTime = ox::MaxValue<turbine::TimeMs>;
|
||||
m_currentTicks = ticksMs(turbineCtx(m_nctx));
|
||||
for (auto &state : m_objStates) {
|
||||
nextUpdateTime = ox::min(nextUpdateTime, updateObj(state));
|
||||
OX_REQUIRE(u, updateObj(state));
|
||||
nextUpdateTime = ox::min(nextUpdateTime, u);
|
||||
}
|
||||
return static_cast<int>(nextUpdateTime - m_currentTicks);
|
||||
}
|
||||
@ -102,20 +103,20 @@ void World::setupTile(
|
||||
}
|
||||
}
|
||||
|
||||
turbine::TimeMs World::updateObj(ObjState &state) noexcept {
|
||||
ox::Result<turbine::TimeMs> World::updateObj(ObjState &state) noexcept {
|
||||
if (state.nextUpdateTime <= m_currentTicks) {
|
||||
auto &obj = m_worldStatic.objTileRefSets[state.objIdx];
|
||||
++state.frame;
|
||||
if (state.frame >= obj.frames) {
|
||||
state.frame = 0;
|
||||
}
|
||||
std::ignore = ncore::loadBgTileSheet(
|
||||
OX_RETURN_ERROR(ncore::loadBgTileSheet(
|
||||
m_nctx,
|
||||
obj.cbb,
|
||||
*m_tilesheets[obj.tilesheetId],
|
||||
obj.cbbIdx,
|
||||
static_cast<size_t>(obj.tilesheetIdx + state.frame * static_cast<uint16_t>(obj.tileCnt)),
|
||||
obj.tileCnt);
|
||||
obj.tileCnt));
|
||||
state.nextUpdateTime = m_currentTicks + obj.intervalMs;
|
||||
}
|
||||
return state.nextUpdateTime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user