Struct veloren_client::Client

source ·
pub struct Client {
Show 53 fields pub(crate) registered: bool, pub(crate) presence: Option<PresenceKind>, pub(crate) runtime: Arc<Runtime>, pub(crate) server_info: ServerInfo, pub(crate) server_description: ServerDescription, pub(crate) world_data: WorldData, pub(crate) weather: WeatherLerp, pub(crate) player_list: HashMap<Uid, PlayerInfo>, pub(crate) character_list: CharacterList, pub(crate) sites: HashMap<SiteId, SiteInfoRich>, pub(crate) possible_starting_sites: Vec<SiteId>, pub(crate) pois: Vec<PoiInfo>, pub chat_mode: ChatMode, pub(crate) recipe_book: RecipeBook, pub(crate) component_recipe_book: ComponentRecipeBook, pub(crate) repair_recipe_book: RepairRecipeBook, pub(crate) available_recipes: HashMap<String, Option<SpriteKind>>, pub(crate) lod_zones: HashMap<Vec2<i32>, Zone>, pub(crate) lod_last_requested: Option<Instant>, pub(crate) lod_pos_fallback: Option<Vec2<f32>>, pub(crate) force_update_counter: u64, pub(crate) max_group_size: u32, pub(crate) invite: Option<(Uid, Instant, Duration, InviteKind)>, pub(crate) group_leader: Option<Uid>, pub(crate) group_members: HashMap<Uid, Role>, pub(crate) pending_invites: HashSet<Uid>, pub(crate) pending_trade: Option<(TradeId, PendingTrade, Option<SitePrices>)>, pub(crate) network: Option<Network>, pub(crate) participant: Option<Participant>, pub(crate) general_stream: Stream, pub(crate) ping_stream: Stream, pub(crate) register_stream: Stream, pub(crate) character_screen_stream: Stream, pub(crate) in_game_stream: Stream, pub(crate) terrain_stream: Stream, pub(crate) client_timeout: Duration, pub(crate) last_server_ping: f64, pub(crate) last_server_pong: f64, pub(crate) last_ping_delta: f64, pub(crate) ping_deltas: VecDeque<f64>, pub(crate) tick: u64, pub(crate) state: State, pub(crate) flashing_lights_enabled: bool, pub(crate) server_view_distance_limit: Option<u32>, pub(crate) view_distance: Option<u32>, pub(crate) lod_distance: f32, pub(crate) loaded_distance: f32, pub(crate) pending_chunks: HashMap<Vec2<i32>, Instant>, pub(crate) target_time_of_day: Option<TimeOfDay>, pub(crate) dt_adjustment: f64, pub(crate) connected_server_constants: ServerConstants, pub(crate) missing_plugins: HashSet<PluginHash>, pub(crate) local_plugins: Vec<PathBuf>,
}

Fields§

§registered: bool§presence: Option<PresenceKind>§runtime: Arc<Runtime>§server_info: ServerInfo§server_description: ServerDescription

Localized server motd and rules

§world_data: WorldData§weather: WeatherLerp§player_list: HashMap<Uid, PlayerInfo>§character_list: CharacterList§sites: HashMap<SiteId, SiteInfoRich>§possible_starting_sites: Vec<SiteId>§pois: Vec<PoiInfo>§chat_mode: ChatMode§recipe_book: RecipeBook§component_recipe_book: ComponentRecipeBook§repair_recipe_book: RepairRecipeBook§available_recipes: HashMap<String, Option<SpriteKind>>§lod_zones: HashMap<Vec2<i32>, Zone>§lod_last_requested: Option<Instant>§lod_pos_fallback: Option<Vec2<f32>>§force_update_counter: u64§max_group_size: u32§invite: Option<(Uid, Instant, Duration, InviteKind)>§group_leader: Option<Uid>§group_members: HashMap<Uid, Role>§pending_invites: HashSet<Uid>§pending_trade: Option<(TradeId, PendingTrade, Option<SitePrices>)>§network: Option<Network>§participant: Option<Participant>§general_stream: Stream§ping_stream: Stream§register_stream: Stream§character_screen_stream: Stream§in_game_stream: Stream§terrain_stream: Stream§client_timeout: Duration§last_server_ping: f64§last_server_pong: f64§last_ping_delta: f64§ping_deltas: VecDeque<f64>§tick: u64§state: State§flashing_lights_enabled: bool§server_view_distance_limit: Option<u32>

Terrrain view distance

§view_distance: Option<u32>§lod_distance: f32§loaded_distance: f32§pending_chunks: HashMap<Vec2<i32>, Instant>§target_time_of_day: Option<TimeOfDay>§dt_adjustment: f64§connected_server_constants: ServerConstants§missing_plugins: HashSet<PluginHash>

