diff options
| author | mat <github@matdoes.dev> | 2023-03-11 17:02:57 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2023-03-11 17:02:57 -0600 |
| commit | cd0a1ed8d4c7670eb58d33f521026e760798e1a5 (patch) | |
| tree | 5b47c3ab6ffa3cd2b87b26a24bfb854a53885fc4 /azalea-world/src | |
| parent | 40a0c8acfbfb88be791c295a14014468e2fd4298 (diff) | |
| download | azalea-drasl-cd0a1ed8d4c7670eb58d33f521026e760798e1a5.tar.xz | |
fix doc errors
Diffstat (limited to 'azalea-world/src')
| -rw-r--r-- | azalea-world/src/container.rs | 10 | ||||
| -rw-r--r-- | azalea-world/src/entity/info.rs | 14 | ||||
| -rw-r--r-- | azalea-world/src/world.rs | 28 |
3 files changed, 26 insertions, 26 deletions
diff --git a/azalea-world/src/container.rs b/azalea-world/src/container.rs index fdd89a75..c8af8c99 100644 --- a/azalea-world/src/container.rs +++ b/azalea-world/src/container.rs @@ -10,10 +10,10 @@ use std::{ use crate::{ChunkStorage, Instance}; -/// A container of [`World`]s. Worlds are stored as a Weak pointer here, so -/// if no clients are using a world it will be forgotten. +/// A container of [`Instance`]s (aka worlds). Instances are stored as a Weak +/// pointer here, so if no clients are using an instance it will be forgotten. #[derive(Default, Resource)] -pub struct WorldContainer { +pub struct InstanceContainer { // We just refer to the chunks here and don't include entities because there's not that many // cases where we'd want to get every entity in the world (just getting the entities in chunks // should work fine). @@ -29,9 +29,9 @@ pub struct WorldContainer { pub worlds: HashMap<ResourceLocation, Weak<RwLock<Instance>>>, } -impl WorldContainer { +impl InstanceContainer { pub fn new() -> Self { - WorldContainer { + InstanceContainer { worlds: HashMap::new(), } } diff --git a/azalea-world/src/entity/info.rs b/azalea-world/src/entity/info.rs index 19e87627..fdfe82c2 100644 --- a/azalea-world/src/entity/info.rs +++ b/azalea-world/src/entity/info.rs @@ -6,7 +6,7 @@ use crate::{ entity::{ self, add_dead, update_bounding_box, EntityUuid, MinecraftEntityId, Position, WorldName, }, - update_entity_by_id_index, update_uuid_index, PartialWorld, WorldContainer, + update_entity_by_id_index, update_uuid_index, InstanceContainer, PartialInstance, }; use azalea_core::ChunkPos; use bevy_app::{App, CoreSet, Plugin}; @@ -134,9 +134,9 @@ impl PartialEntityInfos { } } -/// A [`Command`] that applies a "relative update" to an entity, which means -/// this update won't be run multiple times by different clients in the same -/// world. +/// An [`EntityCommand`] that applies a "relative update" to an entity, which +/// means this update won't be run multiple times by different clients in the +/// same world. /// /// This is used to avoid a bug where when there's multiple clients in the same /// world and an entity sends a relative move packet to all clients, its @@ -146,7 +146,7 @@ impl PartialEntityInfos { /// other clients within render distance will get too. You usually don't need /// this when the change isn't relative either. pub struct RelativeEntityUpdate { - pub partial_world: Arc<RwLock<PartialWorld>>, + pub partial_world: Arc<RwLock<PartialInstance>>, // a function that takes the entity and updates it pub update: Box<dyn FnOnce(&mut EntityMut) + Send + Sync>, } @@ -218,7 +218,7 @@ fn update_entity_chunk_positions( ), Changed<entity::Position>, >, - world_container: Res<WorldContainer>, + world_container: Res<InstanceContainer>, ) { for (entity, pos, last_pos, world_name) in query.iter_mut() { let world_lock = world_container.get(world_name).unwrap(); @@ -285,7 +285,7 @@ fn debug_detect_updates_received_on_local_entities( fn remove_despawned_entities_from_indexes( mut commands: Commands, mut entity_infos: ResMut<EntityInfos>, - world_container: Res<WorldContainer>, + world_container: Res<InstanceContainer>, query: Query<(Entity, &EntityUuid, &Position, &WorldName, &LoadedBy), Changed<LoadedBy>>, ) { for (entity, uuid, position, world_name, loaded_by) in &query { diff --git a/azalea-world/src/world.rs b/azalea-world/src/world.rs index 7da9b869..e8d25032 100644 --- a/azalea-world/src/world.rs +++ b/azalea-world/src/world.rs @@ -4,7 +4,7 @@ use crate::{ }, iterators::ChunkIterator, palette::Palette, - ChunkStorage, PartialChunkStorage, WorldContainer, + ChunkStorage, InstanceContainer, PartialChunkStorage, }; use azalea_block::{BlockState, BlockStates}; use azalea_core::{BlockPos, ChunkPos}; @@ -21,24 +21,24 @@ use std::{ fmt::Debug, }; -/// PartialWorlds are usually owned by clients, and hold strong references to -/// chunks and entities in [`World`]s. +/// PartialInstances are usually owned by clients, and hold strong references to +/// chunks and entities in [`Instance`]s. /// /// Basically, they hold the chunks and entities that are within render /// distance but can still access chunks and entities owned by other -/// `PartialWorld`s that have the same `World`. +/// `PartialInstance`s that have the same `Instance`. /// -/// This is primarily useful for having multiple clients in the same world. -pub struct PartialWorld { +/// This is primarily useful for having multiple clients in the same Instance. +pub struct PartialInstance { pub chunks: PartialChunkStorage, /// Some metadata about entities, like what entities are in certain chunks. /// This does not contain the entity data itself, that's in the ECS. pub entity_infos: PartialEntityInfos, } -impl PartialWorld { +impl PartialInstance { pub fn new(chunk_radius: u32, owner_entity: Option<Entity>) -> Self { - PartialWorld { + PartialInstance { chunks: PartialChunkStorage::new(chunk_radius), entity_infos: PartialEntityInfos::new(owner_entity), } @@ -59,7 +59,7 @@ pub fn deduplicate_entities( (Changed<MinecraftEntityId>, Without<Local>), >, mut loaded_by_query: Query<&mut LoadedBy>, - world_container: Res<WorldContainer>, + world_container: Res<InstanceContainer>, ) { // if this entity already exists, remove it for (new_entity, id, world_name) in query.iter_mut() { @@ -104,7 +104,7 @@ pub fn deduplicate_local_entities( (Entity, &MinecraftEntityId, &WorldName), (Changed<MinecraftEntityId>, With<Local>), >, - world_container: Res<WorldContainer>, + world_container: Res<InstanceContainer>, ) { // if this entity already exists, remove the old one for (new_entity, id, world_name) in query.iter_mut() { @@ -262,7 +262,7 @@ impl Instance { } } -impl Debug for PartialWorld { +impl Debug for PartialInstance { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("World") .field("chunk_storage", &self.chunks) @@ -271,8 +271,8 @@ impl Debug for PartialWorld { } } -impl Default for PartialWorld { - /// Creates a completely self-contained `PartialWorld`. This is only for +impl Default for PartialInstance { + /// Creates a completely self-contained `PartialInstance`. This is only for /// testing and shouldn't be used in actual code! fn default() -> Self { let chunk_storage = PartialChunkStorage::default(); @@ -290,7 +290,7 @@ pub fn update_entity_by_id_index( (Entity, &MinecraftEntityId, &WorldName, Option<&Local>), Changed<MinecraftEntityId>, >, - world_container: Res<WorldContainer>, + world_container: Res<InstanceContainer>, ) { for (entity, id, world_name, local) in query.iter_mut() { let world_lock = world_container.get(world_name).unwrap(); |
