Trait valence::Layer

source ·
pub trait Layer: WritePacket {
    type ExceptWriter<'a>: WritePacket
       where Self: 'a;
    type ViewWriter<'a>: WritePacket
       where Self: 'a;
    type ViewExceptWriter<'a>: WritePacket
       where Self: 'a;
    type RadiusWriter<'a>: WritePacket
       where Self: 'a;
    type RadiusExceptWriter<'a>: WritePacket
       where Self: 'a;

    // Required methods
    fn except_writer(&mut self, except: Entity) -> Self::ExceptWriter<'_>;
    fn view_writer(&mut self, pos: impl Into<ChunkPos>) -> Self::ViewWriter<'_>;
    fn view_except_writer(
        &mut self,
        pos: impl Into<ChunkPos>,
        except: Entity,
    ) -> Self::ViewExceptWriter<'_>;
    fn radius_writer(
        &mut self,
        pos: impl Into<BlockPos>,
        radius: u32,
    ) -> Self::RadiusWriter<'_>;
    fn radius_except_writer(
        &mut self,
        pos: impl Into<BlockPos>,
        radius: u32,
        except: Entity,
    ) -> Self::RadiusExceptWriter<'_>;
}
Expand description

Common functionality for layers. Notable implementors are ChunkLayer and EntityLayer.

Layers support sending packets to viewers of the layer under various conditions. These are the “packet writers” exposed by this trait.

Layers themselves implement the WritePacket trait. Writing directly to a layer will send packets to all viewers unconditionally.

Required Associated Types§

source

type ExceptWriter<'a>: WritePacket where Self: 'a

Packet writer returned by except_writer.

source

type ViewWriter<'a>: WritePacket where Self: 'a

Packet writer returned by view_writer.

source

type ViewExceptWriter<'a>: WritePacket where Self: 'a

Packet writer returned by view_except_writer.

source

type RadiusWriter<'a>: WritePacket where Self: 'a

Packet writer returned by radius_writer.

source

type RadiusExceptWriter<'a>: WritePacket where Self: 'a

Packet writer returned by radius_except_writer.

Required Methods§

source

fn except_writer(&mut self, except: Entity) -> Self::ExceptWriter<'_>

Returns a packet writer which sends packets to all viewers not identified by except.

source

fn view_writer(&mut self, pos: impl Into<ChunkPos>) -> Self::ViewWriter<'_>

Returns a packet writer which sends packets to viewers in view of the chunk position pos.

source

fn view_except_writer( &mut self, pos: impl Into<ChunkPos>, except: Entity, ) -> Self::ViewExceptWriter<'_>

Returns a packet writer which sends packets to viewers in view of the chunk position pos and not identified by except.

source

fn radius_writer( &mut self, pos: impl Into<BlockPos>, radius: u32, ) -> Self::RadiusWriter<'_>

Returns a packet writer which sends packets to viewers within radius blocks of the block position pos.

source

fn radius_except_writer( &mut self, pos: impl Into<BlockPos>, radius: u32, except: Entity, ) -> Self::RadiusExceptWriter<'_>

Returns a packet writer which sends packets to viewers within radius blocks of the block position pos and not identified by except.

Object Safety§

This trait is not object safe.

Implementors§