Struct veloren_common::region::RegionMap
source · pub struct RegionMap {
regions: IndexMap<Vec2<i32>, Region, DefaultHashBuilder>,
tracked_entities: BitSet,
entities_to_move: Vec<(usize, u32, Vec3<i32>)>,
entities_to_remove: Vec<(usize, u32)>,
tick: u64,
}
Expand description
A region system that tracks where entities are.
Note, this structure is primarily intended for tracking which entities need to be synchronized to which clients (and as part of that what entities are already synchronized). If an entity is marked to not be synchronized to other clients it may not appear here.
Fields§
§regions: IndexMap<Vec2<i32>, Region, DefaultHashBuilder>
§tracked_entities: BitSet
§entities_to_move: Vec<(usize, u32, Vec3<i32>)>
§entities_to_remove: Vec<(usize, u32)>
§tick: u64
Implementations§
source§impl RegionMap
impl RegionMap
pub fn new() -> Self
pub fn tick( &mut self, pos: ReadStorage<'_, Pos>, vel: ReadStorage<'_, Vel>, presence: ReadStorage<'_, Presence>, entities: Entities<'_>, )
sourcepub fn entity_deleted(&mut self, entity: Entity)
pub fn entity_deleted(&mut self, entity: Entity)
Must be called immediately after succesfully deleting an entity from the ecs (i.e. when deleting the entity did not generate a WrongGeneration error).
fn add_entity(&mut self, id: u32, pos: Vec3<i32>, from: Option<Vec2<i32>>)
fn pos_key<P: Into<Vec2<i32>>>(pos: P) -> Vec2<i32>
pub fn key_pos(key: Vec2<i32>) -> Vec2<i32>
sourcepub fn find_region(&self, entity: Entity, pos: Vec3<f32>) -> Option<Vec2<i32>>
pub fn find_region(&self, entity: Entity, pos: Vec3<f32>) -> Option<Vec2<i32>>
Finds the region where a given entity is located using a given position to speed up the search
sourcepub fn in_region_map(&self, entity: Entity) -> bool
pub fn in_region_map(&self, entity: Entity) -> bool
Checks if this entity is located in the RegionMap
.
fn key_index(&self, key: Vec2<i32>) -> Option<usize>
sourcefn insert(&mut self, key: Vec2<i32>) -> usize
fn insert(&mut self, key: Vec2<i32>) -> usize
Adds a new region Returns the index of the region in the index map
sourcefn remove_index(&mut self, index: usize)
fn remove_index(&mut self, index: usize)
Add a region using its key
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RegionMap
impl RefUnwindSafe for RegionMap
impl Send for RegionMap
impl Sync for RegionMap
impl Unpin for RegionMap
impl UnwindSafe for RegionMap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Tries to create the default.
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
Calls
try_default
and panics on an error case.