summaryrefslogtreecommitdiffstats
path: root/game/shared/entity/stasis.cc
blob: 68d8e9d836b3af0528873a3b7fead176cefdf99a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "shared/pch.hh"

#include "shared/entity/stasis.hh"

#include "shared/entity/transform.hh"
#include "shared/world/dimension.hh"

void entity::Stasis::fixed_update(world::Dimension* dimension)
{
    auto view = dimension->entities.view<entity::Transform>();

    for(auto [entity, transform] : view.each()) {
        if(dimension->find_chunk(transform.chunk)) {
            dimension->entities.remove<entity::Stasis>(entity);
        }
        else {
            dimension->entities.emplace_or_replace<entity::Stasis>(entity);
        }
    }
}