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) character_being_deleted: Option<CharacterId>,
pub(crate) sites: HashMap<SiteId, SiteInfoRich>,
pub(crate) possible_starting_sites: Vec<SiteId>,
pub(crate) pois: Vec<PoiInfo>,
pub chat_mode: ChatMode,
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
§character_being_deleted: Option<CharacterId>
§sites: HashMap<SiteId, SiteInfoRich>
§possible_starting_sites: Vec<SiteId>
§pois: Vec<PoiInfo>
§chat_mode: ChatMode
§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
impl Client
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>
sourcepub(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>
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
.
pub(crate) fn send_msg_err<S>(&mut self, msg: S) -> Result<(), StreamError>where
S: Into<ClientMsg>,
pub fn request_player_physics(&mut self, server_authoritative: bool)
pub fn request_lossy_terrain_compression( &mut self, lossy_terrain_compression: bool, )
pub(crate) fn send_msg<S>(&mut self, msg: S)where
S: Into<ClientMsg>,
sourcepub fn request_character(
&mut self,
character_id: CharacterId,
view_distances: ViewDistances,
)
pub fn request_character( &mut self, character_id: CharacterId, view_distances: ViewDistances, )
Request a state transition to ClientState::Character
.
sourcepub fn request_spectate(&mut self, view_distances: ViewDistances)
pub fn request_spectate(&mut self, view_distances: ViewDistances)
Request a state transition to ClientState::Spectate
.
sourcepub fn load_character_list(&mut self)
pub fn load_character_list(&mut self)
Load the current players character list
sourcepub fn create_character(
&mut self,
alias: String,
mainhand: Option<String>,
offhand: Option<String>,
body: Body,
hardcore: bool,
start_site: Option<SiteId>,
)
pub fn create_character( &mut self, alias: String, mainhand: Option<String>, offhand: Option<String>, body: Body, hardcore: bool, start_site: Option<SiteId>, )
New character creation
pub fn edit_character(&mut self, alias: String, id: CharacterId, body: Body)
sourcepub fn delete_character(&mut self, character_id: CharacterId)
pub fn delete_character(&mut self, character_id: CharacterId)
Character deletion
sourcepub fn request_remove_character(&mut self)
pub fn request_remove_character(&mut self)
Request a state transition to ClientState::Registered
from an ingame
state.
pub fn set_view_distances(&mut self, view_distances: ViewDistances)
sourcepub(crate) fn set_view_distances_local(
&mut self,
view_distances: ViewDistances,
) -> ViewDistances
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.
pub fn set_lod_distance(&mut self, lod_distance: u32)
pub fn set_flashing_lights_enabled(&mut self, flashing_lights_enabled: bool)
pub fn use_slot(&mut self, slot: Slot)
pub fn swap_slots(&mut self, a: Slot, b: Slot)
pub fn drop_slot(&mut self, slot: Slot)
pub fn sort_inventory(&mut self)
pub fn perform_trade_action(&mut self, action: TradeAction)
pub fn is_dead(&self) -> bool
pub fn is_gliding(&self) -> bool
pub fn split_swap_slots(&mut self, a: Slot, b: Slot)
pub fn split_drop_slot(&mut self, slot: Slot)
pub fn pick_up(&mut self, entity: EcsEntity)
pub fn do_pet(&mut self, target_entity: EcsEntity)
pub fn npc_interact(&mut self, npc_entity: EcsEntity, subject: Subject)
pub fn player_list(&self) -> &HashMap<Uid, PlayerInfo>
pub fn character_list(&self) -> &CharacterList
pub fn server_info(&self) -> &ServerInfo
pub fn server_description(&self) -> &ServerDescription
pub fn world_data(&self) -> &WorldData
pub fn component_recipe_book(&self) -> &ComponentRecipeBook
pub fn repair_recipe_book(&self) -> &RepairRecipeBook
pub fn available_recipes(&self) -> &HashMap<String, Option<SpriteKind>>
pub fn lod_zones(&self) -> &HashMap<Vec2<i32>, Zone>
sourcepub fn set_lod_pos_fallback(&mut self, pos: Vec2<f32>)
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.
pub fn craft_recipe( &mut self, recipe: &str, slots: Vec<(u32, InvSlotId)>, craft_sprite: Option<(VolumePos, SpriteKind)>, amount: u32, ) -> bool
sourcepub fn can_salvage_item(&self, slot: InvSlotId) -> bool
pub fn can_salvage_item(&self, slot: InvSlotId) -> bool
Checks if the item in the given slot can be salvaged.
sourcepub fn salvage_item(&mut self, slot: InvSlotId, salvage_pos: VolumePos) -> bool
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.
sourcepub fn craft_modular_weapon(
&mut self,
primary_component: InvSlotId,
secondary_component: InvSlotId,
sprite_pos: Option<VolumePos>,
) -> bool
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)
pub fn craft_modular_weapon_component( &mut self, toolkind: ToolKind, material: InvSlotId, modifier: Option<InvSlotId>, slots: Vec<(u32, InvSlotId)>, sprite_pos: Option<VolumePos>, )
sourcepub fn repair_item(
&mut self,
item: Slot,
slots: Vec<(u32, InvSlotId)>,
sprite_pos: VolumePos,
) -> bool
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.
pub(crate) fn update_available_recipes(&mut self)
sourcepub fn sites(&self) -> &HashMap<SiteId, SiteInfoRich>
pub fn sites(&self) -> &HashMap<SiteId, SiteInfoRich>
Unstable, likely to be removed in a future release
pub fn possible_starting_sites(&self) -> &[SiteId]
pub fn sites_mut(&mut self) -> &mut HashMap<SiteId, SiteInfoRich>
pub fn enable_lantern(&mut self)
pub fn disable_lantern(&mut self)
pub fn toggle_sprite_light(&mut self, pos: VolumePos, enable: bool)
pub fn remove_buff(&mut self, buff_id: BuffKind)
pub fn leave_stance(&mut self)
pub fn unlock_skill(&mut self, skill: Skill)
pub fn max_group_size(&self) -> u32
pub fn invite(&self) -> Option<(Uid, Instant, Duration, InviteKind)>
pub fn group_info(&self) -> Option<(String, Uid)>
pub fn group_members(&self) -> &HashMap<Uid, Role>
pub fn pending_invites(&self) -> &HashSet<Uid>
pub fn pending_trade( &self, ) -> &Option<(TradeId, PendingTrade, Option<SitePrices>)>
pub fn is_trading(&self) -> bool
pub fn send_invite(&mut self, invitee: Uid, kind: InviteKind)
pub fn accept_invite(&mut self)
pub fn decline_invite(&mut self)
pub fn leave_group(&mut self)
pub fn kick_from_group(&mut self, uid: Uid)
pub fn assign_group_leader(&mut self, uid: Uid)
pub fn is_riding(&self) -> bool
pub fn is_lantern_enabled(&self) -> bool
pub fn mount(&mut self, entity: EcsEntity)
sourcepub fn mount_volume(&mut self, volume_pos: VolumePos)
pub fn mount_volume(&mut self, volume_pos: VolumePos)
Mount a block at a VolumePos
.
pub fn unmount(&mut self)
pub fn set_pet_stay(&mut self, entity: EcsEntity, stay: bool)
pub fn respawn(&mut self)
pub fn map_marker_event(&mut self, event: MapMarkerChange)
sourcepub fn spectate_position(&mut self, pos: Vec3<f32>) -> bool
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.
sourcepub fn swap_loadout(&mut self)
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.
sourcepub fn is_wielding(&self) -> Option<bool>
pub fn is_wielding(&self) -> Option<bool>
Determine whether the player is wielding, if they’re even capable of being in a wield state.
pub fn toggle_wield(&mut self)
pub fn toggle_sit(&mut self)
pub fn toggle_dance(&mut self)
pub fn utter(&mut self, kind: UtteranceKind)
pub fn toggle_sneak(&mut self)
pub fn toggle_glide(&mut self)
pub fn handle_input( &mut self, input: InputKind, pressed: bool, select_pos: Option<Vec3<f32>>, target_entity: Option<EcsEntity>, )
pub fn activate_portal(&mut self, portal: Uid)
pub(crate) fn control_action(&mut self, control_action: ControlAction)
pub fn view_distance(&self) -> Option<u32>
pub fn server_view_distance_limit(&self) -> Option<u32>
pub fn loaded_distance(&self) -> f32
pub fn position(&self) -> Option<Vec3<f32>>
sourcepub fn weather_at_player(&self) -> Weather
pub fn weather_at_player(&self) -> Weather
Returns Weather::default if no player position exists.
pub fn current_chunk(&self) -> Option<Arc<TerrainChunk>>
pub fn current<C>(&self) -> Option<C>where
C: Component + Clone,
pub fn current_biome(&self) -> BiomeKind
pub fn current_site(&self) -> SiteKindMeta
pub fn request_site_economy(&mut self, id: SiteId)
pub fn inventories(&self) -> ReadStorage<'_, Inventory>
sourcepub fn send_command(&mut self, name: String, args: Vec<String>)
pub fn send_command(&mut self, name: String, args: Vec<String>)
Send a command to the server.
sourcepub fn clear_terrain(&mut self)
pub fn clear_terrain(&mut self)
Remove all cached terrain
pub fn place_block(&mut self, pos: Vec3<i32>, block: Block)
pub fn remove_block(&mut self, pos: Vec3<i32>)
pub fn collect_block(&mut self, pos: Vec3<i32>)
pub fn change_ability(&mut self, slot: usize, new_ability: AuxiliaryAbility)
sourcepub fn tick(
&mut self,
inputs: ControllerInputs,
dt: Duration,
) -> Result<Vec<Event>, Error>
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.
sourcepub(crate) fn tick_terrain(&mut self) -> Result<(), Error>
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.
pub(crate) fn handle_server_msg( &mut self, frontend_events: &mut Vec<Event>, msg: ServerGeneral, ) -> Result<(), Error>
pub(crate) fn handle_server_in_game_msg( &mut self, frontend_events: &mut Vec<Event>, msg: ServerGeneral, ) -> Result<(), Error>
pub(crate) fn handle_server_terrain_msg( &mut self, msg: ServerGeneral, ) -> Result<(), Error>
pub(crate) fn handle_server_character_screen_msg( &mut self, events: &mut Vec<Event>, msg: ServerGeneral, ) -> Result<(), Error>
pub(crate) fn handle_ping_msg(&mut self, msg: PingMsg) -> Result<(), Error>
pub(crate) fn handle_messages( &mut self, frontend_events: &mut Vec<Event>, ) -> Result<u64, Error>
sourcepub(crate) fn handle_new_messages(&mut self) -> Result<Vec<Event>, Error>
pub(crate) fn handle_new_messages(&mut self) -> Result<Vec<Event>, Error>
Handle new server messages.
pub fn entity(&self) -> EcsEntity
pub fn uid(&self) -> Option<Uid>
pub fn presence(&self) -> Option<PresenceKind>
pub fn registered(&self) -> bool
pub fn get_tick(&self) -> u64
pub fn get_ping_ms(&self) -> f64
pub fn get_ping_ms_rolling_avg(&self) -> f64
sourcepub fn runtime(&self) -> &Arc<Runtime>
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).
sourcepub fn players(&self) -> impl Iterator<Item = &str>
pub fn players(&self) -> impl Iterator<Item = &str>
Returns an iterator over the aliases of all the online players on the server
sourcepub fn is_moderator(&self) -> bool
pub fn is_moderator(&self) -> bool
Return true if this client is a moderator on the server
sourcepub(crate) fn clean_state(&mut self)
pub(crate) fn clean_state(&mut self)
Clean client ECS state
sourcepub fn personalize_alias(&self, uid: Uid, alias: String) -> String
pub fn personalize_alias(&self, uid: Uid, alias: String) -> String
Change player alias to “You” if client belongs to matching player
sourcepub fn lookup_msg_context(&self, msg: &ChatMsg) -> ChatTypeContext
pub fn lookup_msg_context(&self, msg: &ChatMsg) -> ChatTypeContext
Get important information from client that is necessary for message localisation
sourcepub fn plugin_received(&mut self, hash: PluginHash) -> usize
pub fn plugin_received(&mut self, hash: PluginHash) -> usize
another plugin data received, is this the last one
sourcepub fn are_plugins_missing(&self) -> bool
pub fn are_plugins_missing(&self) -> bool
true if missing_plugins is not empty
sourcepub fn take_local_plugins(&mut self) -> Vec<PathBuf>
pub fn take_local_plugins(&mut self) -> Vec<PathBuf>
extract list of locally cached plugins to load
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
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> 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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§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>
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>
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