Requested but not yet received plugins

§local_plugins: Vec<PathBuf>

Locally cached plugins needed by the server

Implementations§

source§

impl Client

source

pub async fn new( addr: ConnectionArgs, runtime: Arc<Runtime>, mismatched_server_info: &mut Option<ServerInfo>, username: &str, password: &str, locale: Option<String>, auth_trusted: impl FnMut(&str) -> bool, init_stage_update: &(dyn Fn(ClientInitStage) + Send + Sync), add_foreign_systems: impl Fn(&mut DispatcherBuilder<'_, '_>) + Send + 'static, config_dir: PathBuf ) -> Result<Self, Error>

source

pub(crate) async fn register( username: &str, password: &str, locale: Option<String>, auth_trusted: impl FnMut(&str) -> bool, server_info: &ServerInfo, register_stream: &mut Stream ) -> Result<(), Error>

Request a state transition to ClientState::Registered.

source

pub(crate) fn send_msg_err<S>(&mut self, msg: S) -> Result<(), StreamError>
where S: Into<ClientMsg>,

source

pub fn request_player_physics(&mut self, server_authoritative: bool)

source

pub fn request_lossy_terrain_compression( &mut self, lossy_terrain_compression: bool )

source

pub(crate) fn send_msg<S>(&mut self, msg: S)
where S: Into<ClientMsg>,

source

pub fn request_character( &mut self, character_id: CharacterId, view_distances: ViewDistances )

Request a state transition to ClientState::Character.

source

pub fn request_spectate(&mut self, view_distances: ViewDistances)

Request a state transition to ClientState::Spectate.

source

pub fn load_character_list(&mut self)

Load the current players character list

source

pub fn create_character( &mut self, alias: String, mainhand: Option<String>, offhand: Option<String>, body: Body, start_site: Option<SiteId> )

New character creation

source

pub fn edit_character(&mut self, alias: String, id: CharacterId, body: Body)

source

pub fn delete_character(&mut self, character_id: CharacterId)

Character deletion

source

pub fn logout(&mut self)

Send disconnect message to the server

source

pub fn request_remove_character(&mut self)

Request a state transition to ClientState::Registered from an ingame state.

source

pub fn set_view_distances(&mut self, view_distances: ViewDistances)

source

pub(crate) fn set_view_distances_local( &mut self, view_distances: ViewDistances ) -> ViewDistances

Clamps provided view distances, locally sets the terrain view distance in the client’s properties and returns the clamped values for the caller to send to the server.

source

pub fn set_lod_distance(&mut self, lod_distance: u32)

source

pub fn set_flashing_lights_enabled(&mut self, flashing_lights_enabled: bool)

source

pub fn use_slot(&mut self, slot: Slot)

source

pub fn swap_slots(&mut self, a: Slot, b: Slot)

source

pub fn drop_slot(&mut self, slot: Slot)

source

pub fn sort_inventory(&mut self)

source

pub fn perform_trade_action(&mut self, action: TradeAction)

source

pub fn is_dead(&self) -> bool

source

pub fn is_gliding(&self) -> bool

source

pub fn split_swap_slots(&mut self, a: Slot, b: Slot)

source

pub fn split_drop_slot(&mut self, slot: Slot)

source

pub fn pick_up(&mut self, entity: EcsEntity)

source

pub fn do_pet(&mut self, target_entity: EcsEntity)

source

pub fn npc_interact(&mut self, npc_entity: EcsEntity, subject: Subject)

source

pub fn player_list(&self) -> &HashMap<Uid, PlayerInfo>

source

pub fn character_list(&self) -> &CharacterList

source

pub fn server_info(&self) -> &ServerInfo

source

pub fn server_description(&self) -> &ServerDescription

source

pub fn world_data(&self) -> &WorldData

source

pub fn recipe_book(&self) -> &RecipeBook

source

pub fn component_recipe_book(&self) -> &ComponentRecipeBook

source

pub fn repair_recipe_book(&self) -> &RepairRecipeBook

source

pub fn available_recipes(&self) -> &HashMap<String, Option<SpriteKind>>

source

pub fn lod_zones(&self) -> &HashMap<Vec2<i32>, Zone>

source

pub fn set_lod_pos_fallback(&mut self, pos: Vec2<f32>)

Set the fallback position used for loading LoD zones when the client entity does not have a position.

source

pub fn can_craft_recipe( &self, recipe: &str, amount: u32 ) -> (bool, Option<SpriteKind>)

Returns whether the specified recipe can be crafted and the sprite, if any, that is required to do so.

source

pub fn craft_recipe( &mut self, recipe: &str, slots: Vec<(u32, InvSlotId)>, craft_sprite: Option<(VolumePos, SpriteKind)>, amount: u32 ) -> bool

source

pub fn can_salvage_item(&self, slot: InvSlotId) -> bool

Checks if the item in the given slot can be salvaged.

source

pub fn salvage_item(&mut self, slot: InvSlotId, salvage_pos: VolumePos) -> bool

Salvage the item in the given inventory slot. salvage_pos should be the location of a relevant crafting station within range of the player.

source

pub fn craft_modular_weapon( &mut self, primary_component: InvSlotId, secondary_component: InvSlotId, sprite_pos: Option<VolumePos> ) -> bool

Crafts modular weapon from components in the provided slots. sprite_pos should be the location of the necessary crafting station in range of the player. Returns whether or not the networking event was sent (which is based on whether the player has two modular components in the provided slots)

source

pub fn craft_modular_weapon_component( &mut self, toolkind: ToolKind, material: InvSlotId, modifier: Option<InvSlotId>, slots: Vec<(u32, InvSlotId)>, sprite_pos: Option<VolumePos> )

source

pub fn repair_item( &mut self, item: Slot, slots: Vec<(u32, InvSlotId)>, sprite_pos: VolumePos ) -> bool

Repairs the item in the given inventory slot. sprite_pos should be the location of a relevant crafting station within range of the player.

source

pub(crate) fn update_available_recipes(&mut self)

source

pub fn sites(&self) -> &HashMap<SiteId, SiteInfoRich>

Unstable, likely to be removed in a future release

source

pub fn possible_starting_sites(&self) -> &[SiteId]

source

pub fn pois(&self) -> &Vec<PoiInfo>

Unstable, likely to be removed in a future release

source

pub fn sites_mut(&mut self) -> &mut HashMap<SiteId, SiteInfoRich>

source

pub fn enable_lantern(&mut self)

source

pub fn disable_lantern(&mut self)

source

pub fn toggle_sprite_light(&mut self, pos: VolumePos, enable: bool)

source

pub fn remove_buff(&mut self, buff_id: BuffKind)

source

pub fn leave_stance(&mut self)

source

pub fn unlock_skill(&mut self, skill: Skill)

source

pub fn max_group_size(&self) -> u32

source

pub fn invite(&self) -> Option<(Uid, Instant, Duration, InviteKind)>

source

pub fn group_info(&self) -> Option<(String, Uid)>

source

pub fn group_members(&self) -> &HashMap<Uid, Role>

source

pub fn pending_invites(&self) -> &HashSet<Uid>

source

pub fn pending_trade( &self ) -> &Option<(TradeId, PendingTrade, Option<SitePrices>)>

source

pub fn is_trading(&self) -> bool

source

pub fn send_invite(&mut self, invitee: Uid, kind: InviteKind)

source

pub fn accept_invite(&mut self)

source

pub fn decline_invite(&mut self)

source

pub fn leave_group(&mut self)

source

pub fn kick_from_group(&mut self, uid: Uid)

source

pub fn assign_group_leader(&mut self, uid: Uid)

source

pub fn is_riding(&self) -> bool

source

pub fn is_lantern_enabled(&self) -> bool

source

pub fn mount(&mut self, entity: EcsEntity)

source

pub fn mount_volume(&mut self, volume_pos: VolumePos)

Mount a block at a VolumePos.

source

pub fn unmount(&mut self)

source

pub fn set_pet_stay(&mut self, entity: EcsEntity, stay: bool)

source

pub fn respawn(&mut self)

source

pub fn map_marker_event(&mut self, event: MapMarkerChange)

source

pub fn spectate_position(&mut self, pos: Vec3<f32>) -> bool

Set the current position to spectate, returns true if the client’s player has a Pos component to write to.

source

pub fn swap_loadout(&mut self)

Checks whether a player can swap their weapon+ability Loadout settings and sends the ControlAction event that signals to do the swap.

source

pub fn is_wielding(&self) -> Option<bool>

Determine whether the player is wielding, if they’re even capable of being in a wield state.

source

pub fn toggle_wield(&mut self)

source

pub fn toggle_sit(&mut self)

source

pub fn toggle_dance(&mut self)

source

pub fn utter(&mut self, kind: UtteranceKind)

source

pub fn toggle_sneak(&mut self)

source

pub fn toggle_glide(&mut self)

source

pub fn handle_input( &mut self, input: InputKind, pressed: bool, select_pos: Option<Vec3<f32>>, target_entity: Option<EcsEntity> )

source

pub fn activate_portal(&mut self, portal: Uid)

source

pub(crate) fn control_action(&mut self, control_action: ControlAction)

source

pub fn view_distance(&self) -> Option<u32>

source

pub fn server_view_distance_limit(&self) -> Option<u32>

source

pub fn loaded_distance(&self) -> f32

source

pub fn position(&self) -> Option<Vec3<f32>>

source

pub fn weather_at_player(&self) -> Weather

Returns Weather::default if no player position exists.

source

pub fn current_chunk(&self) -> Option<Arc<TerrainChunk>>

source

pub fn current<C>(&self) -> Option<C>
where C: Clone + Component,

source

pub fn current_biome(&self) -> BiomeKind

source

pub fn current_site(&self) -> SiteKindMeta

source

pub fn request_site_economy(&mut self, id: SiteId)

source

pub fn inventories(&self) -> ReadStorage<'_, Inventory>

source

pub fn send_chat(&mut self, message: String)

Send a chat message to the server.

source

pub fn send_command(&mut self, name: String, args: Vec<String>)

Send a command to the server.

source

pub fn clear_terrain(&mut self)

Remove all cached terrain

source

pub fn place_block(&mut self, pos: Vec3<i32>, block: Block)

source

pub fn remove_block(&mut self, pos: Vec3<i32>)

source

pub fn collect_block(&mut self, pos: Vec3<i32>)

source

pub fn change_ability(&mut self, slot: usize, new_ability: AuxiliaryAbility)

source

pub fn tick( &mut self, inputs: ControllerInputs, dt: Duration ) -> Result<Vec<Event>, Error>

Execute a single client tick, handle input and update the game state by the given duration.

source

pub fn cleanup(&mut self)

Clean up the client after a tick.

source

pub(crate) fn tick_terrain(&mut self) -> Result<(), Error>

Handles terrain addition and removal.

Removes old terrain chunks outside the view distance. Sends requests for missing chunks within the view distance.

source

pub(crate) fn handle_server_msg( &mut self, frontend_events: &mut Vec<Event>, msg: ServerGeneral ) -> Result<(), Error>

source

pub(crate) fn handle_server_in_game_msg( &mut self, frontend_events: &mut Vec<Event>, msg: ServerGeneral ) -> Result<(), Error>

source

pub(crate) fn handle_server_terrain_msg( &mut self, msg: ServerGeneral ) -> Result<(), Error>

source

pub(crate) fn handle_server_character_screen_msg( &mut self, events: &mut Vec<Event>, msg: ServerGeneral ) -> Result<(), Error>

source

pub(crate) fn handle_ping_msg(&mut self, msg: PingMsg) -> Result<(), Error>

source

pub(crate) fn handle_messages( &mut self, frontend_events: &mut Vec<Event> ) -> Result<u64, Error>

source

pub(crate) fn handle_new_messages(&mut self) -> Result<Vec<Event>, Error>

Handle new server messages.

source

pub fn entity(&self) -> EcsEntity

source

pub fn uid(&self) -> Option<Uid>

source

pub fn presence(&self) -> Option<PresenceKind>

source

pub fn registered(&self) -> bool

source

pub fn get_tick(&self) -> u64

source

pub fn get_ping_ms(&self) -> f64

source

pub fn get_ping_ms_rolling_avg(&self) -> f64

source

pub fn runtime(&self) -> &Arc<Runtime>

Get a reference to the client’s runtime thread pool. This pool should be used for any computationally expensive operations that run outside of the main thread (i.e., threads that block on I/O operations are exempt).

source

pub fn state(&self) -> &State

Get a reference to the client’s game state.

source

pub fn state_mut(&mut self) -> &mut State

Get a mutable reference to the client’s game state.

source

pub fn players(&self) -> impl Iterator<Item = &str>

Returns an iterator over the aliases of all the online players on the server

source

pub fn is_moderator(&self) -> bool

Return true if this client is a moderator on the server

source

pub(crate) fn clean_state(&mut self)

Clean client ECS state

source

pub fn personalize_alias(&self, uid: Uid, alias: String) -> String

Change player alias to “You” if client belongs to matching player

source

pub fn lookup_msg_context(&self, msg: &ChatMsg) -> ChatTypeContext

Get important information from client that is necessary for message localisation

source

pub fn plugin_received(&mut self, hash: PluginHash) -> usize

another plugin data received, is this the last one

source

pub fn num_missing_plugins(&self) -> usize

number of requested plugins

source

pub fn take_local_plugins(&mut self) -> Vec<PathBuf>

extract list of locally cached plugins to load

Trait Implementations§

source§

impl Drop for Client

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl !Sync for Client

§

impl !Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> GetSetFdFlags for T

§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<Context> SubContext<Context> for Context

§

fn sub_context(self) -> Context

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more