veloren_common/comp/anchor.rs
1use specs::{Component, Entity};
2use vek::Vec2;
3
4/// This component exists in order to fix a bug that caused entities
5/// such as campfires to duplicate because the chunk was double-loaded.
6/// See https://gitlab.com/veloren/veloren/-/merge_requests/1543
7#[derive(Copy, Clone, Debug, PartialEq, Eq)]
8pub enum Anchor {
9 /// An entity with an Entity Anchor will be destroyed when its anchor Entity
10 /// no longer exists
11 Entity(Entity),
12 /// An entity with Chunk Anchor will be destroyed when both the chunk it's
13 /// currently positioned within and its anchor chunk are unloaded
14 Chunk(Vec2<i32>),
15}
16
17impl Component for Anchor {
18 type Storage = specs::VecStorage<Self>;
19}