diff --git a/quill/api/src/entities.rs b/quill/api/src/entities.rs index ec0cf6126..131cbaa20 100644 --- a/quill/api/src/entities.rs +++ b/quill/api/src/entities.rs @@ -1,11 +1,26 @@ //! Defines components for all Minecraft entities. //! +//! # Entity wrappers +//! In an ECS, components provide access to raw _data_, +//! like an entity's position, health, inventory, etc. +//! But components don't have to abstract high-level +//! methods that need access to multiple components. For example, +//! "deal damage" requires access to `Health` and `Inventory` (to handle armor), +//! and possibly potion effects. +//! +//! To solve this problem, Quill provides entity _wrappers_ that provide +//! these high-level methods. Each entity has a wrapper struct +//! that implements a series of traits. For example, the `Player` wrapper +//! struct provides the `send_message` function via the `SendMessage` trait. +//! Similarly, the `DealDamage` trait provides the `damage()` method +//! for entities with health. +//! //! # Marker components //! Each entity has a "marker component": //! just a struct (often with no fields) //! that signifies the type of an entity. //! -//! For example, all horse entities have the [`Horse`] +//! For example, all horse entities have the [`HorseMarker`] //! marker component. //! //! For certain entities, these components also diff --git a/quill/api/src/game.rs b/quill/api/src/game.rs index 4fcfe058c..6af6230f2 100644 --- a/quill/api/src/game.rs +++ b/quill/api/src/game.rs @@ -5,11 +5,9 @@ use libcraft_core::{BlockPosition, ChunkPosition, Position, CHUNK_HEIGHT}; use libcraft_particles::Particle; use quill_common::entity_init::EntityInit; -use crate::{ - query::{Query, QueryIter}, - EntityBuilder, -}; +use crate::{query::QueryIter, EntityBuilder}; use crate::{Entity, EntityId}; +use quill_common::entity::FromQuery; /// Error returned when getting or setting a block fails. #[derive(Debug, thiserror::Error)] @@ -109,7 +107,16 @@ impl Game { /// println!("Found an entity with position {:?} and UUID {}", position, uuid); /// } /// ``` - pub fn query(&self) -> QueryIter { + /// + /// Iterate over all player entities, and send them messages: + /// ```no_run + /// use quill::entities::Player; + /// # let game: quill::Game = unimplemented!(); + /// for (_entity, player) in game.query::() { + /// player.send_message("Hello world"); + /// } + /// ``` + pub fn query(&self) -> QueryIter { QueryIter::new() } diff --git a/quill/api/src/query.rs b/quill/api/src/query.rs index 64da4919e..b4ff9dfb5 100644 --- a/quill/api/src/query.rs +++ b/quill/api/src/query.rs @@ -2,100 +2,13 @@ use std::{marker::PhantomData, mem::MaybeUninit}; -use quill_common::{entity::QueryData, Component, HostComponent, PointerMut}; +use quill_common::{ + entity::{FromQuery, QueryData}, + PointerMut, +}; use crate::{Entity, EntityId}; -/// A type that can be used for a query. -/// -/// Implemented for tuples of `Query`s as well. -pub trait Query { - type Item; - - fn add_component_types(types: &mut Vec); - - /// # Safety - /// `component_index` must be a valid index less - /// than the number of entities in the query data. - /// - /// `component_offsets` must contain the proper byte offset - /// of the current component index. - unsafe fn get_unchecked( - data: &QueryData, - component_index: &mut usize, - component_offsets: &mut [usize], - ) -> Self::Item; -} - -impl<'a, T> Query for &'a T -where - T: Component, - [T]: ToOwned, -{ - type Item = T; - - fn add_component_types(types: &mut Vec) { - types.push(T::host_component()); - } - - unsafe fn get_unchecked( - data: &QueryData, - component_index: &mut usize, - component_offsets: &mut [usize], - ) -> T { - let component_len = *((data.component_lens.as_mut_ptr()).add(*component_index)) as usize; - let component_ptr = - (*(data.component_ptrs.as_mut_ptr().add(*component_index))).as_mut_ptr(); - - let offset = component_offsets[*component_index]; - let component_ptr = component_ptr.add(offset); - let component_len = component_len - offset; - - let component_bytes = std::slice::from_raw_parts(component_ptr, component_len); - let (value, advance) = T::from_bytes_unchecked(component_bytes); - - component_offsets[*component_index] += advance; - - *component_index += 1; - - value - } -} - -macro_rules! impl_query_tuple { - ($($query:ident),* $(,)?) => { - impl <$($query: Query),*> Query for ($($query,)*) { - type Item = ($($query::Item),*); - fn add_component_types(types: &mut Vec) { - $( - $query::add_component_types(types); - )* - } - - unsafe fn get_unchecked(data: &QueryData, component_index: &mut usize, component_offsets: &mut [usize]) -> Self::Item { - ( - $( - $query::get_unchecked(data, component_index, component_offsets) - ),* - ) - } - } - } -} - -impl_query_tuple!(A, B); -impl_query_tuple!(A, B, C); -impl_query_tuple!(A, B, C, D); -impl_query_tuple!(A, B, C, D, E); -impl_query_tuple!(A, B, C, D, E, F); -impl_query_tuple!(A, B, C, D, E, F, G); -impl_query_tuple!(A, B, C, D, E, F, G, H); -impl_query_tuple!(A, B, C, D, E, F, G, H, I); -impl_query_tuple!(A, B, C, D, E, F, G, H, I, J); -impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K); -impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K, L); -impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K, L, M); - /// An iterator over all entities matching a query. pub struct QueryIter { data: QueryData, @@ -106,7 +19,7 @@ pub struct QueryIter { impl QueryIter where - Q: Query, + Q: FromQuery, { pub(crate) fn new() -> Self { let mut component_types = Vec::new(); @@ -136,7 +49,7 @@ where impl Iterator for QueryIter where - Q: Query, + Q: FromQuery, { type Item = (Entity, Q::Item); @@ -145,16 +58,19 @@ where return None; } + let entity_id = + EntityId(unsafe { *(self.data.entities_ptr.as_mut_ptr()).add(self.entity_index) }); + let entity = Entity::new(entity_id); + let components = unsafe { let mut component_index = 0; Q::get_unchecked( + entity_id.0, &self.data, &mut component_index, &mut self.component_offsets, ) }; - let entity_id = unsafe { *(self.data.entities_ptr.as_mut_ptr()).add(self.entity_index) }; - let entity = Entity::new(EntityId(entity_id)); self.entity_index += 1; diff --git a/quill/common/src/component.rs b/quill/common/src/component.rs index 77fee4cfd..0721be013 100644 --- a/quill/common/src/component.rs +++ b/quill/common/src/component.rs @@ -65,114 +65,114 @@ host_component_enum! { Position = 0, // Entity marker components - AreaEffectCloud = 100, - ArmorStand = 101, - Arrow = 102, - Bat = 103, - Bee = 104, - Blaze = 105, - Boat = 106, - Cat = 107, - CaveSpider = 108, - Chicken = 109, - Cod = 110, - Cow = 111, - Creeper = 112, - Dolphin = 113, - Donkey = 114, - DragonFireball = 115, - Drowned = 116, - ElderGuardian = 117, - EndCrystal = 118, - EnderDragon = 119, - Enderman = 120, - Endermite = 121, - Evoker = 122, - EvokerFangs = 123, - ExperienceOrb = 124, - EyeOfEnder = 125, - FallingBlock = 126, - FireworkRocket = 127, - Fox = 128, - Ghast = 129, - Giant = 130, - Guardian = 131, - Hoglin = 132, - Horse = 133, - Husk = 134, - Illusioner = 135, - IronGolem = 136, - Item = 137, - ItemFrame = 138, - Fireball = 139, - LeashKnot = 140, - LightningBolt = 141, - Llama = 142, - LlamaSpit = 143, - MagmaCube = 144, - Minecart = 145, - ChestMinecart = 146, - CommandBlockMinecart = 147, - FurnaceMinecart = 148, - HopperMinecart = 149, - SpawnerMinecart = 150, - TntMinecart = 151, - Mule = 152, - Mooshroom = 153, - Ocelot = 154, - Painting = 155, - Panda = 156, - Parrot = 157, - Phantom = 158, - Pig = 159, - Piglin = 160, - Pillager = 161, - PolarBear = 162, - Tnt = 163, - Pufferfish = 164, - Rabbit = 165, - Ravager = 166, - Salmon = 167, - Sheep = 168, - Shulker = 169, - ShulkerBullet = 170, - Silverfish = 171, - Skeleton = 172, - SkeletonHorse = 173, - Slime = 174, - SmallFireball = 175, - SnowGolem = 176, - Snowball = 177, - SpectralArrow = 178, - Spider = 179, - Squid = 180, - Stray = 181, - Strider = 182, - Egg = 183, - EnderPearl = 184, - ExperienceBottle = 185, - Potion = 186, - Trident = 187, - TraderLlama = 188, - TropicalFish = 189, - Turtle = 190, - Vex = 191, - Villager = 192, - Vindicator = 193, - WanderingTrader = 194, - Witch = 195, - Wither = 196, - WitherSkeleton = 197, - WitherSkull = 198, - Wolf = 199, - Zoglin = 200, - Zombie = 201, - ZombieHorse = 202, - ZombieVillager = 203, - ZombifiedPiglin = 204, - Player = 205, - FishingBobber = 206, - PiglinBrute = 207, + AreaEffectCloudMarker = 100, + ArmorStandMarker = 101, + ArrowMarker = 102, + BatMarker = 103, + BeeMarker = 104, + BlazeMarker = 105, + BoatMarker = 106, + CatMarker = 107, + CaveSpiderMarker = 108, + ChickenMarker = 109, + CodMarker = 110, + CowMarker = 111, + CreeperMarker = 112, + DolphinMarker = 113, + DonkeyMarker = 114, + DragonFireballMarker = 115, + DrownedMarker = 116, + ElderGuardianMarker = 117, + PiglinBruteMarker = 118, + EndCrystalMarker = 119, + EnderDragonMarker = 120, + EndermanMarker = 121, + EndermiteMarker = 122, + EvokerMarker = 123, + EvokerFangsMarker = 124, + ExperienceOrbMarker = 125, + EyeOfEnderMarker = 126, + FallingBlockMarker = 127, + FireworkRocketMarker = 128, + FoxMarker = 129, + GhastMarker = 130, + GiantMarker = 131, + GuardianMarker = 132, + HoglinMarker = 133, + HorseMarker = 134, + HuskMarker = 135, + IllusionerMarker = 136, + IronGolemMarker = 137, + ItemMarker = 138, + ItemFrameMarker = 139, + FireballMarker = 140, + LeashKnotMarker = 141, + LightningBoltMarker = 142, + LlamaMarker = 143, + LlamaSpitMarker = 144, + MagmaCubeMarker = 145, + MinecartMarker = 146, + ChestMinecartMarker = 147, + CommandBlockMinecartMarker = 148, + FurnaceMinecartMarker = 149, + HopperMinecartMarker = 150, + SpawnerMinecartMarker = 151, + TntMinecartMarker = 152, + MuleMarker = 153, + MooshroomMarker = 154, + OcelotMarker = 155, + PaintingMarker = 156, + PandaMarker = 157, + ParrotMarker = 158, + PhantomMarker = 159, + PigMarker = 160, + PiglinMarker = 161, + PillagerMarker = 162, + PolarBearMarker = 163, + TntMarker = 164, + PufferfishMarker = 165, + RabbitMarker = 166, + RavagerMarker = 167, + SalmonMarker = 168, + SheepMarker = 169, + ShulkerMarker = 170, + ShulkerBulletMarker = 171, + SilverfishMarker = 172, + SkeletonMarker = 173, + SkeletonHorseMarker = 174, + SlimeMarker = 175, + SmallFireballMarker = 176, + SnowGolemMarker = 177, + SnowballMarker = 178, + SpectralArrowMarker = 179, + SpiderMarker = 180, + SquidMarker = 181, + StrayMarker = 182, + StriderMarker = 183, + EggMarker = 184, + EnderPearlMarker = 185, + ExperienceBottleMarker = 186, + PotionMarker = 187, + TridentMarker = 188, + TraderLlamaMarker = 189, + TropicalFishMarker = 190, + TurtleMarker = 191, + VexMarker = 192, + VillagerMarker = 193, + VindicatorMarker = 194, + WanderingTraderMarker = 195, + WitchMarker = 196, + WitherMarker = 197, + WitherSkeletonMarker = 198, + WitherSkullMarker = 199, + WolfMarker = 200, + ZoglinMarker = 201, + ZombieMarker = 202, + ZombieHorseMarker = 203, + ZombieVillagerMarker = 204, + ZombifiedPiglinMarker = 205, + PlayerMarker = 206, + FishingBobberMarker = 207, // `bincode` components Gamemode = 1000, diff --git a/quill/common/src/entities.rs b/quill/common/src/entities.rs index 452be357c..9c8def8c9 100644 --- a/quill/common/src/entities.rs +++ b/quill/common/src/entities.rs @@ -1,216 +1,276 @@ +use crate::HostComponent; + +/// A struct with an entity ID. +/// +/// Entity wrappers need to implement this trait. +pub trait HasEntityId { + fn entity_id(&self) -> EntityId; +} + +/// An entity wrapper struct. +/// +/// See the `quill` API documentation for more information. +pub trait EntityWrapper: HasEntityId { + /// Wraps the entity with the given ID. + fn from_entity_id(entity_id: EntityId) -> Self; + + /// Gets the marker component that indicates whether + /// an entity can be wrapped by this struct. + fn marker_component() -> HostComponent; +} + +/// Implemenents `EntityWrapper` for an entity wrapper struct. +macro_rules! entity_wrapper_impl { + ($wrapper_struct:ident, $marker:ident) => { + impl crate::entities::EntityWrapper for $wrapper_struct { + fn from_entity_id(entity_id: EntityId) -> Self { + Self { id: entity_id } + } + + fn marker_component() -> crate::HostComponent { + crate::HostComponent::$marker + } + } + }; +} + +/// Implements `FromQuery` for an entity wrapper struct. +macro_rules! wrapper_from_query_impl { + ($wrapper_struct:ident, $marker:ident) => { + impl crate::entity::FromQuery for $wrapper_struct { + type Item = Self; + + fn add_component_types(components: &mut impl Extend) { + components.extend(std::iter::once(crate::HostComponent::$marker)); + } + + unsafe fn get_unchecked( + entity_id: crate::entity::EntityId, + _: &crate::entity::QueryData, + _: &mut usize, + _: &mut [usize], + ) -> Self { + Self { id: entity_id } + } + } + }; +} + pub mod area_effect_cloud; -pub use area_effect_cloud::AreaEffectCloud; +pub use area_effect_cloud::{AreaEffectCloud, AreaEffectCloudMarker}; pub mod armor_stand; -pub use armor_stand::ArmorStand; +pub use armor_stand::{ArmorStand, ArmorStandMarker}; pub mod arrow; -pub use arrow::Arrow; +pub use arrow::{Arrow, ArrowMarker}; pub mod bat; -pub use bat::Bat; +pub use bat::{Bat, BatMarker}; pub mod bee; -pub use bee::Bee; +pub use bee::{Bee, BeeMarker}; pub mod blaze; -pub use blaze::Blaze; +pub use blaze::{Blaze, BlazeMarker}; pub mod boat; -pub use boat::Boat; +pub use boat::{Boat, BoatMarker}; pub mod cat; -pub use cat::Cat; +pub use cat::{Cat, CatMarker}; pub mod cave_spider; -pub use cave_spider::CaveSpider; +pub use cave_spider::{CaveSpider, CaveSpiderMarker}; pub mod chicken; -pub use chicken::Chicken; +pub use chicken::{Chicken, ChickenMarker}; pub mod cod; -pub use cod::Cod; +pub use cod::{Cod, CodMarker}; pub mod cow; -pub use cow::Cow; +pub use cow::{Cow, CowMarker}; pub mod creeper; -pub use creeper::Creeper; +pub use creeper::{Creeper, CreeperMarker}; pub mod dolphin; -pub use dolphin::Dolphin; +pub use dolphin::{Dolphin, DolphinMarker}; pub mod donkey; -pub use donkey::Donkey; +pub use donkey::{Donkey, DonkeyMarker}; pub mod dragon_fireball; -pub use dragon_fireball::DragonFireball; +pub use dragon_fireball::{DragonFireball, DragonFireballMarker}; pub mod drowned; -pub use drowned::Drowned; +pub use drowned::{Drowned, DrownedMarker}; pub mod elder_guardian; -pub use elder_guardian::ElderGuardian; +pub use elder_guardian::{ElderGuardian, ElderGuardianMarker}; +pub mod piglin_brute; +pub use piglin_brute::{PiglinBrute, PiglinBruteMarker}; pub mod end_crystal; -pub use end_crystal::EndCrystal; +pub use end_crystal::{EndCrystal, EndCrystalMarker}; pub mod ender_dragon; -pub use ender_dragon::EnderDragon; +pub use ender_dragon::{EnderDragon, EnderDragonMarker}; pub mod enderman; -pub use enderman::Enderman; +pub use enderman::{Enderman, EndermanMarker}; pub mod endermite; -pub use endermite::Endermite; +pub use endermite::{Endermite, EndermiteMarker}; pub mod evoker; -pub use evoker::Evoker; +pub use evoker::{Evoker, EvokerMarker}; pub mod evoker_fangs; -pub use evoker_fangs::EvokerFangs; +pub use evoker_fangs::{EvokerFangs, EvokerFangsMarker}; pub mod experience_orb; -pub use experience_orb::ExperienceOrb; +pub use experience_orb::{ExperienceOrb, ExperienceOrbMarker}; pub mod eye_of_ender; -pub use eye_of_ender::EyeOfEnder; +pub use eye_of_ender::{EyeOfEnder, EyeOfEnderMarker}; pub mod falling_block; -pub use falling_block::FallingBlock; +pub use falling_block::{FallingBlock, FallingBlockMarker}; pub mod firework_rocket; -pub use firework_rocket::FireworkRocket; +pub use firework_rocket::{FireworkRocket, FireworkRocketMarker}; pub mod fox; -pub use fox::Fox; +pub use fox::{Fox, FoxMarker}; pub mod ghast; -pub use ghast::Ghast; +pub use ghast::{Ghast, GhastMarker}; pub mod giant; -pub use giant::Giant; +pub use giant::{Giant, GiantMarker}; pub mod guardian; -pub use guardian::Guardian; +pub use guardian::{Guardian, GuardianMarker}; pub mod hoglin; -pub use hoglin::Hoglin; +pub use hoglin::{Hoglin, HoglinMarker}; pub mod horse; -pub use horse::Horse; +pub use horse::{Horse, HorseMarker}; pub mod husk; -pub use husk::Husk; +pub use husk::{Husk, HuskMarker}; pub mod illusioner; -pub use illusioner::Illusioner; +pub use illusioner::{Illusioner, IllusionerMarker}; pub mod iron_golem; -pub use iron_golem::IronGolem; +pub use iron_golem::{IronGolem, IronGolemMarker}; pub mod item; -pub use item::Item; +pub use item::{Item, ItemMarker}; pub mod item_frame; -pub use item_frame::ItemFrame; +pub use item_frame::{ItemFrame, ItemFrameMarker}; pub mod fireball; -pub use fireball::Fireball; +pub use fireball::{Fireball, FireballMarker}; pub mod leash_knot; -pub use leash_knot::LeashKnot; +pub use leash_knot::{LeashKnot, LeashKnotMarker}; pub mod lightning_bolt; -pub use lightning_bolt::LightningBolt; +pub use lightning_bolt::{LightningBolt, LightningBoltMarker}; pub mod llama; -pub use llama::Llama; +pub use llama::{Llama, LlamaMarker}; pub mod llama_spit; -pub use llama_spit::LlamaSpit; +pub use llama_spit::{LlamaSpit, LlamaSpitMarker}; pub mod magma_cube; -pub use magma_cube::MagmaCube; +pub use magma_cube::{MagmaCube, MagmaCubeMarker}; pub mod minecart; -pub use minecart::Minecart; +pub use minecart::{Minecart, MinecartMarker}; pub mod chest_minecart; -pub use chest_minecart::ChestMinecart; +pub use chest_minecart::{ChestMinecart, ChestMinecartMarker}; pub mod command_block_minecart; -pub use command_block_minecart::CommandBlockMinecart; +pub use command_block_minecart::{CommandBlockMinecart, CommandBlockMinecartMarker}; pub mod furnace_minecart; -pub use furnace_minecart::FurnaceMinecart; +pub use furnace_minecart::{FurnaceMinecart, FurnaceMinecartMarker}; pub mod hopper_minecart; -pub use hopper_minecart::HopperMinecart; +pub use hopper_minecart::{HopperMinecart, HopperMinecartMarker}; pub mod spawner_minecart; -pub use spawner_minecart::SpawnerMinecart; +pub use spawner_minecart::{SpawnerMinecart, SpawnerMinecartMarker}; pub mod tnt_minecart; -pub use tnt_minecart::TntMinecart; +pub use tnt_minecart::{TntMinecart, TntMinecartMarker}; pub mod mule; -pub use mule::Mule; +pub use mule::{Mule, MuleMarker}; pub mod mooshroom; -pub use mooshroom::Mooshroom; +pub use mooshroom::{Mooshroom, MooshroomMarker}; pub mod ocelot; -pub use ocelot::Ocelot; +pub use ocelot::{Ocelot, OcelotMarker}; pub mod painting; -pub use painting::Painting; +pub use painting::{Painting, PaintingMarker}; pub mod panda; -pub use panda::Panda; +pub use panda::{Panda, PandaMarker}; pub mod parrot; -pub use parrot::Parrot; +pub use parrot::{Parrot, ParrotMarker}; pub mod phantom; -pub use phantom::Phantom; +pub use phantom::{Phantom, PhantomMarker}; pub mod pig; -pub use pig::Pig; +pub use pig::{Pig, PigMarker}; pub mod piglin; -pub use piglin::Piglin; -pub mod piglin_brute; -pub use piglin_brute::PiglinBrute; +pub use piglin::{Piglin, PiglinMarker}; pub mod pillager; -pub use pillager::Pillager; +pub use pillager::{Pillager, PillagerMarker}; pub mod polar_bear; -pub use polar_bear::PolarBear; +pub use polar_bear::{PolarBear, PolarBearMarker}; pub mod tnt; -pub use tnt::Tnt; +pub use tnt::{Tnt, TntMarker}; pub mod pufferfish; -pub use pufferfish::Pufferfish; +pub use pufferfish::{Pufferfish, PufferfishMarker}; pub mod rabbit; -pub use rabbit::Rabbit; +pub use rabbit::{Rabbit, RabbitMarker}; pub mod ravager; -pub use ravager::Ravager; +pub use ravager::{Ravager, RavagerMarker}; pub mod salmon; -pub use salmon::Salmon; +pub use salmon::{Salmon, SalmonMarker}; pub mod sheep; -pub use sheep::Sheep; +pub use sheep::{Sheep, SheepMarker}; pub mod shulker; -pub use shulker::Shulker; +pub use shulker::{Shulker, ShulkerMarker}; pub mod shulker_bullet; -pub use shulker_bullet::ShulkerBullet; +pub use shulker_bullet::{ShulkerBullet, ShulkerBulletMarker}; pub mod silverfish; -pub use silverfish::Silverfish; +pub use silverfish::{Silverfish, SilverfishMarker}; pub mod skeleton; -pub use skeleton::Skeleton; +pub use skeleton::{Skeleton, SkeletonMarker}; pub mod skeleton_horse; -pub use skeleton_horse::SkeletonHorse; +pub use skeleton_horse::{SkeletonHorse, SkeletonHorseMarker}; pub mod slime; -pub use slime::Slime; +pub use slime::{Slime, SlimeMarker}; pub mod small_fireball; -pub use small_fireball::SmallFireball; +pub use small_fireball::{SmallFireball, SmallFireballMarker}; pub mod snow_golem; -pub use snow_golem::SnowGolem; +pub use snow_golem::{SnowGolem, SnowGolemMarker}; pub mod snowball; -pub use snowball::Snowball; +pub use snowball::{Snowball, SnowballMarker}; pub mod spectral_arrow; -pub use spectral_arrow::SpectralArrow; +pub use spectral_arrow::{SpectralArrow, SpectralArrowMarker}; pub mod spider; -pub use spider::Spider; +pub use spider::{Spider, SpiderMarker}; pub mod squid; -pub use squid::Squid; +pub use squid::{Squid, SquidMarker}; pub mod stray; -pub use stray::Stray; +pub use stray::{Stray, StrayMarker}; pub mod strider; -pub use strider::Strider; +pub use strider::{Strider, StriderMarker}; pub mod egg; -pub use egg::Egg; +pub use egg::{Egg, EggMarker}; pub mod ender_pearl; -pub use ender_pearl::EnderPearl; +pub use ender_pearl::{EnderPearl, EnderPearlMarker}; pub mod experience_bottle; -pub use experience_bottle::ExperienceBottle; +pub use experience_bottle::{ExperienceBottle, ExperienceBottleMarker}; pub mod potion; -pub use potion::Potion; +pub use potion::{Potion, PotionMarker}; pub mod trident; -pub use trident::Trident; +pub use trident::{Trident, TridentMarker}; pub mod trader_llama; -pub use trader_llama::TraderLlama; +pub use trader_llama::{TraderLlama, TraderLlamaMarker}; pub mod tropical_fish; -pub use tropical_fish::TropicalFish; +pub use tropical_fish::{TropicalFish, TropicalFishMarker}; pub mod turtle; -pub use turtle::Turtle; +pub use turtle::{Turtle, TurtleMarker}; pub mod vex; -pub use vex::Vex; +pub use vex::{Vex, VexMarker}; pub mod villager; -pub use villager::Villager; +pub use villager::{Villager, VillagerMarker}; pub mod vindicator; -pub use vindicator::Vindicator; +pub use vindicator::{Vindicator, VindicatorMarker}; pub mod wandering_trader; -pub use wandering_trader::WanderingTrader; +pub use wandering_trader::{WanderingTrader, WanderingTraderMarker}; pub mod witch; -pub use witch::Witch; +pub use witch::{Witch, WitchMarker}; pub mod wither; -pub use wither::Wither; +pub use wither::{Wither, WitherMarker}; pub mod wither_skeleton; -pub use wither_skeleton::WitherSkeleton; +pub use wither_skeleton::{WitherSkeleton, WitherSkeletonMarker}; pub mod wither_skull; -pub use wither_skull::WitherSkull; +pub use wither_skull::{WitherSkull, WitherSkullMarker}; pub mod wolf; -pub use wolf::Wolf; +pub use wolf::{Wolf, WolfMarker}; pub mod zoglin; -pub use zoglin::Zoglin; +pub use zoglin::{Zoglin, ZoglinMarker}; pub mod zombie; -pub use zombie::Zombie; +pub use zombie::{Zombie, ZombieMarker}; pub mod zombie_horse; -pub use zombie_horse::ZombieHorse; +pub use zombie_horse::{ZombieHorse, ZombieHorseMarker}; pub mod zombie_villager; -pub use zombie_villager::ZombieVillager; +pub use zombie_villager::{ZombieVillager, ZombieVillagerMarker}; pub mod zombified_piglin; -pub use zombified_piglin::ZombifiedPiglin; +pub use zombified_piglin::{ZombifiedPiglin, ZombifiedPiglinMarker}; pub mod player; -pub use player::Player; +pub use player::{Player, PlayerMarker}; pub mod fishing_bobber; -pub use fishing_bobber::FishingBobber; +pub use fishing_bobber::{FishingBobber, FishingBobberMarker}; + +use crate::EntityId; diff --git a/quill/common/src/entities/area_effect_cloud.rs b/quill/common/src/entities/area_effect_cloud.rs index da07f1ab0..8c992e188 100644 --- a/quill/common/src/entities/area_effect_cloud.rs +++ b/quill/common/src/entities/area_effect_cloud.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for area effect cloud entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all area effect clouds: /// ```no_run -/// use quill::{Game, Position, entities::AreaEffectCloud}; +/// use quill::{Game, Position, entities::AreaEffectCloudMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &AreaEffectCloud)>() { -/// println!("Found a area effect cloud with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &AreaEffectCloudMarker)>() { +/// println!("Found a area effect cloud with position "area effect cloud"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct AreaEffectCloud; +pub struct AreaEffectCloudMarker; + +pod_component_impl!(AreaEffectCloudMarker); + +/// Entity wrapper for area effect cloud entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct AreaEffectCloud { + id: EntityId, +} + +wrapper_from_query_impl!(AreaEffectCloud, AreaEffectCloudMarker); +entity_wrapper_impl!(AreaEffectCloud, AreaEffectCloudMarker); -pod_component_impl!(AreaEffectCloud); +impl crate::HasEntityId for AreaEffectCloud { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/armor_stand.rs b/quill/common/src/entities/armor_stand.rs index 53edaf229..6c46b89f1 100644 --- a/quill/common/src/entities/armor_stand.rs +++ b/quill/common/src/entities/armor_stand.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for armor stand entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all armor stands: /// ```no_run -/// use quill::{Game, Position, entities::ArmorStand}; +/// use quill::{Game, Position, entities::ArmorStandMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ArmorStand)>() { -/// println!("Found a armor stand with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ArmorStandMarker)>() { +/// println!("Found a armor stand with position "armor stand"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ArmorStand; +pub struct ArmorStandMarker; + +pod_component_impl!(ArmorStandMarker); + +/// Entity wrapper for armor stand entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ArmorStand { + id: EntityId, +} + +wrapper_from_query_impl!(ArmorStand, ArmorStandMarker); +entity_wrapper_impl!(ArmorStand, ArmorStandMarker); -pod_component_impl!(ArmorStand); +impl crate::HasEntityId for ArmorStand { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/arrow.rs b/quill/common/src/entities/arrow.rs index 6267a47c3..565db265c 100644 --- a/quill/common/src/entities/arrow.rs +++ b/quill/common/src/entities/arrow.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for arrow entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all arrows: /// ```no_run -/// use quill::{Game, Position, entities::Arrow}; +/// use quill::{Game, Position, entities::ArrowMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Arrow)>() { -/// println!("Found a arrow with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ArrowMarker)>() { +/// println!("Found a arrow with position "arrow"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Arrow; +pub struct ArrowMarker; + +pod_component_impl!(ArrowMarker); + +/// Entity wrapper for arrow entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Arrow { + id: EntityId, +} + +wrapper_from_query_impl!(Arrow, ArrowMarker); +entity_wrapper_impl!(Arrow, ArrowMarker); -pod_component_impl!(Arrow); +impl crate::HasEntityId for Arrow { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/bat.rs b/quill/common/src/entities/bat.rs index 82a6f13d5..d730710af 100644 --- a/quill/common/src/entities/bat.rs +++ b/quill/common/src/entities/bat.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for bat entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all bats: /// ```no_run -/// use quill::{Game, Position, entities::Bat}; +/// use quill::{Game, Position, entities::BatMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Bat)>() { -/// println!("Found a bat with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &BatMarker)>() { +/// println!("Found a bat with position "bat"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Bat; +pub struct BatMarker; + +pod_component_impl!(BatMarker); + +/// Entity wrapper for bat entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Bat { + id: EntityId, +} + +wrapper_from_query_impl!(Bat, BatMarker); +entity_wrapper_impl!(Bat, BatMarker); -pod_component_impl!(Bat); +impl crate::HasEntityId for Bat { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/bee.rs b/quill/common/src/entities/bee.rs index ee81b1567..cc4fdfeb6 100644 --- a/quill/common/src/entities/bee.rs +++ b/quill/common/src/entities/bee.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for bee entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all bees: /// ```no_run -/// use quill::{Game, Position, entities::Bee}; +/// use quill::{Game, Position, entities::BeeMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Bee)>() { -/// println!("Found a bee with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &BeeMarker)>() { +/// println!("Found a bee with position "bee"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Bee; +pub struct BeeMarker; + +pod_component_impl!(BeeMarker); + +/// Entity wrapper for bee entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Bee { + id: EntityId, +} + +wrapper_from_query_impl!(Bee, BeeMarker); +entity_wrapper_impl!(Bee, BeeMarker); -pod_component_impl!(Bee); +impl crate::HasEntityId for Bee { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/blaze.rs b/quill/common/src/entities/blaze.rs index abf9c986e..3f2d09112 100644 --- a/quill/common/src/entities/blaze.rs +++ b/quill/common/src/entities/blaze.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for blaze entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all blazes: /// ```no_run -/// use quill::{Game, Position, entities::Blaze}; +/// use quill::{Game, Position, entities::BlazeMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Blaze)>() { -/// println!("Found a blaze with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &BlazeMarker)>() { +/// println!("Found a blaze with position "blaze"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Blaze; +pub struct BlazeMarker; + +pod_component_impl!(BlazeMarker); + +/// Entity wrapper for blaze entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Blaze { + id: EntityId, +} + +wrapper_from_query_impl!(Blaze, BlazeMarker); +entity_wrapper_impl!(Blaze, BlazeMarker); -pod_component_impl!(Blaze); +impl crate::HasEntityId for Blaze { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/boat.rs b/quill/common/src/entities/boat.rs index 21d260449..df9659c66 100644 --- a/quill/common/src/entities/boat.rs +++ b/quill/common/src/entities/boat.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for boat entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all boats: /// ```no_run -/// use quill::{Game, Position, entities::Boat}; +/// use quill::{Game, Position, entities::BoatMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Boat)>() { -/// println!("Found a boat with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &BoatMarker)>() { +/// println!("Found a boat with position "boat"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Boat; +pub struct BoatMarker; + +pod_component_impl!(BoatMarker); + +/// Entity wrapper for boat entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Boat { + id: EntityId, +} + +wrapper_from_query_impl!(Boat, BoatMarker); +entity_wrapper_impl!(Boat, BoatMarker); -pod_component_impl!(Boat); +impl crate::HasEntityId for Boat { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/cat.rs b/quill/common/src/entities/cat.rs index b8f0721e3..309dfeb4e 100644 --- a/quill/common/src/entities/cat.rs +++ b/quill/common/src/entities/cat.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for cat entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all cats: /// ```no_run -/// use quill::{Game, Position, entities::Cat}; +/// use quill::{Game, Position, entities::CatMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Cat)>() { -/// println!("Found a cat with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CatMarker)>() { +/// println!("Found a cat with position "cat"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Cat; +pub struct CatMarker; + +pod_component_impl!(CatMarker); + +/// Entity wrapper for cat entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Cat { + id: EntityId, +} + +wrapper_from_query_impl!(Cat, CatMarker); +entity_wrapper_impl!(Cat, CatMarker); -pod_component_impl!(Cat); +impl crate::HasEntityId for Cat { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/cave_spider.rs b/quill/common/src/entities/cave_spider.rs index c600f48b3..0ddece2b3 100644 --- a/quill/common/src/entities/cave_spider.rs +++ b/quill/common/src/entities/cave_spider.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for cave spider entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all cave spiders: /// ```no_run -/// use quill::{Game, Position, entities::CaveSpider}; +/// use quill::{Game, Position, entities::CaveSpiderMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &CaveSpider)>() { -/// println!("Found a cave spider with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CaveSpiderMarker)>() { +/// println!("Found a cave spider with position "cave spider"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct CaveSpider; +pub struct CaveSpiderMarker; + +pod_component_impl!(CaveSpiderMarker); + +/// Entity wrapper for cave spider entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct CaveSpider { + id: EntityId, +} + +wrapper_from_query_impl!(CaveSpider, CaveSpiderMarker); +entity_wrapper_impl!(CaveSpider, CaveSpiderMarker); -pod_component_impl!(CaveSpider); +impl crate::HasEntityId for CaveSpider { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/chest_minecart.rs b/quill/common/src/entities/chest_minecart.rs index 010a314c7..e1e84d3f6 100644 --- a/quill/common/src/entities/chest_minecart.rs +++ b/quill/common/src/entities/chest_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for chest minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all chest minecarts: /// ```no_run -/// use quill::{Game, Position, entities::ChestMinecart}; +/// use quill::{Game, Position, entities::ChestMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ChestMinecart)>() { -/// println!("Found a chest minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ChestMinecartMarker)>() { +/// println!("Found a chest minecart with position "chest minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ChestMinecart; +pub struct ChestMinecartMarker; + +pod_component_impl!(ChestMinecartMarker); + +/// Entity wrapper for chest minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ChestMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(ChestMinecart, ChestMinecartMarker); +entity_wrapper_impl!(ChestMinecart, ChestMinecartMarker); -pod_component_impl!(ChestMinecart); +impl crate::HasEntityId for ChestMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/chicken.rs b/quill/common/src/entities/chicken.rs index 236399d04..ef8753bfd 100644 --- a/quill/common/src/entities/chicken.rs +++ b/quill/common/src/entities/chicken.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for chicken entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all chickens: /// ```no_run -/// use quill::{Game, Position, entities::Chicken}; +/// use quill::{Game, Position, entities::ChickenMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Chicken)>() { -/// println!("Found a chicken with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ChickenMarker)>() { +/// println!("Found a chicken with position "chicken"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Chicken; +pub struct ChickenMarker; + +pod_component_impl!(ChickenMarker); + +/// Entity wrapper for chicken entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Chicken { + id: EntityId, +} + +wrapper_from_query_impl!(Chicken, ChickenMarker); +entity_wrapper_impl!(Chicken, ChickenMarker); -pod_component_impl!(Chicken); +impl crate::HasEntityId for Chicken { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/cod.rs b/quill/common/src/entities/cod.rs index 528b8d369..013cbcaab 100644 --- a/quill/common/src/entities/cod.rs +++ b/quill/common/src/entities/cod.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for cod entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all cods: /// ```no_run -/// use quill::{Game, Position, entities::Cod}; +/// use quill::{Game, Position, entities::CodMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Cod)>() { -/// println!("Found a cod with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CodMarker)>() { +/// println!("Found a cod with position "cod"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Cod; +pub struct CodMarker; + +pod_component_impl!(CodMarker); + +/// Entity wrapper for cod entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Cod { + id: EntityId, +} + +wrapper_from_query_impl!(Cod, CodMarker); +entity_wrapper_impl!(Cod, CodMarker); -pod_component_impl!(Cod); +impl crate::HasEntityId for Cod { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/command_block_minecart.rs b/quill/common/src/entities/command_block_minecart.rs index 33c0ca053..5f5527654 100644 --- a/quill/common/src/entities/command_block_minecart.rs +++ b/quill/common/src/entities/command_block_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for command block minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all command block minecarts: /// ```no_run -/// use quill::{Game, Position, entities::CommandBlockMinecart}; +/// use quill::{Game, Position, entities::CommandBlockMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &CommandBlockMinecart)>() { -/// println!("Found a command block minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CommandBlockMinecartMarker)>() { +/// println!("Found a command block minecart with position "command block minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct CommandBlockMinecart; +pub struct CommandBlockMinecartMarker; + +pod_component_impl!(CommandBlockMinecartMarker); + +/// Entity wrapper for command block minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct CommandBlockMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(CommandBlockMinecart, CommandBlockMinecartMarker); +entity_wrapper_impl!(CommandBlockMinecart, CommandBlockMinecartMarker); -pod_component_impl!(CommandBlockMinecart); +impl crate::HasEntityId for CommandBlockMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/cow.rs b/quill/common/src/entities/cow.rs index adb540b9c..19f141da6 100644 --- a/quill/common/src/entities/cow.rs +++ b/quill/common/src/entities/cow.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for cow entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all cows: /// ```no_run -/// use quill::{Game, Position, entities::Cow}; +/// use quill::{Game, Position, entities::CowMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Cow)>() { -/// println!("Found a cow with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CowMarker)>() { +/// println!("Found a cow with position "cow"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Cow; +pub struct CowMarker; + +pod_component_impl!(CowMarker); + +/// Entity wrapper for cow entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Cow { + id: EntityId, +} + +wrapper_from_query_impl!(Cow, CowMarker); +entity_wrapper_impl!(Cow, CowMarker); -pod_component_impl!(Cow); +impl crate::HasEntityId for Cow { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/creeper.rs b/quill/common/src/entities/creeper.rs index 48261737f..74cd71caf 100644 --- a/quill/common/src/entities/creeper.rs +++ b/quill/common/src/entities/creeper.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for creeper entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all creepers: /// ```no_run -/// use quill::{Game, Position, entities::Creeper}; +/// use quill::{Game, Position, entities::CreeperMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Creeper)>() { -/// println!("Found a creeper with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &CreeperMarker)>() { +/// println!("Found a creeper with position "creeper"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Creeper; +pub struct CreeperMarker; + +pod_component_impl!(CreeperMarker); + +/// Entity wrapper for creeper entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Creeper { + id: EntityId, +} + +wrapper_from_query_impl!(Creeper, CreeperMarker); +entity_wrapper_impl!(Creeper, CreeperMarker); -pod_component_impl!(Creeper); +impl crate::HasEntityId for Creeper { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/dolphin.rs b/quill/common/src/entities/dolphin.rs index c763c7a65..10e97aae7 100644 --- a/quill/common/src/entities/dolphin.rs +++ b/quill/common/src/entities/dolphin.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for dolphin entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all dolphins: /// ```no_run -/// use quill::{Game, Position, entities::Dolphin}; +/// use quill::{Game, Position, entities::DolphinMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Dolphin)>() { -/// println!("Found a dolphin with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &DolphinMarker)>() { +/// println!("Found a dolphin with position "dolphin"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Dolphin; +pub struct DolphinMarker; + +pod_component_impl!(DolphinMarker); + +/// Entity wrapper for dolphin entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Dolphin { + id: EntityId, +} + +wrapper_from_query_impl!(Dolphin, DolphinMarker); +entity_wrapper_impl!(Dolphin, DolphinMarker); -pod_component_impl!(Dolphin); +impl crate::HasEntityId for Dolphin { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/donkey.rs b/quill/common/src/entities/donkey.rs index 5c9565572..02025bd21 100644 --- a/quill/common/src/entities/donkey.rs +++ b/quill/common/src/entities/donkey.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for donkey entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all donkeys: /// ```no_run -/// use quill::{Game, Position, entities::Donkey}; +/// use quill::{Game, Position, entities::DonkeyMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Donkey)>() { -/// println!("Found a donkey with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &DonkeyMarker)>() { +/// println!("Found a donkey with position "donkey"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Donkey; +pub struct DonkeyMarker; + +pod_component_impl!(DonkeyMarker); + +/// Entity wrapper for donkey entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Donkey { + id: EntityId, +} + +wrapper_from_query_impl!(Donkey, DonkeyMarker); +entity_wrapper_impl!(Donkey, DonkeyMarker); -pod_component_impl!(Donkey); +impl crate::HasEntityId for Donkey { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/dragon_fireball.rs b/quill/common/src/entities/dragon_fireball.rs index 2ecb539ff..7ee40300c 100644 --- a/quill/common/src/entities/dragon_fireball.rs +++ b/quill/common/src/entities/dragon_fireball.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for dragon fireball entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all dragon fireballs: /// ```no_run -/// use quill::{Game, Position, entities::DragonFireball}; +/// use quill::{Game, Position, entities::DragonFireballMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &DragonFireball)>() { -/// println!("Found a dragon fireball with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &DragonFireballMarker)>() { +/// println!("Found a dragon fireball with position "dragon fireball"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct DragonFireball; +pub struct DragonFireballMarker; + +pod_component_impl!(DragonFireballMarker); + +/// Entity wrapper for dragon fireball entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct DragonFireball { + id: EntityId, +} + +wrapper_from_query_impl!(DragonFireball, DragonFireballMarker); +entity_wrapper_impl!(DragonFireball, DragonFireballMarker); -pod_component_impl!(DragonFireball); +impl crate::HasEntityId for DragonFireball { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/drowned.rs b/quill/common/src/entities/drowned.rs index bcf1fa93f..9e86e5dc8 100644 --- a/quill/common/src/entities/drowned.rs +++ b/quill/common/src/entities/drowned.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for drowned entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all drowneds: /// ```no_run -/// use quill::{Game, Position, entities::Drowned}; +/// use quill::{Game, Position, entities::DrownedMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Drowned)>() { -/// println!("Found a drowned with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &DrownedMarker)>() { +/// println!("Found a drowned with position "drowned"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Drowned; +pub struct DrownedMarker; + +pod_component_impl!(DrownedMarker); + +/// Entity wrapper for drowned entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Drowned { + id: EntityId, +} + +wrapper_from_query_impl!(Drowned, DrownedMarker); +entity_wrapper_impl!(Drowned, DrownedMarker); -pod_component_impl!(Drowned); +impl crate::HasEntityId for Drowned { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/egg.rs b/quill/common/src/entities/egg.rs index 0c89551cc..db0ae4662 100644 --- a/quill/common/src/entities/egg.rs +++ b/quill/common/src/entities/egg.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for egg entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all eggs: /// ```no_run -/// use quill::{Game, Position, entities::Egg}; +/// use quill::{Game, Position, entities::EggMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Egg)>() { -/// println!("Found a egg with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EggMarker)>() { +/// println!("Found a egg with position "egg"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Egg; +pub struct EggMarker; + +pod_component_impl!(EggMarker); + +/// Entity wrapper for egg entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Egg { + id: EntityId, +} + +wrapper_from_query_impl!(Egg, EggMarker); +entity_wrapper_impl!(Egg, EggMarker); -pod_component_impl!(Egg); +impl crate::HasEntityId for Egg { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/elder_guardian.rs b/quill/common/src/entities/elder_guardian.rs index ea2503448..f6b04342a 100644 --- a/quill/common/src/entities/elder_guardian.rs +++ b/quill/common/src/entities/elder_guardian.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for elder guardian entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all elder guardians: /// ```no_run -/// use quill::{Game, Position, entities::ElderGuardian}; +/// use quill::{Game, Position, entities::ElderGuardianMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ElderGuardian)>() { -/// println!("Found a elder guardian with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ElderGuardianMarker)>() { +/// println!("Found a elder guardian with position "elder guardian"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ElderGuardian; +pub struct ElderGuardianMarker; + +pod_component_impl!(ElderGuardianMarker); + +/// Entity wrapper for elder guardian entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ElderGuardian { + id: EntityId, +} + +wrapper_from_query_impl!(ElderGuardian, ElderGuardianMarker); +entity_wrapper_impl!(ElderGuardian, ElderGuardianMarker); -pod_component_impl!(ElderGuardian); +impl crate::HasEntityId for ElderGuardian { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/end_crystal.rs b/quill/common/src/entities/end_crystal.rs index 2ceaa8fa7..4a2e263de 100644 --- a/quill/common/src/entities/end_crystal.rs +++ b/quill/common/src/entities/end_crystal.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for end crystal entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all end crystals: /// ```no_run -/// use quill::{Game, Position, entities::EndCrystal}; +/// use quill::{Game, Position, entities::EndCrystalMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &EndCrystal)>() { -/// println!("Found a end crystal with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EndCrystalMarker)>() { +/// println!("Found a end crystal with position "end crystal"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct EndCrystal; +pub struct EndCrystalMarker; + +pod_component_impl!(EndCrystalMarker); + +/// Entity wrapper for end crystal entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct EndCrystal { + id: EntityId, +} + +wrapper_from_query_impl!(EndCrystal, EndCrystalMarker); +entity_wrapper_impl!(EndCrystal, EndCrystalMarker); -pod_component_impl!(EndCrystal); +impl crate::HasEntityId for EndCrystal { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/ender_dragon.rs b/quill/common/src/entities/ender_dragon.rs index 0ab804da3..4f7c74f83 100644 --- a/quill/common/src/entities/ender_dragon.rs +++ b/quill/common/src/entities/ender_dragon.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for ender dragon entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all ender dragons: /// ```no_run -/// use quill::{Game, Position, entities::EnderDragon}; +/// use quill::{Game, Position, entities::EnderDragonMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &EnderDragon)>() { -/// println!("Found a ender dragon with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EnderDragonMarker)>() { +/// println!("Found a ender dragon with position "ender dragon"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct EnderDragon; +pub struct EnderDragonMarker; + +pod_component_impl!(EnderDragonMarker); + +/// Entity wrapper for ender dragon entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct EnderDragon { + id: EntityId, +} + +wrapper_from_query_impl!(EnderDragon, EnderDragonMarker); +entity_wrapper_impl!(EnderDragon, EnderDragonMarker); -pod_component_impl!(EnderDragon); +impl crate::HasEntityId for EnderDragon { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/ender_pearl.rs b/quill/common/src/entities/ender_pearl.rs index 4f44365cf..8efb469de 100644 --- a/quill/common/src/entities/ender_pearl.rs +++ b/quill/common/src/entities/ender_pearl.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for ender pearl entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all ender pearls: /// ```no_run -/// use quill::{Game, Position, entities::EnderPearl}; +/// use quill::{Game, Position, entities::EnderPearlMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &EnderPearl)>() { -/// println!("Found a ender pearl with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EnderPearlMarker)>() { +/// println!("Found a ender pearl with position "ender pearl"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct EnderPearl; +pub struct EnderPearlMarker; + +pod_component_impl!(EnderPearlMarker); + +/// Entity wrapper for ender pearl entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct EnderPearl { + id: EntityId, +} + +wrapper_from_query_impl!(EnderPearl, EnderPearlMarker); +entity_wrapper_impl!(EnderPearl, EnderPearlMarker); -pod_component_impl!(EnderPearl); +impl crate::HasEntityId for EnderPearl { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/enderman.rs b/quill/common/src/entities/enderman.rs index 393fce912..a53ec16ba 100644 --- a/quill/common/src/entities/enderman.rs +++ b/quill/common/src/entities/enderman.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for enderman entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all endermans: /// ```no_run -/// use quill::{Game, Position, entities::Enderman}; +/// use quill::{Game, Position, entities::EndermanMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Enderman)>() { -/// println!("Found a enderman with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EndermanMarker)>() { +/// println!("Found a enderman with position "enderman"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Enderman; +pub struct EndermanMarker; + +pod_component_impl!(EndermanMarker); + +/// Entity wrapper for enderman entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Enderman { + id: EntityId, +} + +wrapper_from_query_impl!(Enderman, EndermanMarker); +entity_wrapper_impl!(Enderman, EndermanMarker); -pod_component_impl!(Enderman); +impl crate::HasEntityId for Enderman { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/endermite.rs b/quill/common/src/entities/endermite.rs index cc4b19dd9..4e5699d65 100644 --- a/quill/common/src/entities/endermite.rs +++ b/quill/common/src/entities/endermite.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for endermite entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all endermites: /// ```no_run -/// use quill::{Game, Position, entities::Endermite}; +/// use quill::{Game, Position, entities::EndermiteMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Endermite)>() { -/// println!("Found a endermite with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EndermiteMarker)>() { +/// println!("Found a endermite with position "endermite"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Endermite; +pub struct EndermiteMarker; + +pod_component_impl!(EndermiteMarker); + +/// Entity wrapper for endermite entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Endermite { + id: EntityId, +} + +wrapper_from_query_impl!(Endermite, EndermiteMarker); +entity_wrapper_impl!(Endermite, EndermiteMarker); -pod_component_impl!(Endermite); +impl crate::HasEntityId for Endermite { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/evoker.rs b/quill/common/src/entities/evoker.rs index 118fb90da..b4fb1a091 100644 --- a/quill/common/src/entities/evoker.rs +++ b/quill/common/src/entities/evoker.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for evoker entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all evokers: /// ```no_run -/// use quill::{Game, Position, entities::Evoker}; +/// use quill::{Game, Position, entities::EvokerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Evoker)>() { -/// println!("Found a evoker with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EvokerMarker)>() { +/// println!("Found a evoker with position "evoker"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Evoker; +pub struct EvokerMarker; + +pod_component_impl!(EvokerMarker); + +/// Entity wrapper for evoker entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Evoker { + id: EntityId, +} + +wrapper_from_query_impl!(Evoker, EvokerMarker); +entity_wrapper_impl!(Evoker, EvokerMarker); -pod_component_impl!(Evoker); +impl crate::HasEntityId for Evoker { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/evoker_fangs.rs b/quill/common/src/entities/evoker_fangs.rs index 48cbb3d78..1b20b633c 100644 --- a/quill/common/src/entities/evoker_fangs.rs +++ b/quill/common/src/entities/evoker_fangs.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for evoker fangs entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all evoker fangss: /// ```no_run -/// use quill::{Game, Position, entities::EvokerFangs}; +/// use quill::{Game, Position, entities::EvokerFangsMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &EvokerFangs)>() { -/// println!("Found a evoker fangs with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EvokerFangsMarker)>() { +/// println!("Found a evoker fangs with position "evoker fangs"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct EvokerFangs; +pub struct EvokerFangsMarker; + +pod_component_impl!(EvokerFangsMarker); + +/// Entity wrapper for evoker fangs entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct EvokerFangs { + id: EntityId, +} + +wrapper_from_query_impl!(EvokerFangs, EvokerFangsMarker); +entity_wrapper_impl!(EvokerFangs, EvokerFangsMarker); -pod_component_impl!(EvokerFangs); +impl crate::HasEntityId for EvokerFangs { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/experience_bottle.rs b/quill/common/src/entities/experience_bottle.rs index 034e71d58..0c87e1bcf 100644 --- a/quill/common/src/entities/experience_bottle.rs +++ b/quill/common/src/entities/experience_bottle.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for experience bottle entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all experience bottles: /// ```no_run -/// use quill::{Game, Position, entities::ExperienceBottle}; +/// use quill::{Game, Position, entities::ExperienceBottleMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ExperienceBottle)>() { -/// println!("Found a experience bottle with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ExperienceBottleMarker)>() { +/// println!("Found a experience bottle with position "experience bottle"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ExperienceBottle; +pub struct ExperienceBottleMarker; + +pod_component_impl!(ExperienceBottleMarker); + +/// Entity wrapper for experience bottle entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ExperienceBottle { + id: EntityId, +} + +wrapper_from_query_impl!(ExperienceBottle, ExperienceBottleMarker); +entity_wrapper_impl!(ExperienceBottle, ExperienceBottleMarker); -pod_component_impl!(ExperienceBottle); +impl crate::HasEntityId for ExperienceBottle { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/experience_orb.rs b/quill/common/src/entities/experience_orb.rs index f3aa27199..0df0ffcb1 100644 --- a/quill/common/src/entities/experience_orb.rs +++ b/quill/common/src/entities/experience_orb.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for experience orb entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all experience orbs: /// ```no_run -/// use quill::{Game, Position, entities::ExperienceOrb}; +/// use quill::{Game, Position, entities::ExperienceOrbMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ExperienceOrb)>() { -/// println!("Found a experience orb with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ExperienceOrbMarker)>() { +/// println!("Found a experience orb with position "experience orb"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ExperienceOrb; +pub struct ExperienceOrbMarker; + +pod_component_impl!(ExperienceOrbMarker); + +/// Entity wrapper for experience orb entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ExperienceOrb { + id: EntityId, +} + +wrapper_from_query_impl!(ExperienceOrb, ExperienceOrbMarker); +entity_wrapper_impl!(ExperienceOrb, ExperienceOrbMarker); -pod_component_impl!(ExperienceOrb); +impl crate::HasEntityId for ExperienceOrb { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/eye_of_ender.rs b/quill/common/src/entities/eye_of_ender.rs index 6c1e83cd4..ab01b43b7 100644 --- a/quill/common/src/entities/eye_of_ender.rs +++ b/quill/common/src/entities/eye_of_ender.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for eye of ender entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all eye of enders: /// ```no_run -/// use quill::{Game, Position, entities::EyeOfEnder}; +/// use quill::{Game, Position, entities::EyeOfEnderMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &EyeOfEnder)>() { -/// println!("Found a eye of ender with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &EyeOfEnderMarker)>() { +/// println!("Found a eye of ender with position "eye of ender"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct EyeOfEnder; +pub struct EyeOfEnderMarker; + +pod_component_impl!(EyeOfEnderMarker); + +/// Entity wrapper for eye of ender entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct EyeOfEnder { + id: EntityId, +} + +wrapper_from_query_impl!(EyeOfEnder, EyeOfEnderMarker); +entity_wrapper_impl!(EyeOfEnder, EyeOfEnderMarker); -pod_component_impl!(EyeOfEnder); +impl crate::HasEntityId for EyeOfEnder { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/falling_block.rs b/quill/common/src/entities/falling_block.rs index abc223edf..0cff5aae4 100644 --- a/quill/common/src/entities/falling_block.rs +++ b/quill/common/src/entities/falling_block.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for falling block entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all falling blocks: /// ```no_run -/// use quill::{Game, Position, entities::FallingBlock}; +/// use quill::{Game, Position, entities::FallingBlockMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &FallingBlock)>() { -/// println!("Found a falling block with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FallingBlockMarker)>() { +/// println!("Found a falling block with position "falling block"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct FallingBlock; +pub struct FallingBlockMarker; + +pod_component_impl!(FallingBlockMarker); + +/// Entity wrapper for falling block entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct FallingBlock { + id: EntityId, +} + +wrapper_from_query_impl!(FallingBlock, FallingBlockMarker); +entity_wrapper_impl!(FallingBlock, FallingBlockMarker); -pod_component_impl!(FallingBlock); +impl crate::HasEntityId for FallingBlock { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/fireball.rs b/quill/common/src/entities/fireball.rs index d524648be..628efb80d 100644 --- a/quill/common/src/entities/fireball.rs +++ b/quill/common/src/entities/fireball.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for fireball entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all fireballs: /// ```no_run -/// use quill::{Game, Position, entities::Fireball}; +/// use quill::{Game, Position, entities::FireballMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Fireball)>() { -/// println!("Found a fireball with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FireballMarker)>() { +/// println!("Found a fireball with position "fireball"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Fireball; +pub struct FireballMarker; + +pod_component_impl!(FireballMarker); + +/// Entity wrapper for fireball entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Fireball { + id: EntityId, +} + +wrapper_from_query_impl!(Fireball, FireballMarker); +entity_wrapper_impl!(Fireball, FireballMarker); -pod_component_impl!(Fireball); +impl crate::HasEntityId for Fireball { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/firework_rocket.rs b/quill/common/src/entities/firework_rocket.rs index f03f2edc3..8853af1d5 100644 --- a/quill/common/src/entities/firework_rocket.rs +++ b/quill/common/src/entities/firework_rocket.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for firework rocket entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all firework rockets: /// ```no_run -/// use quill::{Game, Position, entities::FireworkRocket}; +/// use quill::{Game, Position, entities::FireworkRocketMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &FireworkRocket)>() { -/// println!("Found a firework rocket with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FireworkRocketMarker)>() { +/// println!("Found a firework rocket with position "firework rocket"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct FireworkRocket; +pub struct FireworkRocketMarker; + +pod_component_impl!(FireworkRocketMarker); + +/// Entity wrapper for firework rocket entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct FireworkRocket { + id: EntityId, +} + +wrapper_from_query_impl!(FireworkRocket, FireworkRocketMarker); +entity_wrapper_impl!(FireworkRocket, FireworkRocketMarker); -pod_component_impl!(FireworkRocket); +impl crate::HasEntityId for FireworkRocket { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/fishing_bobber.rs b/quill/common/src/entities/fishing_bobber.rs index c49a726f4..ab739dd39 100644 --- a/quill/common/src/entities/fishing_bobber.rs +++ b/quill/common/src/entities/fishing_bobber.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for fishing bobber entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all fishing bobbers: /// ```no_run -/// use quill::{Game, Position, entities::FishingBobber}; +/// use quill::{Game, Position, entities::FishingBobberMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &FishingBobber)>() { -/// println!("Found a fishing bobber with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FishingBobberMarker)>() { +/// println!("Found a fishing bobber with position "fishing bobber"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct FishingBobber; +pub struct FishingBobberMarker; + +pod_component_impl!(FishingBobberMarker); + +/// Entity wrapper for fishing bobber entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct FishingBobber { + id: EntityId, +} + +wrapper_from_query_impl!(FishingBobber, FishingBobberMarker); +entity_wrapper_impl!(FishingBobber, FishingBobberMarker); -pod_component_impl!(FishingBobber); +impl crate::HasEntityId for FishingBobber { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/fox.rs b/quill/common/src/entities/fox.rs index c8c367585..1e0ff3d7d 100644 --- a/quill/common/src/entities/fox.rs +++ b/quill/common/src/entities/fox.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for fox entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all foxs: /// ```no_run -/// use quill::{Game, Position, entities::Fox}; +/// use quill::{Game, Position, entities::FoxMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Fox)>() { -/// println!("Found a fox with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FoxMarker)>() { +/// println!("Found a fox with position "fox"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Fox; +pub struct FoxMarker; + +pod_component_impl!(FoxMarker); + +/// Entity wrapper for fox entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Fox { + id: EntityId, +} + +wrapper_from_query_impl!(Fox, FoxMarker); +entity_wrapper_impl!(Fox, FoxMarker); -pod_component_impl!(Fox); +impl crate::HasEntityId for Fox { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/furnace_minecart.rs b/quill/common/src/entities/furnace_minecart.rs index 259647d1d..e3681c9ac 100644 --- a/quill/common/src/entities/furnace_minecart.rs +++ b/quill/common/src/entities/furnace_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for furnace minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all furnace minecarts: /// ```no_run -/// use quill::{Game, Position, entities::FurnaceMinecart}; +/// use quill::{Game, Position, entities::FurnaceMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &FurnaceMinecart)>() { -/// println!("Found a furnace minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &FurnaceMinecartMarker)>() { +/// println!("Found a furnace minecart with position "furnace minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct FurnaceMinecart; +pub struct FurnaceMinecartMarker; + +pod_component_impl!(FurnaceMinecartMarker); + +/// Entity wrapper for furnace minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct FurnaceMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(FurnaceMinecart, FurnaceMinecartMarker); +entity_wrapper_impl!(FurnaceMinecart, FurnaceMinecartMarker); -pod_component_impl!(FurnaceMinecart); +impl crate::HasEntityId for FurnaceMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/ghast.rs b/quill/common/src/entities/ghast.rs index ee1b579d3..59ba2a7ce 100644 --- a/quill/common/src/entities/ghast.rs +++ b/quill/common/src/entities/ghast.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for ghast entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all ghasts: /// ```no_run -/// use quill::{Game, Position, entities::Ghast}; +/// use quill::{Game, Position, entities::GhastMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Ghast)>() { -/// println!("Found a ghast with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &GhastMarker)>() { +/// println!("Found a ghast with position "ghast"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Ghast; +pub struct GhastMarker; + +pod_component_impl!(GhastMarker); + +/// Entity wrapper for ghast entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Ghast { + id: EntityId, +} + +wrapper_from_query_impl!(Ghast, GhastMarker); +entity_wrapper_impl!(Ghast, GhastMarker); -pod_component_impl!(Ghast); +impl crate::HasEntityId for Ghast { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/giant.rs b/quill/common/src/entities/giant.rs index 4dd05874a..0903928b1 100644 --- a/quill/common/src/entities/giant.rs +++ b/quill/common/src/entities/giant.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for giant entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all giants: /// ```no_run -/// use quill::{Game, Position, entities::Giant}; +/// use quill::{Game, Position, entities::GiantMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Giant)>() { -/// println!("Found a giant with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &GiantMarker)>() { +/// println!("Found a giant with position "giant"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Giant; +pub struct GiantMarker; + +pod_component_impl!(GiantMarker); + +/// Entity wrapper for giant entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Giant { + id: EntityId, +} + +wrapper_from_query_impl!(Giant, GiantMarker); +entity_wrapper_impl!(Giant, GiantMarker); -pod_component_impl!(Giant); +impl crate::HasEntityId for Giant { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/guardian.rs b/quill/common/src/entities/guardian.rs index 29ec01eef..59d5b3c8b 100644 --- a/quill/common/src/entities/guardian.rs +++ b/quill/common/src/entities/guardian.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for guardian entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all guardians: /// ```no_run -/// use quill::{Game, Position, entities::Guardian}; +/// use quill::{Game, Position, entities::GuardianMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Guardian)>() { -/// println!("Found a guardian with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &GuardianMarker)>() { +/// println!("Found a guardian with position "guardian"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Guardian; +pub struct GuardianMarker; + +pod_component_impl!(GuardianMarker); + +/// Entity wrapper for guardian entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Guardian { + id: EntityId, +} + +wrapper_from_query_impl!(Guardian, GuardianMarker); +entity_wrapper_impl!(Guardian, GuardianMarker); -pod_component_impl!(Guardian); +impl crate::HasEntityId for Guardian { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/hoglin.rs b/quill/common/src/entities/hoglin.rs index 621867f00..fd2077620 100644 --- a/quill/common/src/entities/hoglin.rs +++ b/quill/common/src/entities/hoglin.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for hoglin entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all hoglins: /// ```no_run -/// use quill::{Game, Position, entities::Hoglin}; +/// use quill::{Game, Position, entities::HoglinMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Hoglin)>() { -/// println!("Found a hoglin with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &HoglinMarker)>() { +/// println!("Found a hoglin with position "hoglin"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Hoglin; +pub struct HoglinMarker; + +pod_component_impl!(HoglinMarker); + +/// Entity wrapper for hoglin entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Hoglin { + id: EntityId, +} + +wrapper_from_query_impl!(Hoglin, HoglinMarker); +entity_wrapper_impl!(Hoglin, HoglinMarker); -pod_component_impl!(Hoglin); +impl crate::HasEntityId for Hoglin { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/hopper_minecart.rs b/quill/common/src/entities/hopper_minecart.rs index 04f1453ea..b3caab5d1 100644 --- a/quill/common/src/entities/hopper_minecart.rs +++ b/quill/common/src/entities/hopper_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for hopper minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all hopper minecarts: /// ```no_run -/// use quill::{Game, Position, entities::HopperMinecart}; +/// use quill::{Game, Position, entities::HopperMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &HopperMinecart)>() { -/// println!("Found a hopper minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &HopperMinecartMarker)>() { +/// println!("Found a hopper minecart with position "hopper minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct HopperMinecart; +pub struct HopperMinecartMarker; + +pod_component_impl!(HopperMinecartMarker); + +/// Entity wrapper for hopper minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct HopperMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(HopperMinecart, HopperMinecartMarker); +entity_wrapper_impl!(HopperMinecart, HopperMinecartMarker); -pod_component_impl!(HopperMinecart); +impl crate::HasEntityId for HopperMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/horse.rs b/quill/common/src/entities/horse.rs index dd6d52ea7..d652912c5 100644 --- a/quill/common/src/entities/horse.rs +++ b/quill/common/src/entities/horse.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for horse entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all horses: /// ```no_run -/// use quill::{Game, Position, entities::Horse}; +/// use quill::{Game, Position, entities::HorseMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Horse)>() { -/// println!("Found a horse with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &HorseMarker)>() { +/// println!("Found a horse with position "horse"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Horse; +pub struct HorseMarker; + +pod_component_impl!(HorseMarker); + +/// Entity wrapper for horse entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Horse { + id: EntityId, +} + +wrapper_from_query_impl!(Horse, HorseMarker); +entity_wrapper_impl!(Horse, HorseMarker); -pod_component_impl!(Horse); +impl crate::HasEntityId for Horse { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/husk.rs b/quill/common/src/entities/husk.rs index 37a7cc2e9..d00b89135 100644 --- a/quill/common/src/entities/husk.rs +++ b/quill/common/src/entities/husk.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for husk entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all husks: /// ```no_run -/// use quill::{Game, Position, entities::Husk}; +/// use quill::{Game, Position, entities::HuskMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Husk)>() { -/// println!("Found a husk with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &HuskMarker)>() { +/// println!("Found a husk with position "husk"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Husk; +pub struct HuskMarker; + +pod_component_impl!(HuskMarker); + +/// Entity wrapper for husk entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Husk { + id: EntityId, +} + +wrapper_from_query_impl!(Husk, HuskMarker); +entity_wrapper_impl!(Husk, HuskMarker); -pod_component_impl!(Husk); +impl crate::HasEntityId for Husk { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/illusioner.rs b/quill/common/src/entities/illusioner.rs index 4efc89bbe..3ba61239f 100644 --- a/quill/common/src/entities/illusioner.rs +++ b/quill/common/src/entities/illusioner.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for illusioner entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all illusioners: /// ```no_run -/// use quill::{Game, Position, entities::Illusioner}; +/// use quill::{Game, Position, entities::IllusionerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Illusioner)>() { -/// println!("Found a illusioner with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &IllusionerMarker)>() { +/// println!("Found a illusioner with position "illusioner"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Illusioner; +pub struct IllusionerMarker; + +pod_component_impl!(IllusionerMarker); + +/// Entity wrapper for illusioner entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Illusioner { + id: EntityId, +} + +wrapper_from_query_impl!(Illusioner, IllusionerMarker); +entity_wrapper_impl!(Illusioner, IllusionerMarker); -pod_component_impl!(Illusioner); +impl crate::HasEntityId for Illusioner { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/iron_golem.rs b/quill/common/src/entities/iron_golem.rs index 6ee2f96bd..2d1f97b32 100644 --- a/quill/common/src/entities/iron_golem.rs +++ b/quill/common/src/entities/iron_golem.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for iron golem entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all iron golems: /// ```no_run -/// use quill::{Game, Position, entities::IronGolem}; +/// use quill::{Game, Position, entities::IronGolemMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &IronGolem)>() { -/// println!("Found a iron golem with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &IronGolemMarker)>() { +/// println!("Found a iron golem with position "iron golem"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct IronGolem; +pub struct IronGolemMarker; + +pod_component_impl!(IronGolemMarker); + +/// Entity wrapper for iron golem entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct IronGolem { + id: EntityId, +} + +wrapper_from_query_impl!(IronGolem, IronGolemMarker); +entity_wrapper_impl!(IronGolem, IronGolemMarker); -pod_component_impl!(IronGolem); +impl crate::HasEntityId for IronGolem { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/item.rs b/quill/common/src/entities/item.rs index 9c37e4a45..c97fc89fa 100644 --- a/quill/common/src/entities/item.rs +++ b/quill/common/src/entities/item.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for item entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all items: /// ```no_run -/// use quill::{Game, Position, entities::Item}; +/// use quill::{Game, Position, entities::ItemMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Item)>() { -/// println!("Found a item with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ItemMarker)>() { +/// println!("Found a item with position "item"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Item; +pub struct ItemMarker; + +pod_component_impl!(ItemMarker); + +/// Entity wrapper for item entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Item { + id: EntityId, +} + +wrapper_from_query_impl!(Item, ItemMarker); +entity_wrapper_impl!(Item, ItemMarker); -pod_component_impl!(Item); +impl crate::HasEntityId for Item { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/item_frame.rs b/quill/common/src/entities/item_frame.rs index 1eb6157d6..21447be97 100644 --- a/quill/common/src/entities/item_frame.rs +++ b/quill/common/src/entities/item_frame.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for item frame entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all item frames: /// ```no_run -/// use quill::{Game, Position, entities::ItemFrame}; +/// use quill::{Game, Position, entities::ItemFrameMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ItemFrame)>() { -/// println!("Found a item frame with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ItemFrameMarker)>() { +/// println!("Found a item frame with position "item frame"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ItemFrame; +pub struct ItemFrameMarker; + +pod_component_impl!(ItemFrameMarker); + +/// Entity wrapper for item frame entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ItemFrame { + id: EntityId, +} + +wrapper_from_query_impl!(ItemFrame, ItemFrameMarker); +entity_wrapper_impl!(ItemFrame, ItemFrameMarker); -pod_component_impl!(ItemFrame); +impl crate::HasEntityId for ItemFrame { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/leash_knot.rs b/quill/common/src/entities/leash_knot.rs index 548f0b546..2481bb96f 100644 --- a/quill/common/src/entities/leash_knot.rs +++ b/quill/common/src/entities/leash_knot.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for leash knot entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all leash knots: /// ```no_run -/// use quill::{Game, Position, entities::LeashKnot}; +/// use quill::{Game, Position, entities::LeashKnotMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &LeashKnot)>() { -/// println!("Found a leash knot with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &LeashKnotMarker)>() { +/// println!("Found a leash knot with position "leash knot"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct LeashKnot; +pub struct LeashKnotMarker; + +pod_component_impl!(LeashKnotMarker); + +/// Entity wrapper for leash knot entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct LeashKnot { + id: EntityId, +} + +wrapper_from_query_impl!(LeashKnot, LeashKnotMarker); +entity_wrapper_impl!(LeashKnot, LeashKnotMarker); -pod_component_impl!(LeashKnot); +impl crate::HasEntityId for LeashKnot { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/lightning_bolt.rs b/quill/common/src/entities/lightning_bolt.rs index e02e12761..6ac190972 100644 --- a/quill/common/src/entities/lightning_bolt.rs +++ b/quill/common/src/entities/lightning_bolt.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for lightning bolt entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all lightning bolts: /// ```no_run -/// use quill::{Game, Position, entities::LightningBolt}; +/// use quill::{Game, Position, entities::LightningBoltMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &LightningBolt)>() { -/// println!("Found a lightning bolt with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &LightningBoltMarker)>() { +/// println!("Found a lightning bolt with position "lightning bolt"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct LightningBolt; +pub struct LightningBoltMarker; + +pod_component_impl!(LightningBoltMarker); + +/// Entity wrapper for lightning bolt entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct LightningBolt { + id: EntityId, +} + +wrapper_from_query_impl!(LightningBolt, LightningBoltMarker); +entity_wrapper_impl!(LightningBolt, LightningBoltMarker); -pod_component_impl!(LightningBolt); +impl crate::HasEntityId for LightningBolt { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/llama.rs b/quill/common/src/entities/llama.rs index 0d6ebab54..19f16182f 100644 --- a/quill/common/src/entities/llama.rs +++ b/quill/common/src/entities/llama.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for llama entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all llamas: /// ```no_run -/// use quill::{Game, Position, entities::Llama}; +/// use quill::{Game, Position, entities::LlamaMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Llama)>() { -/// println!("Found a llama with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &LlamaMarker)>() { +/// println!("Found a llama with position "llama"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Llama; +pub struct LlamaMarker; + +pod_component_impl!(LlamaMarker); + +/// Entity wrapper for llama entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Llama { + id: EntityId, +} + +wrapper_from_query_impl!(Llama, LlamaMarker); +entity_wrapper_impl!(Llama, LlamaMarker); -pod_component_impl!(Llama); +impl crate::HasEntityId for Llama { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/llama_spit.rs b/quill/common/src/entities/llama_spit.rs index f6a4948de..2cc1d824e 100644 --- a/quill/common/src/entities/llama_spit.rs +++ b/quill/common/src/entities/llama_spit.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for llama spit entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all llama spits: /// ```no_run -/// use quill::{Game, Position, entities::LlamaSpit}; +/// use quill::{Game, Position, entities::LlamaSpitMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &LlamaSpit)>() { -/// println!("Found a llama spit with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &LlamaSpitMarker)>() { +/// println!("Found a llama spit with position "llama spit"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct LlamaSpit; +pub struct LlamaSpitMarker; + +pod_component_impl!(LlamaSpitMarker); + +/// Entity wrapper for llama spit entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct LlamaSpit { + id: EntityId, +} + +wrapper_from_query_impl!(LlamaSpit, LlamaSpitMarker); +entity_wrapper_impl!(LlamaSpit, LlamaSpitMarker); -pod_component_impl!(LlamaSpit); +impl crate::HasEntityId for LlamaSpit { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/magma_cube.rs b/quill/common/src/entities/magma_cube.rs index ab0b18736..33c8e904d 100644 --- a/quill/common/src/entities/magma_cube.rs +++ b/quill/common/src/entities/magma_cube.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for magma cube entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all magma cubes: /// ```no_run -/// use quill::{Game, Position, entities::MagmaCube}; +/// use quill::{Game, Position, entities::MagmaCubeMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &MagmaCube)>() { -/// println!("Found a magma cube with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &MagmaCubeMarker)>() { +/// println!("Found a magma cube with position "magma cube"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct MagmaCube; +pub struct MagmaCubeMarker; + +pod_component_impl!(MagmaCubeMarker); + +/// Entity wrapper for magma cube entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct MagmaCube { + id: EntityId, +} + +wrapper_from_query_impl!(MagmaCube, MagmaCubeMarker); +entity_wrapper_impl!(MagmaCube, MagmaCubeMarker); -pod_component_impl!(MagmaCube); +impl crate::HasEntityId for MagmaCube { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/minecart.rs b/quill/common/src/entities/minecart.rs index 25919dfbf..e22f79f5b 100644 --- a/quill/common/src/entities/minecart.rs +++ b/quill/common/src/entities/minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all minecarts: /// ```no_run -/// use quill::{Game, Position, entities::Minecart}; +/// use quill::{Game, Position, entities::MinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Minecart)>() { -/// println!("Found a minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &MinecartMarker)>() { +/// println!("Found a minecart with position "minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Minecart; +pub struct MinecartMarker; + +pod_component_impl!(MinecartMarker); + +/// Entity wrapper for minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Minecart { + id: EntityId, +} + +wrapper_from_query_impl!(Minecart, MinecartMarker); +entity_wrapper_impl!(Minecart, MinecartMarker); -pod_component_impl!(Minecart); +impl crate::HasEntityId for Minecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/mooshroom.rs b/quill/common/src/entities/mooshroom.rs index 2f5a6403d..d1a2fa017 100644 --- a/quill/common/src/entities/mooshroom.rs +++ b/quill/common/src/entities/mooshroom.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; + /// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all mooshrooms: /// ```no_run -/// use quill::{Game, Position, entities::Mooshroom}; +/// use quill::{Game, Position, entities::MooshroomMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Mooshroom)>() { -/// println!("Found a mooshroom with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &MooshroomMarker)>() { +/// println!("Found a mooshroom with position "mooshroom"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Mooshroom; +pub struct MooshroomMarker; + +pod_component_impl!(MooshroomMarker); + +/// Entity wrapper for mooshroom entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Mooshroom { + id: EntityId, +} + +wrapper_from_query_impl!(Mooshroom, MooshroomMarker); +entity_wrapper_impl!(Mooshroom, MooshroomMarker); -pod_component_impl!(Mooshroom); +impl crate::HasEntityId for Mooshroom { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/mule.rs b/quill/common/src/entities/mule.rs index fcebeabd9..334d315e8 100644 --- a/quill/common/src/entities/mule.rs +++ b/quill/common/src/entities/mule.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for mule entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all mules: /// ```no_run -/// use quill::{Game, Position, entities::Mule}; +/// use quill::{Game, Position, entities::MuleMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Mule)>() { -/// println!("Found a mule with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &MuleMarker)>() { +/// println!("Found a mule with position "mule"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Mule; +pub struct MuleMarker; + +pod_component_impl!(MuleMarker); + +/// Entity wrapper for mule entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Mule { + id: EntityId, +} + +wrapper_from_query_impl!(Mule, MuleMarker); +entity_wrapper_impl!(Mule, MuleMarker); -pod_component_impl!(Mule); +impl crate::HasEntityId for Mule { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/ocelot.rs b/quill/common/src/entities/ocelot.rs index 31b474209..7745c027f 100644 --- a/quill/common/src/entities/ocelot.rs +++ b/quill/common/src/entities/ocelot.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for ocelot entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all ocelots: /// ```no_run -/// use quill::{Game, Position, entities::Ocelot}; +/// use quill::{Game, Position, entities::OcelotMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Ocelot)>() { -/// println!("Found a ocelot with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &OcelotMarker)>() { +/// println!("Found a ocelot with position "ocelot"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Ocelot; +pub struct OcelotMarker; + +pod_component_impl!(OcelotMarker); + +/// Entity wrapper for ocelot entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Ocelot { + id: EntityId, +} + +wrapper_from_query_impl!(Ocelot, OcelotMarker); +entity_wrapper_impl!(Ocelot, OcelotMarker); -pod_component_impl!(Ocelot); +impl crate::HasEntityId for Ocelot { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/painting.rs b/quill/common/src/entities/painting.rs index e14abff7d..3d9f63355 100644 --- a/quill/common/src/entities/painting.rs +++ b/quill/common/src/entities/painting.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for painting entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all paintings: /// ```no_run -/// use quill::{Game, Position, entities::Painting}; +/// use quill::{Game, Position, entities::PaintingMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Painting)>() { -/// println!("Found a painting with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PaintingMarker)>() { +/// println!("Found a painting with position "painting"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Painting; +pub struct PaintingMarker; + +pod_component_impl!(PaintingMarker); + +/// Entity wrapper for painting entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Painting { + id: EntityId, +} + +wrapper_from_query_impl!(Painting, PaintingMarker); +entity_wrapper_impl!(Painting, PaintingMarker); -pod_component_impl!(Painting); +impl crate::HasEntityId for Painting { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/panda.rs b/quill/common/src/entities/panda.rs index 8bcd8b544..b92b8c811 100644 --- a/quill/common/src/entities/panda.rs +++ b/quill/common/src/entities/panda.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for panda entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all pandas: /// ```no_run -/// use quill::{Game, Position, entities::Panda}; +/// use quill::{Game, Position, entities::PandaMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Panda)>() { -/// println!("Found a panda with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PandaMarker)>() { +/// println!("Found a panda with position "panda"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Panda; +pub struct PandaMarker; + +pod_component_impl!(PandaMarker); + +/// Entity wrapper for panda entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Panda { + id: EntityId, +} + +wrapper_from_query_impl!(Panda, PandaMarker); +entity_wrapper_impl!(Panda, PandaMarker); -pod_component_impl!(Panda); +impl crate::HasEntityId for Panda { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/parrot.rs b/quill/common/src/entities/parrot.rs index f06afd167..7d1ba3667 100644 --- a/quill/common/src/entities/parrot.rs +++ b/quill/common/src/entities/parrot.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for parrot entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all parrots: /// ```no_run -/// use quill::{Game, Position, entities::Parrot}; +/// use quill::{Game, Position, entities::ParrotMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Parrot)>() { -/// println!("Found a parrot with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ParrotMarker)>() { +/// println!("Found a parrot with position "parrot"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Parrot; +pub struct ParrotMarker; + +pod_component_impl!(ParrotMarker); + +/// Entity wrapper for parrot entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Parrot { + id: EntityId, +} + +wrapper_from_query_impl!(Parrot, ParrotMarker); +entity_wrapper_impl!(Parrot, ParrotMarker); -pod_component_impl!(Parrot); +impl crate::HasEntityId for Parrot { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/phantom.rs b/quill/common/src/entities/phantom.rs index c5a839b8e..2f6c4cb9e 100644 --- a/quill/common/src/entities/phantom.rs +++ b/quill/common/src/entities/phantom.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for phantom entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all phantoms: /// ```no_run -/// use quill::{Game, Position, entities::Phantom}; +/// use quill::{Game, Position, entities::PhantomMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Phantom)>() { -/// println!("Found a phantom with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PhantomMarker)>() { +/// println!("Found a phantom with position "phantom"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Phantom; +pub struct PhantomMarker; + +pod_component_impl!(PhantomMarker); + +/// Entity wrapper for phantom entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Phantom { + id: EntityId, +} + +wrapper_from_query_impl!(Phantom, PhantomMarker); +entity_wrapper_impl!(Phantom, PhantomMarker); -pod_component_impl!(Phantom); +impl crate::HasEntityId for Phantom { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/pig.rs b/quill/common/src/entities/pig.rs index 753e2f019..c4d928806 100644 --- a/quill/common/src/entities/pig.rs +++ b/quill/common/src/entities/pig.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for pig entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all pigs: /// ```no_run -/// use quill::{Game, Position, entities::Pig}; +/// use quill::{Game, Position, entities::PigMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Pig)>() { -/// println!("Found a pig with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PigMarker)>() { +/// println!("Found a pig with position "pig"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Pig; +pub struct PigMarker; + +pod_component_impl!(PigMarker); + +/// Entity wrapper for pig entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Pig { + id: EntityId, +} + +wrapper_from_query_impl!(Pig, PigMarker); +entity_wrapper_impl!(Pig, PigMarker); -pod_component_impl!(Pig); +impl crate::HasEntityId for Pig { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/piglin.rs b/quill/common/src/entities/piglin.rs index 9f5ea2633..a1e20d3cb 100644 --- a/quill/common/src/entities/piglin.rs +++ b/quill/common/src/entities/piglin.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for piglin entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all piglins: /// ```no_run -/// use quill::{Game, Position, entities::Piglin}; +/// use quill::{Game, Position, entities::PiglinMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Piglin)>() { -/// println!("Found a piglin with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PiglinMarker)>() { +/// println!("Found a piglin with position "piglin"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Piglin; +pub struct PiglinMarker; + +pod_component_impl!(PiglinMarker); + +/// Entity wrapper for piglin entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Piglin { + id: EntityId, +} + +wrapper_from_query_impl!(Piglin, PiglinMarker); +entity_wrapper_impl!(Piglin, PiglinMarker); -pod_component_impl!(Piglin); +impl crate::HasEntityId for Piglin { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/piglin_brute.rs b/quill/common/src/entities/piglin_brute.rs index 0c27b5f6f..4ed253f56 100644 --- a/quill/common/src/entities/piglin_brute.rs +++ b/quill/common/src/entities/piglin_brute.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for piglin brute entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all piglin brutes: /// ```no_run -/// use quill::{Game, Position, entities::PiglinBrute}; +/// use quill::{Game, Position, entities::PiglinBruteMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &PiglinBrute)>() { -/// println!("Found a piglin brute with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PiglinBruteMarker)>() { +/// println!("Found a piglin brute with position "piglin brute"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct PiglinBrute; +pub struct PiglinBruteMarker; + +pod_component_impl!(PiglinBruteMarker); + +/// Entity wrapper for piglin brute entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct PiglinBrute { + id: EntityId, +} + +wrapper_from_query_impl!(PiglinBrute, PiglinBruteMarker); +entity_wrapper_impl!(PiglinBrute, PiglinBruteMarker); -pod_component_impl!(PiglinBrute); +impl crate::HasEntityId for PiglinBrute { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/pillager.rs b/quill/common/src/entities/pillager.rs index 8fb27bf60..6b29e2cef 100644 --- a/quill/common/src/entities/pillager.rs +++ b/quill/common/src/entities/pillager.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for pillager entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all pillagers: /// ```no_run -/// use quill::{Game, Position, entities::Pillager}; +/// use quill::{Game, Position, entities::PillagerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Pillager)>() { -/// println!("Found a pillager with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PillagerMarker)>() { +/// println!("Found a pillager with position "pillager"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Pillager; +pub struct PillagerMarker; + +pod_component_impl!(PillagerMarker); + +/// Entity wrapper for pillager entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Pillager { + id: EntityId, +} + +wrapper_from_query_impl!(Pillager, PillagerMarker); +entity_wrapper_impl!(Pillager, PillagerMarker); -pod_component_impl!(Pillager); +impl crate::HasEntityId for Pillager { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/player.rs b/quill/common/src/entities/player.rs index d971ca5d7..a62817088 100644 --- a/quill/common/src/entities/player.rs +++ b/quill/common/src/entities/player.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for player entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all players: /// ```no_run -/// use quill::{Game, Position, entities::Player}; +/// use quill::{Game, Position, entities::PlayerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Player)>() { -/// println!("Found a player with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PlayerMarker)>() { +/// println!("Found a player with position "player"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Player; +pub struct PlayerMarker; + +pod_component_impl!(PlayerMarker); + +/// Entity wrapper for player entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Player { + id: EntityId, +} + +wrapper_from_query_impl!(Player, PlayerMarker); +entity_wrapper_impl!(Player, PlayerMarker); -pod_component_impl!(Player); +impl crate::HasEntityId for Player { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/polar_bear.rs b/quill/common/src/entities/polar_bear.rs index b3f0e45c9..ec287f0f5 100644 --- a/quill/common/src/entities/polar_bear.rs +++ b/quill/common/src/entities/polar_bear.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for polar bear entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all polar bears: /// ```no_run -/// use quill::{Game, Position, entities::PolarBear}; +/// use quill::{Game, Position, entities::PolarBearMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &PolarBear)>() { -/// println!("Found a polar bear with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PolarBearMarker)>() { +/// println!("Found a polar bear with position "polar bear"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct PolarBear; +pub struct PolarBearMarker; + +pod_component_impl!(PolarBearMarker); + +/// Entity wrapper for polar bear entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct PolarBear { + id: EntityId, +} + +wrapper_from_query_impl!(PolarBear, PolarBearMarker); +entity_wrapper_impl!(PolarBear, PolarBearMarker); -pod_component_impl!(PolarBear); +impl crate::HasEntityId for PolarBear { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/potion.rs b/quill/common/src/entities/potion.rs index 77c898d86..2587a2f3c 100644 --- a/quill/common/src/entities/potion.rs +++ b/quill/common/src/entities/potion.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for potion entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all potions: /// ```no_run -/// use quill::{Game, Position, entities::Potion}; +/// use quill::{Game, Position, entities::PotionMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Potion)>() { -/// println!("Found a potion with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PotionMarker)>() { +/// println!("Found a potion with position "potion"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Potion; +pub struct PotionMarker; + +pod_component_impl!(PotionMarker); + +/// Entity wrapper for potion entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Potion { + id: EntityId, +} + +wrapper_from_query_impl!(Potion, PotionMarker); +entity_wrapper_impl!(Potion, PotionMarker); -pod_component_impl!(Potion); +impl crate::HasEntityId for Potion { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/pufferfish.rs b/quill/common/src/entities/pufferfish.rs index d400b1c6d..665ce577a 100644 --- a/quill/common/src/entities/pufferfish.rs +++ b/quill/common/src/entities/pufferfish.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for pufferfish entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all pufferfishs: /// ```no_run -/// use quill::{Game, Position, entities::Pufferfish}; +/// use quill::{Game, Position, entities::PufferfishMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Pufferfish)>() { -/// println!("Found a pufferfish with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &PufferfishMarker)>() { +/// println!("Found a pufferfish with position "pufferfish"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Pufferfish; +pub struct PufferfishMarker; + +pod_component_impl!(PufferfishMarker); + +/// Entity wrapper for pufferfish entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Pufferfish { + id: EntityId, +} + +wrapper_from_query_impl!(Pufferfish, PufferfishMarker); +entity_wrapper_impl!(Pufferfish, PufferfishMarker); -pod_component_impl!(Pufferfish); +impl crate::HasEntityId for Pufferfish { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/rabbit.rs b/quill/common/src/entities/rabbit.rs index 989fde181..2b5ffb80e 100644 --- a/quill/common/src/entities/rabbit.rs +++ b/quill/common/src/entities/rabbit.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for rabbit entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all rabbits: /// ```no_run -/// use quill::{Game, Position, entities::Rabbit}; +/// use quill::{Game, Position, entities::RabbitMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Rabbit)>() { -/// println!("Found a rabbit with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &RabbitMarker)>() { +/// println!("Found a rabbit with position "rabbit"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Rabbit; +pub struct RabbitMarker; + +pod_component_impl!(RabbitMarker); + +/// Entity wrapper for rabbit entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Rabbit { + id: EntityId, +} + +wrapper_from_query_impl!(Rabbit, RabbitMarker); +entity_wrapper_impl!(Rabbit, RabbitMarker); -pod_component_impl!(Rabbit); +impl crate::HasEntityId for Rabbit { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/ravager.rs b/quill/common/src/entities/ravager.rs index e73a9e98a..1e8c19ea0 100644 --- a/quill/common/src/entities/ravager.rs +++ b/quill/common/src/entities/ravager.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for ravager entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all ravagers: /// ```no_run -/// use quill::{Game, Position, entities::Ravager}; +/// use quill::{Game, Position, entities::RavagerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Ravager)>() { -/// println!("Found a ravager with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &RavagerMarker)>() { +/// println!("Found a ravager with position "ravager"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Ravager; +pub struct RavagerMarker; + +pod_component_impl!(RavagerMarker); + +/// Entity wrapper for ravager entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Ravager { + id: EntityId, +} + +wrapper_from_query_impl!(Ravager, RavagerMarker); +entity_wrapper_impl!(Ravager, RavagerMarker); -pod_component_impl!(Ravager); +impl crate::HasEntityId for Ravager { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/salmon.rs b/quill/common/src/entities/salmon.rs index 996a3b8e5..fca145e73 100644 --- a/quill/common/src/entities/salmon.rs +++ b/quill/common/src/entities/salmon.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for salmon entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all salmons: /// ```no_run -/// use quill::{Game, Position, entities::Salmon}; +/// use quill::{Game, Position, entities::SalmonMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Salmon)>() { -/// println!("Found a salmon with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SalmonMarker)>() { +/// println!("Found a salmon with position "salmon"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Salmon; +pub struct SalmonMarker; + +pod_component_impl!(SalmonMarker); + +/// Entity wrapper for salmon entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Salmon { + id: EntityId, +} + +wrapper_from_query_impl!(Salmon, SalmonMarker); +entity_wrapper_impl!(Salmon, SalmonMarker); -pod_component_impl!(Salmon); +impl crate::HasEntityId for Salmon { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/sheep.rs b/quill/common/src/entities/sheep.rs index cd7202db2..72cdd9136 100644 --- a/quill/common/src/entities/sheep.rs +++ b/quill/common/src/entities/sheep.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for sheep entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all sheeps: /// ```no_run -/// use quill::{Game, Position, entities::Sheep}; +/// use quill::{Game, Position, entities::SheepMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Sheep)>() { -/// println!("Found a sheep with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SheepMarker)>() { +/// println!("Found a sheep with position "sheep"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Sheep; +pub struct SheepMarker; + +pod_component_impl!(SheepMarker); + +/// Entity wrapper for sheep entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Sheep { + id: EntityId, +} + +wrapper_from_query_impl!(Sheep, SheepMarker); +entity_wrapper_impl!(Sheep, SheepMarker); -pod_component_impl!(Sheep); +impl crate::HasEntityId for Sheep { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/shulker.rs b/quill/common/src/entities/shulker.rs index f33b15624..e04816611 100644 --- a/quill/common/src/entities/shulker.rs +++ b/quill/common/src/entities/shulker.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for shulker entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all shulkers: /// ```no_run -/// use quill::{Game, Position, entities::Shulker}; +/// use quill::{Game, Position, entities::ShulkerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Shulker)>() { -/// println!("Found a shulker with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ShulkerMarker)>() { +/// println!("Found a shulker with position "shulker"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Shulker; +pub struct ShulkerMarker; + +pod_component_impl!(ShulkerMarker); + +/// Entity wrapper for shulker entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Shulker { + id: EntityId, +} + +wrapper_from_query_impl!(Shulker, ShulkerMarker); +entity_wrapper_impl!(Shulker, ShulkerMarker); -pod_component_impl!(Shulker); +impl crate::HasEntityId for Shulker { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/shulker_bullet.rs b/quill/common/src/entities/shulker_bullet.rs index edd923bc4..99ae6aacd 100644 --- a/quill/common/src/entities/shulker_bullet.rs +++ b/quill/common/src/entities/shulker_bullet.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for shulker bullet entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all shulker bullets: /// ```no_run -/// use quill::{Game, Position, entities::ShulkerBullet}; +/// use quill::{Game, Position, entities::ShulkerBulletMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ShulkerBullet)>() { -/// println!("Found a shulker bullet with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ShulkerBulletMarker)>() { +/// println!("Found a shulker bullet with position "shulker bullet"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ShulkerBullet; +pub struct ShulkerBulletMarker; + +pod_component_impl!(ShulkerBulletMarker); + +/// Entity wrapper for shulker bullet entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ShulkerBullet { + id: EntityId, +} + +wrapper_from_query_impl!(ShulkerBullet, ShulkerBulletMarker); +entity_wrapper_impl!(ShulkerBullet, ShulkerBulletMarker); -pod_component_impl!(ShulkerBullet); +impl crate::HasEntityId for ShulkerBullet { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/silverfish.rs b/quill/common/src/entities/silverfish.rs index 990808a38..92f9890d8 100644 --- a/quill/common/src/entities/silverfish.rs +++ b/quill/common/src/entities/silverfish.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for silverfish entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all silverfishs: /// ```no_run -/// use quill::{Game, Position, entities::Silverfish}; +/// use quill::{Game, Position, entities::SilverfishMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Silverfish)>() { -/// println!("Found a silverfish with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SilverfishMarker)>() { +/// println!("Found a silverfish with position "silverfish"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Silverfish; +pub struct SilverfishMarker; + +pod_component_impl!(SilverfishMarker); + +/// Entity wrapper for silverfish entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Silverfish { + id: EntityId, +} + +wrapper_from_query_impl!(Silverfish, SilverfishMarker); +entity_wrapper_impl!(Silverfish, SilverfishMarker); -pod_component_impl!(Silverfish); +impl crate::HasEntityId for Silverfish { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/skeleton.rs b/quill/common/src/entities/skeleton.rs index 7162a368d..48d97d39c 100644 --- a/quill/common/src/entities/skeleton.rs +++ b/quill/common/src/entities/skeleton.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for skeleton entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all skeletons: /// ```no_run -/// use quill::{Game, Position, entities::Skeleton}; +/// use quill::{Game, Position, entities::SkeletonMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Skeleton)>() { -/// println!("Found a skeleton with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SkeletonMarker)>() { +/// println!("Found a skeleton with position "skeleton"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Skeleton; +pub struct SkeletonMarker; + +pod_component_impl!(SkeletonMarker); + +/// Entity wrapper for skeleton entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Skeleton { + id: EntityId, +} + +wrapper_from_query_impl!(Skeleton, SkeletonMarker); +entity_wrapper_impl!(Skeleton, SkeletonMarker); -pod_component_impl!(Skeleton); +impl crate::HasEntityId for Skeleton { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/skeleton_horse.rs b/quill/common/src/entities/skeleton_horse.rs index 0c14ff853..d3d7c3972 100644 --- a/quill/common/src/entities/skeleton_horse.rs +++ b/quill/common/src/entities/skeleton_horse.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for skeleton horse entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all skeleton horses: /// ```no_run -/// use quill::{Game, Position, entities::SkeletonHorse}; +/// use quill::{Game, Position, entities::SkeletonHorseMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &SkeletonHorse)>() { -/// println!("Found a skeleton horse with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SkeletonHorseMarker)>() { +/// println!("Found a skeleton horse with position "skeleton horse"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct SkeletonHorse; +pub struct SkeletonHorseMarker; + +pod_component_impl!(SkeletonHorseMarker); + +/// Entity wrapper for skeleton horse entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct SkeletonHorse { + id: EntityId, +} + +wrapper_from_query_impl!(SkeletonHorse, SkeletonHorseMarker); +entity_wrapper_impl!(SkeletonHorse, SkeletonHorseMarker); -pod_component_impl!(SkeletonHorse); +impl crate::HasEntityId for SkeletonHorse { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/slime.rs b/quill/common/src/entities/slime.rs index 756c503b5..a4068dea9 100644 --- a/quill/common/src/entities/slime.rs +++ b/quill/common/src/entities/slime.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for slime entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all slimes: /// ```no_run -/// use quill::{Game, Position, entities::Slime}; +/// use quill::{Game, Position, entities::SlimeMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Slime)>() { -/// println!("Found a slime with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SlimeMarker)>() { +/// println!("Found a slime with position "slime"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Slime; +pub struct SlimeMarker; + +pod_component_impl!(SlimeMarker); + +/// Entity wrapper for slime entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Slime { + id: EntityId, +} + +wrapper_from_query_impl!(Slime, SlimeMarker); +entity_wrapper_impl!(Slime, SlimeMarker); -pod_component_impl!(Slime); +impl crate::HasEntityId for Slime { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/small_fireball.rs b/quill/common/src/entities/small_fireball.rs index 07d50e0a2..25ea28e55 100644 --- a/quill/common/src/entities/small_fireball.rs +++ b/quill/common/src/entities/small_fireball.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for small fireball entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all small fireballs: /// ```no_run -/// use quill::{Game, Position, entities::SmallFireball}; +/// use quill::{Game, Position, entities::SmallFireballMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &SmallFireball)>() { -/// println!("Found a small fireball with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SmallFireballMarker)>() { +/// println!("Found a small fireball with position "small fireball"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct SmallFireball; +pub struct SmallFireballMarker; + +pod_component_impl!(SmallFireballMarker); + +/// Entity wrapper for small fireball entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct SmallFireball { + id: EntityId, +} + +wrapper_from_query_impl!(SmallFireball, SmallFireballMarker); +entity_wrapper_impl!(SmallFireball, SmallFireballMarker); -pod_component_impl!(SmallFireball); +impl crate::HasEntityId for SmallFireball { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/snow_golem.rs b/quill/common/src/entities/snow_golem.rs index df0491083..616a9dfd3 100644 --- a/quill/common/src/entities/snow_golem.rs +++ b/quill/common/src/entities/snow_golem.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for snow golem entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all snow golems: /// ```no_run -/// use quill::{Game, Position, entities::SnowGolem}; +/// use quill::{Game, Position, entities::SnowGolemMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &SnowGolem)>() { -/// println!("Found a snow golem with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SnowGolemMarker)>() { +/// println!("Found a snow golem with position "snow golem"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct SnowGolem; +pub struct SnowGolemMarker; + +pod_component_impl!(SnowGolemMarker); + +/// Entity wrapper for snow golem entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct SnowGolem { + id: EntityId, +} + +wrapper_from_query_impl!(SnowGolem, SnowGolemMarker); +entity_wrapper_impl!(SnowGolem, SnowGolemMarker); -pod_component_impl!(SnowGolem); +impl crate::HasEntityId for SnowGolem { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/snowball.rs b/quill/common/src/entities/snowball.rs index ea823c696..3c384d38d 100644 --- a/quill/common/src/entities/snowball.rs +++ b/quill/common/src/entities/snowball.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for snowball entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all snowballs: /// ```no_run -/// use quill::{Game, Position, entities::Snowball}; +/// use quill::{Game, Position, entities::SnowballMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Snowball)>() { -/// println!("Found a snowball with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SnowballMarker)>() { +/// println!("Found a snowball with position "snowball"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Snowball; +pub struct SnowballMarker; + +pod_component_impl!(SnowballMarker); + +/// Entity wrapper for snowball entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Snowball { + id: EntityId, +} + +wrapper_from_query_impl!(Snowball, SnowballMarker); +entity_wrapper_impl!(Snowball, SnowballMarker); -pod_component_impl!(Snowball); +impl crate::HasEntityId for Snowball { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/spawner_minecart.rs b/quill/common/src/entities/spawner_minecart.rs index c5584a9cd..3090b530d 100644 --- a/quill/common/src/entities/spawner_minecart.rs +++ b/quill/common/src/entities/spawner_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for spawner minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all spawner minecarts: /// ```no_run -/// use quill::{Game, Position, entities::SpawnerMinecart}; +/// use quill::{Game, Position, entities::SpawnerMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &SpawnerMinecart)>() { -/// println!("Found a spawner minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SpawnerMinecartMarker)>() { +/// println!("Found a spawner minecart with position "spawner minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct SpawnerMinecart; +pub struct SpawnerMinecartMarker; + +pod_component_impl!(SpawnerMinecartMarker); + +/// Entity wrapper for spawner minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct SpawnerMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(SpawnerMinecart, SpawnerMinecartMarker); +entity_wrapper_impl!(SpawnerMinecart, SpawnerMinecartMarker); -pod_component_impl!(SpawnerMinecart); +impl crate::HasEntityId for SpawnerMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/spectral_arrow.rs b/quill/common/src/entities/spectral_arrow.rs index 8a78f908c..36a5d6c4b 100644 --- a/quill/common/src/entities/spectral_arrow.rs +++ b/quill/common/src/entities/spectral_arrow.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for spectral arrow entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all spectral arrows: /// ```no_run -/// use quill::{Game, Position, entities::SpectralArrow}; +/// use quill::{Game, Position, entities::SpectralArrowMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &SpectralArrow)>() { -/// println!("Found a spectral arrow with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SpectralArrowMarker)>() { +/// println!("Found a spectral arrow with position "spectral arrow"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct SpectralArrow; +pub struct SpectralArrowMarker; + +pod_component_impl!(SpectralArrowMarker); + +/// Entity wrapper for spectral arrow entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct SpectralArrow { + id: EntityId, +} + +wrapper_from_query_impl!(SpectralArrow, SpectralArrowMarker); +entity_wrapper_impl!(SpectralArrow, SpectralArrowMarker); -pod_component_impl!(SpectralArrow); +impl crate::HasEntityId for SpectralArrow { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/spider.rs b/quill/common/src/entities/spider.rs index 85c5fcdc3..326de12e8 100644 --- a/quill/common/src/entities/spider.rs +++ b/quill/common/src/entities/spider.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for spider entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all spiders: /// ```no_run -/// use quill::{Game, Position, entities::Spider}; +/// use quill::{Game, Position, entities::SpiderMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Spider)>() { -/// println!("Found a spider with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SpiderMarker)>() { +/// println!("Found a spider with position "spider"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Spider; +pub struct SpiderMarker; + +pod_component_impl!(SpiderMarker); + +/// Entity wrapper for spider entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Spider { + id: EntityId, +} + +wrapper_from_query_impl!(Spider, SpiderMarker); +entity_wrapper_impl!(Spider, SpiderMarker); -pod_component_impl!(Spider); +impl crate::HasEntityId for Spider { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/squid.rs b/quill/common/src/entities/squid.rs index 479364cb9..c8ec424c3 100644 --- a/quill/common/src/entities/squid.rs +++ b/quill/common/src/entities/squid.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for squid entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all squids: /// ```no_run -/// use quill::{Game, Position, entities::Squid}; +/// use quill::{Game, Position, entities::SquidMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Squid)>() { -/// println!("Found a squid with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &SquidMarker)>() { +/// println!("Found a squid with position "squid"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Squid; +pub struct SquidMarker; + +pod_component_impl!(SquidMarker); + +/// Entity wrapper for squid entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Squid { + id: EntityId, +} + +wrapper_from_query_impl!(Squid, SquidMarker); +entity_wrapper_impl!(Squid, SquidMarker); -pod_component_impl!(Squid); +impl crate::HasEntityId for Squid { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/stray.rs b/quill/common/src/entities/stray.rs index 92c952bc9..8ab56c550 100644 --- a/quill/common/src/entities/stray.rs +++ b/quill/common/src/entities/stray.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for stray entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all strays: /// ```no_run -/// use quill::{Game, Position, entities::Stray}; +/// use quill::{Game, Position, entities::StrayMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Stray)>() { -/// println!("Found a stray with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &StrayMarker)>() { +/// println!("Found a stray with position "stray"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Stray; +pub struct StrayMarker; + +pod_component_impl!(StrayMarker); + +/// Entity wrapper for stray entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Stray { + id: EntityId, +} + +wrapper_from_query_impl!(Stray, StrayMarker); +entity_wrapper_impl!(Stray, StrayMarker); -pod_component_impl!(Stray); +impl crate::HasEntityId for Stray { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/strider.rs b/quill/common/src/entities/strider.rs index 63194fd1e..353a24882 100644 --- a/quill/common/src/entities/strider.rs +++ b/quill/common/src/entities/strider.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for strider entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all striders: /// ```no_run -/// use quill::{Game, Position, entities::Strider}; +/// use quill::{Game, Position, entities::StriderMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Strider)>() { -/// println!("Found a strider with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &StriderMarker)>() { +/// println!("Found a strider with position "strider"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Strider; +pub struct StriderMarker; + +pod_component_impl!(StriderMarker); + +/// Entity wrapper for strider entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Strider { + id: EntityId, +} + +wrapper_from_query_impl!(Strider, StriderMarker); +entity_wrapper_impl!(Strider, StriderMarker); -pod_component_impl!(Strider); +impl crate::HasEntityId for Strider { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/tnt.rs b/quill/common/src/entities/tnt.rs index 6dbd66814..879640b01 100644 --- a/quill/common/src/entities/tnt.rs +++ b/quill/common/src/entities/tnt.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for tnt entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all tnts: /// ```no_run -/// use quill::{Game, Position, entities::Tnt}; +/// use quill::{Game, Position, entities::TntMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Tnt)>() { -/// println!("Found a tnt with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TntMarker)>() { +/// println!("Found a tnt with position "tnt"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Tnt; +pub struct TntMarker; + +pod_component_impl!(TntMarker); + +/// Entity wrapper for tnt entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Tnt { + id: EntityId, +} + +wrapper_from_query_impl!(Tnt, TntMarker); +entity_wrapper_impl!(Tnt, TntMarker); -pod_component_impl!(Tnt); +impl crate::HasEntityId for Tnt { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/tnt_minecart.rs b/quill/common/src/entities/tnt_minecart.rs index e9b5e4962..66b015a16 100644 --- a/quill/common/src/entities/tnt_minecart.rs +++ b/quill/common/src/entities/tnt_minecart.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for tnt minecart entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all tnt minecarts: /// ```no_run -/// use quill::{Game, Position, entities::TntMinecart}; +/// use quill::{Game, Position, entities::TntMinecartMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &TntMinecart)>() { -/// println!("Found a tnt minecart with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TntMinecartMarker)>() { +/// println!("Found a tnt minecart with position "tnt minecart"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct TntMinecart; +pub struct TntMinecartMarker; + +pod_component_impl!(TntMinecartMarker); + +/// Entity wrapper for tnt minecart entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct TntMinecart { + id: EntityId, +} + +wrapper_from_query_impl!(TntMinecart, TntMinecartMarker); +entity_wrapper_impl!(TntMinecart, TntMinecartMarker); -pod_component_impl!(TntMinecart); +impl crate::HasEntityId for TntMinecart { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/trader_llama.rs b/quill/common/src/entities/trader_llama.rs index e8ef11d57..210f3cd3d 100644 --- a/quill/common/src/entities/trader_llama.rs +++ b/quill/common/src/entities/trader_llama.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for trader llama entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all trader llamas: /// ```no_run -/// use quill::{Game, Position, entities::TraderLlama}; +/// use quill::{Game, Position, entities::TraderLlamaMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &TraderLlama)>() { -/// println!("Found a trader llama with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TraderLlamaMarker)>() { +/// println!("Found a trader llama with position "trader llama"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct TraderLlama; +pub struct TraderLlamaMarker; + +pod_component_impl!(TraderLlamaMarker); + +/// Entity wrapper for trader llama entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct TraderLlama { + id: EntityId, +} + +wrapper_from_query_impl!(TraderLlama, TraderLlamaMarker); +entity_wrapper_impl!(TraderLlama, TraderLlamaMarker); -pod_component_impl!(TraderLlama); +impl crate::HasEntityId for TraderLlama { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/trident.rs b/quill/common/src/entities/trident.rs index 41612484b..71133d813 100644 --- a/quill/common/src/entities/trident.rs +++ b/quill/common/src/entities/trident.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for trident entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all tridents: /// ```no_run -/// use quill::{Game, Position, entities::Trident}; +/// use quill::{Game, Position, entities::TridentMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Trident)>() { -/// println!("Found a trident with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TridentMarker)>() { +/// println!("Found a trident with position "trident"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Trident; +pub struct TridentMarker; + +pod_component_impl!(TridentMarker); + +/// Entity wrapper for trident entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Trident { + id: EntityId, +} + +wrapper_from_query_impl!(Trident, TridentMarker); +entity_wrapper_impl!(Trident, TridentMarker); -pod_component_impl!(Trident); +impl crate::HasEntityId for Trident { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/tropical_fish.rs b/quill/common/src/entities/tropical_fish.rs index 2d6b02c25..f4b8e9c9a 100644 --- a/quill/common/src/entities/tropical_fish.rs +++ b/quill/common/src/entities/tropical_fish.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for tropical fish entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all tropical fishs: /// ```no_run -/// use quill::{Game, Position, entities::TropicalFish}; +/// use quill::{Game, Position, entities::TropicalFishMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &TropicalFish)>() { -/// println!("Found a tropical fish with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TropicalFishMarker)>() { +/// println!("Found a tropical fish with position "tropical fish"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct TropicalFish; +pub struct TropicalFishMarker; + +pod_component_impl!(TropicalFishMarker); + +/// Entity wrapper for tropical fish entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct TropicalFish { + id: EntityId, +} + +wrapper_from_query_impl!(TropicalFish, TropicalFishMarker); +entity_wrapper_impl!(TropicalFish, TropicalFishMarker); -pod_component_impl!(TropicalFish); +impl crate::HasEntityId for TropicalFish { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/turtle.rs b/quill/common/src/entities/turtle.rs index efe77937b..59ffb0a05 100644 --- a/quill/common/src/entities/turtle.rs +++ b/quill/common/src/entities/turtle.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for turtle entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all turtles: /// ```no_run -/// use quill::{Game, Position, entities::Turtle}; +/// use quill::{Game, Position, entities::TurtleMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Turtle)>() { -/// println!("Found a turtle with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &TurtleMarker)>() { +/// println!("Found a turtle with position "turtle"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Turtle; +pub struct TurtleMarker; + +pod_component_impl!(TurtleMarker); + +/// Entity wrapper for turtle entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Turtle { + id: EntityId, +} + +wrapper_from_query_impl!(Turtle, TurtleMarker); +entity_wrapper_impl!(Turtle, TurtleMarker); -pod_component_impl!(Turtle); +impl crate::HasEntityId for Turtle { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/vex.rs b/quill/common/src/entities/vex.rs index e165bd310..0863e642a 100644 --- a/quill/common/src/entities/vex.rs +++ b/quill/common/src/entities/vex.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for vex entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all vexs: /// ```no_run -/// use quill::{Game, Position, entities::Vex}; +/// use quill::{Game, Position, entities::VexMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Vex)>() { -/// println!("Found a vex with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &VexMarker)>() { +/// println!("Found a vex with position "vex"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Vex; +pub struct VexMarker; + +pod_component_impl!(VexMarker); + +/// Entity wrapper for vex entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Vex { + id: EntityId, +} + +wrapper_from_query_impl!(Vex, VexMarker); +entity_wrapper_impl!(Vex, VexMarker); -pod_component_impl!(Vex); +impl crate::HasEntityId for Vex { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/villager.rs b/quill/common/src/entities/villager.rs index e42e253a4..34ec036ad 100644 --- a/quill/common/src/entities/villager.rs +++ b/quill/common/src/entities/villager.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for villager entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all villagers: /// ```no_run -/// use quill::{Game, Position, entities::Villager}; +/// use quill::{Game, Position, entities::VillagerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Villager)>() { -/// println!("Found a villager with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &VillagerMarker)>() { +/// println!("Found a villager with position "villager"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Villager; +pub struct VillagerMarker; + +pod_component_impl!(VillagerMarker); + +/// Entity wrapper for villager entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Villager { + id: EntityId, +} + +wrapper_from_query_impl!(Villager, VillagerMarker); +entity_wrapper_impl!(Villager, VillagerMarker); -pod_component_impl!(Villager); +impl crate::HasEntityId for Villager { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/vindicator.rs b/quill/common/src/entities/vindicator.rs index 9eb5e0092..778ecd4a7 100644 --- a/quill/common/src/entities/vindicator.rs +++ b/quill/common/src/entities/vindicator.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for vindicator entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all vindicators: /// ```no_run -/// use quill::{Game, Position, entities::Vindicator}; +/// use quill::{Game, Position, entities::VindicatorMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Vindicator)>() { -/// println!("Found a vindicator with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &VindicatorMarker)>() { +/// println!("Found a vindicator with position "vindicator"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Vindicator; +pub struct VindicatorMarker; + +pod_component_impl!(VindicatorMarker); + +/// Entity wrapper for vindicator entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Vindicator { + id: EntityId, +} + +wrapper_from_query_impl!(Vindicator, VindicatorMarker); +entity_wrapper_impl!(Vindicator, VindicatorMarker); -pod_component_impl!(Vindicator); +impl crate::HasEntityId for Vindicator { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/wandering_trader.rs b/quill/common/src/entities/wandering_trader.rs index a8f0c9b7a..96ab502bd 100644 --- a/quill/common/src/entities/wandering_trader.rs +++ b/quill/common/src/entities/wandering_trader.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for wandering trader entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all wandering traders: /// ```no_run -/// use quill::{Game, Position, entities::WanderingTrader}; +/// use quill::{Game, Position, entities::WanderingTraderMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &WanderingTrader)>() { -/// println!("Found a wandering trader with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WanderingTraderMarker)>() { +/// println!("Found a wandering trader with position "wandering trader"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct WanderingTrader; +pub struct WanderingTraderMarker; + +pod_component_impl!(WanderingTraderMarker); + +/// Entity wrapper for wandering trader entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct WanderingTrader { + id: EntityId, +} + +wrapper_from_query_impl!(WanderingTrader, WanderingTraderMarker); +entity_wrapper_impl!(WanderingTrader, WanderingTraderMarker); -pod_component_impl!(WanderingTrader); +impl crate::HasEntityId for WanderingTrader { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/witch.rs b/quill/common/src/entities/witch.rs index fcb261562..5525af173 100644 --- a/quill/common/src/entities/witch.rs +++ b/quill/common/src/entities/witch.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for witch entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all witchs: /// ```no_run -/// use quill::{Game, Position, entities::Witch}; +/// use quill::{Game, Position, entities::WitchMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Witch)>() { -/// println!("Found a witch with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WitchMarker)>() { +/// println!("Found a witch with position "witch"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Witch; +pub struct WitchMarker; + +pod_component_impl!(WitchMarker); + +/// Entity wrapper for witch entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Witch { + id: EntityId, +} + +wrapper_from_query_impl!(Witch, WitchMarker); +entity_wrapper_impl!(Witch, WitchMarker); -pod_component_impl!(Witch); +impl crate::HasEntityId for Witch { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/wither.rs b/quill/common/src/entities/wither.rs index 1e0a0a765..ce6babf32 100644 --- a/quill/common/src/entities/wither.rs +++ b/quill/common/src/entities/wither.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for wither entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all withers: /// ```no_run -/// use quill::{Game, Position, entities::Wither}; +/// use quill::{Game, Position, entities::WitherMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Wither)>() { -/// println!("Found a wither with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WitherMarker)>() { +/// println!("Found a wither with position "wither"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Wither; +pub struct WitherMarker; + +pod_component_impl!(WitherMarker); + +/// Entity wrapper for wither entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Wither { + id: EntityId, +} + +wrapper_from_query_impl!(Wither, WitherMarker); +entity_wrapper_impl!(Wither, WitherMarker); -pod_component_impl!(Wither); +impl crate::HasEntityId for Wither { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/wither_skeleton.rs b/quill/common/src/entities/wither_skeleton.rs index baaff5de5..ba89f8550 100644 --- a/quill/common/src/entities/wither_skeleton.rs +++ b/quill/common/src/entities/wither_skeleton.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for wither skeleton entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all wither skeletons: /// ```no_run -/// use quill::{Game, Position, entities::WitherSkeleton}; +/// use quill::{Game, Position, entities::WitherSkeletonMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &WitherSkeleton)>() { -/// println!("Found a wither skeleton with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WitherSkeletonMarker)>() { +/// println!("Found a wither skeleton with position "wither skeleton"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct WitherSkeleton; +pub struct WitherSkeletonMarker; + +pod_component_impl!(WitherSkeletonMarker); + +/// Entity wrapper for wither skeleton entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct WitherSkeleton { + id: EntityId, +} + +wrapper_from_query_impl!(WitherSkeleton, WitherSkeletonMarker); +entity_wrapper_impl!(WitherSkeleton, WitherSkeletonMarker); -pod_component_impl!(WitherSkeleton); +impl crate::HasEntityId for WitherSkeleton { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/wither_skull.rs b/quill/common/src/entities/wither_skull.rs index 641a0a729..47562d62f 100644 --- a/quill/common/src/entities/wither_skull.rs +++ b/quill/common/src/entities/wither_skull.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for wither skull entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all wither skulls: /// ```no_run -/// use quill::{Game, Position, entities::WitherSkull}; +/// use quill::{Game, Position, entities::WitherSkullMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &WitherSkull)>() { -/// println!("Found a wither skull with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WitherSkullMarker)>() { +/// println!("Found a wither skull with position "wither skull"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct WitherSkull; +pub struct WitherSkullMarker; + +pod_component_impl!(WitherSkullMarker); + +/// Entity wrapper for wither skull entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct WitherSkull { + id: EntityId, +} + +wrapper_from_query_impl!(WitherSkull, WitherSkullMarker); +entity_wrapper_impl!(WitherSkull, WitherSkullMarker); -pod_component_impl!(WitherSkull); +impl crate::HasEntityId for WitherSkull { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/wolf.rs b/quill/common/src/entities/wolf.rs index 4376907d6..e44b12fbe 100644 --- a/quill/common/src/entities/wolf.rs +++ b/quill/common/src/entities/wolf.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for wolf entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all wolfs: /// ```no_run -/// use quill::{Game, Position, entities::Wolf}; +/// use quill::{Game, Position, entities::WolfMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Wolf)>() { -/// println!("Found a wolf with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &WolfMarker)>() { +/// println!("Found a wolf with position "wolf"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Wolf; +pub struct WolfMarker; + +pod_component_impl!(WolfMarker); + +/// Entity wrapper for wolf entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Wolf { + id: EntityId, +} + +wrapper_from_query_impl!(Wolf, WolfMarker); +entity_wrapper_impl!(Wolf, WolfMarker); -pod_component_impl!(Wolf); +impl crate::HasEntityId for Wolf { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/zoglin.rs b/quill/common/src/entities/zoglin.rs index 8793439a2..62de4bfff 100644 --- a/quill/common/src/entities/zoglin.rs +++ b/quill/common/src/entities/zoglin.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for zoglin entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all zoglins: /// ```no_run -/// use quill::{Game, Position, entities::Zoglin}; +/// use quill::{Game, Position, entities::ZoglinMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Zoglin)>() { -/// println!("Found a zoglin with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ZoglinMarker)>() { +/// println!("Found a zoglin with position "zoglin"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Zoglin; +pub struct ZoglinMarker; + +pod_component_impl!(ZoglinMarker); + +/// Entity wrapper for zoglin entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Zoglin { + id: EntityId, +} + +wrapper_from_query_impl!(Zoglin, ZoglinMarker); +entity_wrapper_impl!(Zoglin, ZoglinMarker); -pod_component_impl!(Zoglin); +impl crate::HasEntityId for Zoglin { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/zombie.rs b/quill/common/src/entities/zombie.rs index 3532a6362..72d10c8c5 100644 --- a/quill/common/src/entities/zombie.rs +++ b/quill/common/src/entities/zombie.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for zombie entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all zombies: /// ```no_run -/// use quill::{Game, Position, entities::Zombie}; +/// use quill::{Game, Position, entities::ZombieMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &Zombie)>() { -/// println!("Found a zombie with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ZombieMarker)>() { +/// println!("Found a zombie with position "zombie"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct Zombie; +pub struct ZombieMarker; + +pod_component_impl!(ZombieMarker); + +/// Entity wrapper for zombie entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct Zombie { + id: EntityId, +} + +wrapper_from_query_impl!(Zombie, ZombieMarker); +entity_wrapper_impl!(Zombie, ZombieMarker); -pod_component_impl!(Zombie); +impl crate::HasEntityId for Zombie { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/zombie_horse.rs b/quill/common/src/entities/zombie_horse.rs index dc08fb6f7..f440ae8f5 100644 --- a/quill/common/src/entities/zombie_horse.rs +++ b/quill/common/src/entities/zombie_horse.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for zombie horse entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all zombie horses: /// ```no_run -/// use quill::{Game, Position, entities::ZombieHorse}; +/// use quill::{Game, Position, entities::ZombieHorseMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ZombieHorse)>() { -/// println!("Found a zombie horse with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ZombieHorseMarker)>() { +/// println!("Found a zombie horse with position "zombie horse"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ZombieHorse; +pub struct ZombieHorseMarker; + +pod_component_impl!(ZombieHorseMarker); + +/// Entity wrapper for zombie horse entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ZombieHorse { + id: EntityId, +} + +wrapper_from_query_impl!(ZombieHorse, ZombieHorseMarker); +entity_wrapper_impl!(ZombieHorse, ZombieHorseMarker); -pod_component_impl!(ZombieHorse); +impl crate::HasEntityId for ZombieHorse { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/zombie_villager.rs b/quill/common/src/entities/zombie_villager.rs index b86ab2d97..8cc490a53 100644 --- a/quill/common/src/entities/zombie_villager.rs +++ b/quill/common/src/entities/zombie_villager.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for zombie villager entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all zombie villagers: /// ```no_run -/// use quill::{Game, Position, entities::ZombieVillager}; +/// use quill::{Game, Position, entities::ZombieVillagerMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ZombieVillager)>() { -/// println!("Found a zombie villager with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ZombieVillagerMarker)>() { +/// println!("Found a zombie villager with position "zombie villager"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ZombieVillager; +pub struct ZombieVillagerMarker; + +pod_component_impl!(ZombieVillagerMarker); + +/// Entity wrapper for zombie villager entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ZombieVillager { + id: EntityId, +} + +wrapper_from_query_impl!(ZombieVillager, ZombieVillagerMarker); +entity_wrapper_impl!(ZombieVillager, ZombieVillagerMarker); -pod_component_impl!(ZombieVillager); +impl crate::HasEntityId for ZombieVillager { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entities/zombified_piglin.rs b/quill/common/src/entities/zombified_piglin.rs index 057fbbc25..22422e040 100644 --- a/quill/common/src/entities/zombified_piglin.rs +++ b/quill/common/src/entities/zombified_piglin.rs @@ -1,19 +1,38 @@ +use crate::entity::EntityId; use bytemuck::{Pod, Zeroable}; -/// Marker component for zombified piglin entities. + +/// Marker component for mooshroom entities. /// /// # Example /// A system that queries for all zombified piglins: /// ```no_run -/// use quill::{Game, Position, entities::ZombifiedPiglin}; +/// use quill::{Game, Position, entities::ZombifiedPiglinMarker}; /// # struct MyPlugin; /// fn print_entities_system(_plugin: &mut MyPlugin, game: &mut Game) { -/// for (entity, (position, _)) in game.query::<(&Position, &ZombifiedPiglin)>() { -/// println!("Found a zombified piglin with position {:?}", position); +/// for (entity, (position, _)) in game.query::<(&Position, &ZombifiedPiglinMarker)>() { +/// println!("Found a zombified piglin with position "zombified piglin"", position); /// } /// } /// ``` #[derive(Debug, Copy, Clone, Zeroable, Pod)] #[repr(C)] -pub struct ZombifiedPiglin; +pub struct ZombifiedPiglinMarker; + +pod_component_impl!(ZombifiedPiglinMarker); + +/// Entity wrapper for zombified piglin entities. +/// +/// Implements several traits providing high-level methods +/// like "deal damage". +pub struct ZombifiedPiglin { + id: EntityId, +} + +wrapper_from_query_impl!(ZombifiedPiglin, ZombifiedPiglinMarker); +entity_wrapper_impl!(ZombifiedPiglin, ZombifiedPiglinMarker); -pod_component_impl!(ZombifiedPiglin); +impl crate::HasEntityId for ZombifiedPiglin { + fn entity_id(&self) -> EntityId { + self.id + } +} diff --git a/quill/common/src/entity.rs b/quill/common/src/entity.rs index 03a0b4d51..bffa874a6 100644 --- a/quill/common/src/entity.rs +++ b/quill/common/src/entity.rs @@ -1,7 +1,9 @@ +use std::iter::once; + use bytemuck::{Pod, Zeroable}; use serde::{Deserialize, Serialize}; -use crate::PointerMut; +use crate::{Component, HostComponent, PointerMut}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Zeroable, Pod, Serialize, Deserialize)] #[repr(transparent)] @@ -29,3 +31,99 @@ pub struct QueryData { /// component buffer. pub component_lens: PointerMut, } + +/// A type that can be used for a query. +/// +/// Implemented for tuples of `FromQuery`s as well. +/// +/// Implemented for `&T` where `T: Component`. +/// +/// Implemented for entity wrappers like `Player`. +pub trait FromQuery { + type Item; + + /// Adds the requested component types to the query. + fn add_component_types(types: &mut impl Extend); + + /// # Safety + /// `component_index` must be the index of the first compoonent + /// added by `add_component_types`. + /// + /// `component_offsets` must contain the proper byte offset + /// of the current component index. + unsafe fn get_unchecked( + entity: EntityId, + data: &QueryData, + component_index: &mut usize, + component_offsets: &mut [usize], + ) -> Self::Item; +} + +macro_rules! impl_query_tuple { + ($($query:ident),* $(,)?) => { + impl <$($query: FromQuery),*> FromQuery for ($($query,)*) { + type Item = ($($query::Item),*); + fn add_component_types(types: &mut impl Extend) { + $( + $query::add_component_types(types); + )* + } + + unsafe fn get_unchecked(entity: EntityId, data: &QueryData, component_index: &mut usize, component_offsets: &mut [usize]) -> Self::Item { + ( + $( + $query::get_unchecked(entity, data, component_index, component_offsets) + ),* + ) + } + } + } +} + +impl_query_tuple!(A, B); +impl_query_tuple!(A, B, C); +impl_query_tuple!(A, B, C, D); +impl_query_tuple!(A, B, C, D, E); +impl_query_tuple!(A, B, C, D, E, F); +impl_query_tuple!(A, B, C, D, E, F, G); +impl_query_tuple!(A, B, C, D, E, F, G, H); +impl_query_tuple!(A, B, C, D, E, F, G, H, I); +impl_query_tuple!(A, B, C, D, E, F, G, H, I, J); +impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K); +impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K, L); +impl_query_tuple!(A, B, C, D, E, F, G, H, I, J, K, L, M); + +impl<'a, T> FromQuery for &'a T +where + T: Component, +{ + type Item = T; + + fn add_component_types(types: &mut impl Extend) { + types.extend(once(T::host_component())); + } + + unsafe fn get_unchecked( + _entity: EntityId, + data: &QueryData, + component_index: &mut usize, + component_offsets: &mut [usize], + ) -> T { + let component_len = *((data.component_lens.as_mut_ptr()).add(*component_index)) as usize; + let component_ptr = + (*(data.component_ptrs.as_mut_ptr().add(*component_index))).as_mut_ptr(); + + let offset = component_offsets[*component_index]; + let component_ptr = component_ptr.add(offset); + let component_len = component_len - offset; + + let component_bytes = std::slice::from_raw_parts(component_ptr, component_len); + let (value, advance) = T::from_bytes_unchecked(component_bytes); + + component_offsets[*component_index] += advance; + + *component_index += 1; + + value + } +} diff --git a/quill/common/src/lib.rs b/quill/common/src/lib.rs index 53d8a262b..54f2b1cc5 100644 --- a/quill/common/src/lib.rs +++ b/quill/common/src/lib.rs @@ -14,6 +14,7 @@ use std::marker::PhantomData; use bytemuck::{Pod, Zeroable}; pub use component::{Component, HostComponent}; +pub use entities::HasEntityId; pub use entity::EntityId; /// Wrapper type that enforces 64-bit pointers diff --git a/quill/example-plugins/block-access/src/lib.rs b/quill/example-plugins/block-access/src/lib.rs index 33f3ad798..d7133965a 100644 --- a/quill/example-plugins/block-access/src/lib.rs +++ b/quill/example-plugins/block-access/src/lib.rs @@ -18,7 +18,7 @@ impl Plugin for BlockAccess { fn system(_plugin: &mut BlockAccess, game: &mut Game) { // Set the blocks each player is standing on // to bedrock. - for (_entity, (_, pos)) in game.query::<(&Player, &Position)>() { + for (_entity, (_, pos)) in game.query::<(Player, &Position)>() { let block_pos = pos.block(); game.set_block(block_pos, BlockState::from_id(33).unwrap())