pub struct RelevancyFilter { /* private fields */ }Expand description
Per-client relevancy filter that determines which entities should be sent and at what priority/frequency.
Implementations§
Source§impl RelevancyFilter
impl RelevancyFilter
pub fn new(client_id: ClientId, region: RelevancyRegion) -> Self
pub fn client_id(&self) -> ClientId
pub fn set_region(&mut self, region: RelevancyRegion)
pub fn region(&self) -> &RelevancyRegion
pub fn set_max_entities(&mut self, max: usize)
pub fn set_bandwidth_budget(&mut self, bytes: usize)
pub fn add_always_relevant(&mut self, id: NetEntityId)
pub fn remove_always_relevant(&mut self, id: NetEntityId)
pub fn add_never_relevant(&mut self, id: NetEntityId)
pub fn remove_never_relevant(&mut self, id: NetEntityId)
pub fn set_component_priority_bias(&mut self, component_type: u16, bias: f32)
Sourcepub fn update(&mut self, snapshot: &WorldSnapshot, tick: u64)
pub fn update(&mut self, snapshot: &WorldSnapshot, tick: u64)
Update the filter with a new world snapshot. Recomputes relevancy for all entities.
Sourcepub fn select_entities(&mut self, snapshot: &WorldSnapshot) -> Vec<NetEntityId>
pub fn select_entities(&mut self, snapshot: &WorldSnapshot) -> Vec<NetEntityId>
Get entities that should be included in the next update, sorted by accumulated priority (highest first), limited by bandwidth and count.
Sourcepub fn filter_snapshot(&mut self, snapshot: &WorldSnapshot) -> WorldSnapshot
pub fn filter_snapshot(&mut self, snapshot: &WorldSnapshot) -> WorldSnapshot
Create a filtered world snapshot containing only relevant entities for this client.
Sourcepub fn get_entry(&self, id: NetEntityId) -> Option<&RelevancyEntry>
pub fn get_entry(&self, id: NetEntityId) -> Option<&RelevancyEntry>
Get the current relevancy entry for an entity.
Sourcepub fn tracked_count(&self) -> usize
pub fn tracked_count(&self) -> usize
Number of entities currently tracked.
Sourcepub fn relevant_count(&self) -> usize
pub fn relevant_count(&self) -> usize
Number of entities currently considered relevant.
Sourcepub fn reset_priorities(&mut self)
pub fn reset_priorities(&mut self)
Reset accumulated priorities for all entries.
Auto Trait Implementations§
impl Freeze for RelevancyFilter
impl RefUnwindSafe for RelevancyFilter
impl Send for RelevancyFilter
impl Sync for RelevancyFilter
impl Unpin for RelevancyFilter
impl UnsafeUnpin for RelevancyFilter
impl UnwindSafe for RelevancyFilter
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.