From 5e5924e93167fe2b0f291fa181b6eb9b33edd066 Mon Sep 17 00:00:00 2001 From: James Melkonian Date: Fri, 21 May 2021 16:51:03 -0700 Subject: [PATCH] Give objects species --- common/src/cmd.rs | 2 +- common/src/comp/body.rs | 221 ++--- common/src/comp/body/object.rs | 846 +++++++++++------- common/src/comp/body/ship.rs | 1 - common/src/comp/fluid_dynamics.rs | 48 +- common/src/comp/inventory/loadout_builder.rs | 6 +- server/src/cmd.rs | 14 +- server/src/events/entity_creation.rs | 2 +- server/src/events/entity_manipulation.rs | 10 +- server/src/events/interaction.rs | 2 +- server/src/events/inventory_manip.rs | 10 +- server/src/state_ext.rs | 19 +- server/src/sys/wiring/dispatch_actions.rs | 2 +- voxygen/anim/src/object/mod.rs | 6 +- voxygen/anim/src/object/shoot.rs | 6 +- .../audio/sfx/event_mapper/campfire/mod.rs | 2 +- voxygen/src/audio/sfx/mod.rs | 28 +- voxygen/src/ecs/sys/interpolation.rs | 4 +- voxygen/src/scene/particle.rs | 53 +- world/src/site/dungeon/mod.rs | 4 +- world/src/site/settlement/mod.rs | 2 +- 21 files changed, 733 insertions(+), 555 deletions(-) diff --git a/common/src/cmd.rs b/common/src/cmd.rs index 361a20ba55..2782b378e0 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -244,7 +244,7 @@ lazy_static! { souls }; - static ref OBJECTS: Vec = comp::object::ALL_OBJECTS + static ref OBJECTS: Vec = comp::object::ALL_SPECIES .iter() .map(|o| o.to_string().to_string()) .collect(); diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 5554382885..e284affeee 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -92,11 +92,11 @@ pub struct AllBodies { pub fish_small: BodyData>, pub biped_large: BodyData>, pub biped_small: BodyData>, - pub object: BodyData, + pub object: BodyData>, pub golem: BodyData>, pub theropod: BodyData>, pub quadruped_low: BodyData>, - pub ship: BodyData, + pub ship: BodyData>, } /// Can only retrieve body metadata by direct index. @@ -313,9 +313,8 @@ impl Body { get_body_attribute(&body_attribute.quadruped_small, body.species) }, Body::Theropod(body) => get_body_attribute(&body_attribute.theropod, body.species), - // TODO fix this for ships and objects to read from the ron files - Body::Ship(ship) => T::default(), - Body::Object(object) => T::default(), + Body::Ship(body) => get_body_attribute(&body_attribute.ship, body.species), + Body::Object(body) => get_body_attribute(&body_attribute.object, body.species), } } @@ -397,36 +396,37 @@ impl Body { } pub fn aggro(&self, body_aggros: &AllBodiesAggro) -> f32 { - match self { - Body::BipedLarge(body) => { - get_body_f32_attribute(&body_aggros.biped_large, body.species) - }, - Body::BipedSmall(body) => { - get_body_f32_attribute(&body_aggros.biped_small, body.species) - }, - Body::BirdMedium(body) => { - get_body_f32_attribute(&body_aggros.bird_medium, body.species) - }, - Body::BirdLarge(body) => get_body_f32_attribute(&body_aggros.bird_large, body.species), - Body::FishSmall(body) => get_body_f32_attribute(&body_aggros.fish_small, body.species), - Body::FishMedium(body) => { - get_body_f32_attribute(&body_aggros.fish_medium, body.species) - }, - Body::Humanoid(body) => get_body_f32_attribute(&body_aggros.humanoid, body.species), - Body::QuadrupedMedium(body) => { - get_body_f32_attribute(&body_aggros.quadruped_medium, body.species) - }, - Body::QuadrupedSmall(body) => { - get_body_f32_attribute(&body_aggros.quadruped_small, body.species) - }, - Body::Theropod(body) => get_body_f32_attribute(&body_aggros.theropod, body.species), - Body::Dragon(body) => get_body_f32_attribute(&body_aggros.dragon, body.species), - Body::QuadrupedLow(body) => { - get_body_f32_attribute(&body_aggros.quadruped_low, body.species) - }, - Body::Golem(body) => get_body_f32_attribute(&body_aggros.golem, body.species), - Body::Ship(_) | Body::Object(_) => 0.0, - } + 0.0 //match self { + // Body::BipedLarge(body) => { + // get_body_f32_attribute(&body_aggros.biped_large, body.species) + // }, + // Body::BipedSmall(body) => { + // get_body_f32_attribute(&body_aggros.biped_small, body.species) + // }, + // Body::BirdMedium(body) => { + // get_body_f32_attribute(&body_aggros.bird_medium, body.species) + // }, + // Body::BirdLarge(body) => get_body_f32_attribute(&body_aggros.bird_large, body.species), + // Body::FishSmall(body) => get_body_f32_attribute(&body_aggros.fish_small, body.species), + // Body::FishMedium(body) => { + // get_body_f32_attribute(&body_aggros.fish_medium, body.species) + // }, + // Body::Humanoid(body) => get_body_f32_attribute(&body_aggros.humanoid, body.species), + // Body::QuadrupedMedium(body) => { + // get_body_f32_attribute(&body_aggros.quadruped_medium, body.species) + // }, + // Body::QuadrupedSmall(body) => { + // get_body_f32_attribute(&body_aggros.quadruped_small, body.species) + // }, + // Body::Theropod(body) => get_body_f32_attribute(&body_aggros.theropod, body.species), + // Body::Dragon(body) => get_body_f32_attribute(&body_aggros.dragon, body.species), + // Body::QuadrupedLow(body) => { + // get_body_f32_attribute(&body_aggros.quadruped_low, body.species) + // }, + // Body::Golem(body) => get_body_f32_attribute(&body_aggros.golem, body.species), + // Body::Ship(body) => get_body_f32_attribute(&body_aggros.ship, body.species), + // Body::Object(body) => get_body_f32_attribute(&body_aggros.object, body.species), + //} } /// The width (shoulder to shoulder), length (nose to tail) and height @@ -469,7 +469,7 @@ impl Body { }; Vec3::new(1.5, 0.5, height) }, - Body::Object(object) => object.dimensions(), + Body::Object(object) => Vec3::new(1.0, 1.0, 1.0), //object.dimensions(), Body::QuadrupedMedium(body) => match body.species { quadruped_medium::Species::Barghest => Vec3::new(2.0, 3.6, 2.5), quadruped_medium::Species::Bear => Vec3::new(2.0, 3.6, 2.0), @@ -531,79 +531,82 @@ impl Body { pub fn height(&self) -> f32 { self.dimensions().z } pub fn base_energy(&self, body_energies: &AllBodiesBaseEnergy) -> u32 { - match self { - Body::BipedLarge(body) => { - get_body_u32_attribute(&body_energies.biped_large, body.species) - }, - Body::BipedSmall(body) => { - get_body_u32_attribute(&body_energies.biped_small, body.species) - }, - Body::BirdMedium(body) => { - get_body_u32_attribute(&body_energies.bird_medium, body.species) - }, - Body::BirdLarge(body) => { - get_body_u32_attribute(&body_energies.bird_large, body.species) - }, - Body::FishSmall(body) => { - get_body_u32_attribute(&body_energies.fish_small, body.species) - }, - Body::FishMedium(body) => { - get_body_u32_attribute(&body_energies.fish_medium, body.species) - }, - Body::Humanoid(body) => get_body_u32_attribute(&body_energies.humanoid, body.species), - Body::QuadrupedMedium(body) => { - get_body_u32_attribute(&body_energies.quadruped_medium, body.species) - }, - Body::QuadrupedSmall(body) => { - get_body_u32_attribute(&body_energies.quadruped_small, body.species) - }, - Body::Theropod(body) => get_body_u32_attribute(&body_energies.theropod, body.species), - Body::Dragon(body) => get_body_u32_attribute(&body_energies.dragon, body.species), - Body::QuadrupedLow(body) => { - get_body_u32_attribute(&body_energies.quadruped_low, body.species) - }, - Body::Golem(body) => get_body_u32_attribute(&body_energies.golem, body.species), - Body::Ship(_) | Body::Object(_) => 1000, - } + 1000 + //match self { + // Body::BipedLarge(body) => { + // get_body_u32_attribute(&body_energies.biped_large, body.species) + // }, + // Body::BipedSmall(body) => { + // get_body_u32_attribute(&body_energies.biped_small, body.species) + // }, + // Body::BirdMedium(body) => { + // get_body_u32_attribute(&body_energies.bird_medium, body.species) + // }, + // Body::BirdLarge(body) => { + // get_body_u32_attribute(&body_energies.bird_large, body.species) + // }, + // Body::FishSmall(body) => { + // get_body_u32_attribute(&body_energies.fish_small, body.species) + // }, + // Body::FishMedium(body) => { + // get_body_u32_attribute(&body_energies.fish_medium, body.species) + // }, + // Body::Humanoid(body) => get_body_u32_attribute(&body_energies.humanoid, body.species), + // Body::QuadrupedMedium(body) => { + // get_body_u32_attribute(&body_energies.quadruped_medium, body.species) + // }, + // Body::QuadrupedSmall(body) => { + // get_body_u32_attribute(&body_energies.quadruped_small, body.species) + // }, + // Body::Theropod(body) => get_body_u32_attribute(&body_energies.theropod, body.species), + // Body::Dragon(body) => get_body_u32_attribute(&body_energies.dragon, body.species), + // Body::QuadrupedLow(body) => { + // get_body_u32_attribute(&body_energies.quadruped_low, body.species) + // }, + // Body::Golem(body) => get_body_u32_attribute(&body_energies.golem, body.species), + // Body::Ship(body) => get_body_u32_attribute(&body_energies.ship, body.species), + // Body::Object(body) => get_body_u32_attribute(&body_energies.object, body.species), + //} } pub fn base_health(&self, body_healths: &AllBodiesBaseHealth) -> u32 { - match self { - Body::BipedLarge(body) => { - get_body_u32_attribute(&body_healths.biped_large, body.species) - }, - Body::BipedSmall(body) => { - get_body_u32_attribute(&body_healths.biped_small, body.species) - }, - Body::BirdMedium(body) => { - get_body_u32_attribute(&body_healths.bird_medium, body.species) - }, - Body::BirdLarge(body) => get_body_u32_attribute(&body_healths.bird_large, body.species), - Body::FishSmall(body) => get_body_u32_attribute(&body_healths.fish_small, body.species), - Body::FishMedium(body) => { - get_body_u32_attribute(&body_healths.fish_medium, body.species) - }, - Body::Humanoid(body) => get_body_u32_attribute(&body_healths.humanoid, body.species), - Body::QuadrupedMedium(body) => { - get_body_u32_attribute(&body_healths.quadruped_medium, body.species) - }, - Body::QuadrupedSmall(body) => { - get_body_u32_attribute(&body_healths.quadruped_small, body.species) - }, - Body::Theropod(body) => get_body_u32_attribute(&body_healths.theropod, body.species), - Body::Dragon(body) => get_body_u32_attribute(&body_healths.dragon, body.species), - Body::QuadrupedLow(body) => { - get_body_u32_attribute(&body_healths.quadruped_low, body.species) - }, - Body::Golem(body) => get_body_u32_attribute(&body_healths.golem, body.species), - Body::Ship(_) => 10000, - Body::Object(object) => match object { - object::Body::TrainingDummy => 10000, - object::Body::Crossbow => 800, - object::Body::HaniwaSentry => 600, - _ => 10000, - }, - } + 1000 + //match self { + // Body::BipedLarge(body) => { + // get_body_u32_attribute(&body_healths.biped_large, body.species) + // }, + // Body::BipedSmall(body) => { + // get_body_u32_attribute(&body_healths.biped_small, body.species) + // }, + // Body::BirdMedium(body) => { + // get_body_u32_attribute(&body_healths.bird_medium, body.species) + // }, + // Body::BirdLarge(body) => get_body_u32_attribute(&body_healths.bird_large, body.species), + // Body::FishSmall(body) => get_body_u32_attribute(&body_healths.fish_small, body.species), + // Body::FishMedium(body) => { + // get_body_u32_attribute(&body_healths.fish_medium, body.species) + // }, + // Body::Humanoid(body) => get_body_u32_attribute(&body_healths.humanoid, body.species), + // Body::QuadrupedMedium(body) => { + // get_body_u32_attribute(&body_healths.quadruped_medium, body.species) + // }, + // Body::QuadrupedSmall(body) => { + // get_body_u32_attribute(&body_healths.quadruped_small, body.species) + // }, + // Body::Theropod(body) => get_body_u32_attribute(&body_healths.theropod, body.species), + // Body::Dragon(body) => get_body_u32_attribute(&body_healths.dragon, body.species), + // Body::QuadrupedLow(body) => { + // get_body_u32_attribute(&body_healths.quadruped_low, body.species) + // }, + // Body::Golem(body) => get_body_u32_attribute(&body_healths.golem, body.species), + // Body::Ship(body) => get_body_u32_attribute(&body_healths.ship, body.species), //10000, + // Body::Object(body) => get_body_u32_attribute(&body_healths.object, body.species), //match object { + // // object::Body::TrainingDummy => 10000, + // // object::Body::Crossbow => 800, + // // object::Body::HaniwaSentry => 600, + // // _ => 10000, + // //}, + //} } pub fn base_health_increase(&self, body_health_increases: &AllBodiesBaseHealthIncrease) -> u32 { @@ -645,8 +648,8 @@ impl Body { get_body_u32_attribute(&body_health_increases.quadruped_low, body.species) }, Body::Golem(body) => get_body_u32_attribute(&body_health_increases.golem, body.species), - Body::Ship(_) => 500, - Body::Object(_) => 10, + Body::Ship(body) => get_body_u32_attribute(&body_health_increases.ship, body.species), //500, + Body::Object(body) => get_body_u32_attribute(&body_health_increases.object, body.species), //10, } } @@ -667,7 +670,7 @@ impl Body { BuffKind::Burning => match self { Body::Golem(g) => matches!(g.species, golem::Species::ClayGolem), Body::BipedSmall(b) => matches!(b.species, biped_small::Species::Haniwa), - Body::Object(object::Body::HaniwaSentry) => true, + Body::Object(b) => matches!(b.species, object::Species::HaniwaSentry), _ => false, }, _ => false, diff --git a/common/src/comp/body/object.rs b/common/src/comp/body/object.rs index d5a00fcdc2..5a50f02ea4 100644 --- a/common/src/comp/body/object.rs +++ b/common/src/comp/body/object.rs @@ -1,355 +1,539 @@ use crate::{ comp::{item::Reagent, Density, Mass}, consts::{IRON_DENSITY, WATER_DENSITY}, - make_case_elim, + make_proj_elim, }; use rand::{seq::SliceRandom, thread_rng}; use serde::{Deserialize, Serialize}; use vek::Vec3; -make_case_elim!( +make_proj_elim!( body, #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] - #[repr(u32)] - pub enum Body { - Arrow = 0, - Bomb = 1, - Scarecrow = 2, - Cauldron = 3, - ChestVines = 4, - Chest = 5, - ChestDark = 6, - ChestDemon = 7, - ChestGold = 8, - ChestLight = 9, - ChestOpen = 10, - ChestSkull = 11, - Pumpkin = 12, - Pumpkin2 = 13, - Pumpkin3 = 14, - Pumpkin4 = 15, - Pumpkin5 = 16, - Campfire = 17, - LanternGround = 18, - LanternGroundOpen = 19, - LanternStanding2 = 20, - LanternStanding = 21, - PotionBlue = 22, - PotionGreen = 23, - PotionRed = 24, - Crate = 25, - Tent = 26, - WindowSpooky = 27, - DoorSpooky = 28, - Anvil = 29, - Gravestone = 30, - Gravestone2 = 31, - Bench = 32, - Chair = 33, - Chair2 = 34, - Chair3 = 35, - Table = 36, - Table2 = 37, - Table3 = 38, - Drawer = 39, - BedBlue = 40, - Carpet = 41, - Bedroll = 42, - CarpetHumanRound = 43, - CarpetHumanSquare = 44, - CarpetHumanSquare2 = 45, - CarpetHumanSquircle = 46, - Pouch = 47, - CraftingBench = 48, - BoltFire = 49, - ArrowSnake = 50, - CampfireLit = 51, - BoltFireBig = 52, - TrainingDummy = 53, - FireworkBlue = 54, - FireworkGreen = 55, - FireworkPurple = 56, - FireworkRed = 57, - FireworkWhite = 58, - FireworkYellow = 59, - MultiArrow = 60, - BoltNature = 61, - MeatDrop = 62, - Steak = 63, - Crossbow = 64, - ArrowTurret = 65, - Coins = 66, - GoldOre = 67, - SilverOre = 68, - ClayRocket = 69, - HaniwaSentry = 70, + pub struct Body { + pub species: Species, } ); +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[repr(u32)] +pub enum Species { + Arrow = 0, + Bomb = 1, + Scarecrow = 2, + Cauldron = 3, + ChestVines = 4, + Chest = 5, + ChestDark = 6, + ChestDemon = 7, + ChestGold = 8, + ChestLight = 9, + ChestOpen = 10, + ChestSkull = 11, + Pumpkin = 12, + Pumpkin2 = 13, + Pumpkin3 = 14, + Pumpkin4 = 15, + Pumpkin5 = 16, + Campfire = 17, + LanternGround = 18, + LanternGroundOpen = 19, + LanternStanding2 = 20, + LanternStanding = 21, + PotionBlue = 22, + PotionGreen = 23, + PotionRed = 24, + Crate = 25, + Tent = 26, + WindowSpooky = 27, + DoorSpooky = 28, + Anvil = 29, + Gravestone = 30, + Gravestone2 = 31, + Bench = 32, + Chair = 33, + Chair2 = 34, + Chair3 = 35, + Table = 36, + Table2 = 37, + Table3 = 38, + Drawer = 39, + BedBlue = 40, + Carpet = 41, + Bedroll = 42, + CarpetHumanRound = 43, + CarpetHumanSquare = 44, + CarpetHumanSquare2 = 45, + CarpetHumanSquircle = 46, + Pouch = 47, + CraftingBench = 48, + BoltFire = 49, + ArrowSnake = 50, + CampfireLit = 51, + BoltFireBig = 52, + TrainingDummy = 53, + FireworkBlue = 54, + FireworkGreen = 55, + FireworkPurple = 56, + FireworkRed = 57, + FireworkWhite = 58, + FireworkYellow = 59, + MultiArrow = 60, + BoltNature = 61, + MeatDrop = 62, + Steak = 63, + Crossbow = 64, + ArrowTurret = 65, + Coins = 66, + GoldOre = 67, + SilverOre = 68, + ClayRocket = 69, + HaniwaSentry = 70, +} + impl Body { pub fn random() -> Self { let mut rng = thread_rng(); - *(&ALL_OBJECTS).choose(&mut rng).unwrap() - } -} - -pub const ALL_OBJECTS: [Body; 71] = [ - Body::Arrow, - Body::Bomb, - Body::Scarecrow, - Body::Cauldron, - Body::ChestVines, - Body::Chest, - Body::ChestDark, - Body::ChestDemon, - Body::ChestGold, - Body::ChestLight, - Body::ChestOpen, - Body::ChestSkull, - Body::Pumpkin, - Body::Pumpkin2, - Body::Pumpkin3, - Body::Pumpkin4, - Body::Pumpkin5, - Body::Campfire, - Body::CampfireLit, - Body::LanternGround, - Body::LanternGroundOpen, - Body::LanternStanding, - Body::LanternStanding2, - Body::PotionRed, - Body::PotionBlue, - Body::PotionGreen, - Body::Crate, - Body::Tent, - Body::WindowSpooky, - Body::DoorSpooky, - Body::Anvil, - Body::Gravestone, - Body::Gravestone2, - Body::Bench, - Body::Chair, - Body::Chair2, - Body::Chair3, - Body::Table, - Body::Table2, - Body::Table3, - Body::Drawer, - Body::BedBlue, - Body::Carpet, - Body::Bedroll, - Body::CarpetHumanRound, - Body::CarpetHumanSquare, - Body::CarpetHumanSquare2, - Body::CarpetHumanSquircle, - Body::Pouch, - Body::CraftingBench, - Body::BoltFire, - Body::BoltFireBig, - Body::ArrowSnake, - Body::TrainingDummy, - Body::FireworkBlue, - Body::FireworkGreen, - Body::FireworkPurple, - Body::FireworkRed, - Body::FireworkWhite, - Body::FireworkYellow, - Body::MultiArrow, - Body::BoltNature, - Body::MeatDrop, - Body::Steak, - Body::Crossbow, - Body::ArrowTurret, - Body::Coins, - Body::SilverOre, - Body::GoldOre, - Body::ClayRocket, - Body::HaniwaSentry, -]; - -impl From for super::Body { - fn from(body: Body) -> Self { super::Body::Object(body) } -} - -impl Body { - pub fn to_string(&self) -> &str { - match self { - Body::Arrow => "arrow", - Body::Bomb => "bomb", - Body::Scarecrow => "scarecrow", - Body::Cauldron => "cauldron", - Body::ChestVines => "chest_vines", - Body::Chest => "chest", - Body::ChestDark => "chest_dark", - Body::ChestDemon => "chest_demon", - Body::ChestGold => "chest_gold", - Body::ChestLight => "chest_light", - Body::ChestOpen => "chest_open", - Body::ChestSkull => "chest_skull", - Body::Pumpkin => "pumpkin", - Body::Pumpkin2 => "pumpkin_2", - Body::Pumpkin3 => "pumpkin_3", - Body::Pumpkin4 => "pumpkin_4", - Body::Pumpkin5 => "pumpkin_5", - Body::Campfire => "campfire", - Body::CampfireLit => "campfire_lit", - Body::LanternGround => "lantern_ground", - Body::LanternGroundOpen => "lantern_ground_open", - Body::LanternStanding => "lantern_standing", - Body::LanternStanding2 => "lantern_standing_2", - Body::PotionRed => "potion_red", - Body::PotionBlue => "potion_blue", - Body::PotionGreen => "potion_green", - Body::Crate => "crate", - Body::Tent => "tent", - Body::WindowSpooky => "window_spooky", - Body::DoorSpooky => "door_spooky", - Body::Anvil => "anvil", - Body::Gravestone => "gravestone", - Body::Gravestone2 => "gravestone_2", - Body::Bench => "bench", - Body::Chair => "chair", - Body::Chair2 => "chair_2", - Body::Chair3 => "chair_3", - Body::Table => "table", - Body::Table2 => "table_2", - Body::Table3 => "table_3", - Body::Drawer => "drawer", - Body::BedBlue => "bed_blue", - Body::Carpet => "carpet", - Body::Bedroll => "bedroll", - Body::CarpetHumanRound => "carpet_human_round", - Body::CarpetHumanSquare => "carpet_human_square", - Body::CarpetHumanSquare2 => "carpet_human_square_2", - Body::CarpetHumanSquircle => "carpet_human_squircle", - Body::Pouch => "pouch", - Body::CraftingBench => "crafting_bench", - Body::BoltFire => "bolt_fire", - Body::BoltFireBig => "bolt_fire_big", - Body::ArrowSnake => "arrow_snake", - Body::TrainingDummy => "training_dummy", - Body::FireworkBlue => "firework_blue", - Body::FireworkGreen => "firework_green", - Body::FireworkPurple => "firework_purple", - Body::FireworkRed => "firework_red", - Body::FireworkWhite => "firework_white", - Body::FireworkYellow => "firework_yellow", - Body::MultiArrow => "multi_arrow", - Body::BoltNature => "bolt_nature", - Body::MeatDrop => "meat_drop", - Body::Steak => "steak", - Body::Crossbow => "crossbow", - Body::ArrowTurret => "arrow_turret", - Body::Coins => "coins", - Body::SilverOre => "silver_ore", - Body::GoldOre => "gold_ore", - Body::ClayRocket => "clay_rocket", - Body::HaniwaSentry => "haniwa_sentry", + Body { + species: *(&ALL_SPECIES).choose(&mut rng).unwrap(), } } pub fn for_firework(reagent: Reagent) -> Body { match reagent { - Reagent::Blue => Body::FireworkBlue, - Reagent::Green => Body::FireworkGreen, - Reagent::Purple => Body::FireworkPurple, - Reagent::Red => Body::FireworkRed, - Reagent::White => Body::FireworkWhite, - Reagent::Yellow => Body::FireworkYellow, - } - } - - pub fn density(&self) -> Density { - let density = match self { - Body::Anvil | Body::Cauldron => IRON_DENSITY, - Body::Arrow | Body::ArrowSnake | Body::ArrowTurret | Body::MultiArrow => 500.0, - Body::Bomb => 2000.0, // I have no idea what it's supposed to be - Body::Crate => 300.0, // let's say it's a lot of wood and maybe some contents - Body::Scarecrow => 900.0, - Body::TrainingDummy => 2000.0, - // let them sink - _ => 1.1 * WATER_DENSITY, - }; - - Density(density) - } - - pub fn mass(&self) -> Mass { - let m = match self { - // I think MultiArrow is one of several arrows, not several arrows combined? - Body::Anvil => 100.0, - Body::Arrow | Body::ArrowSnake | Body::ArrowTurret | Body::MultiArrow => 0.003, - Body::BedBlue => 50.0, - Body::Bedroll => 3.0, - Body::Bench => 100.0, - Body::BoltFire | Body::BoltFireBig | Body::BoltNature => 1.0, - Body::Bomb => { - 0.5 * IRON_DENSITY * std::f32::consts::PI / 6.0 * self.dimensions().x.powi(3) - }, - Body::Campfire | Body::CampfireLit => 300.0, - Body::Carpet - | Body::CarpetHumanRound - | Body::CarpetHumanSquare - | Body::CarpetHumanSquare2 - | Body::CarpetHumanSquircle => 10.0, - Body::Cauldron => 5.0, - Body::Chair | Body::Chair2 | Body::Chair3 => 10.0, - Body::Chest - | Body::ChestDark - | Body::ChestDemon - | Body::ChestGold - | Body::ChestLight - | Body::ChestOpen - | Body::ChestSkull - | Body::ChestVines => 100.0, - Body::Coins => 1.0, - Body::CraftingBench => 100.0, - Body::Crate => 50.0, - Body::Crossbow => 200.0, - Body::DoorSpooky => 20.0, - Body::Drawer => 50.0, - Body::FireworkBlue - | Body::FireworkGreen - | Body::FireworkPurple - | Body::FireworkRed - | Body::FireworkWhite - | Body::FireworkYellow => 1.0, - Body::Gravestone => 100.0, - Body::Gravestone2 => 100.0, - Body::LanternGround - | Body::LanternGroundOpen - | Body::LanternStanding - | Body::LanternStanding2 => 3.0, - Body::MeatDrop => 5.0, - Body::PotionBlue | Body::PotionGreen | Body::PotionRed => 5.0, - Body::Pouch => 1.0, - Body::Pumpkin | Body::Pumpkin2 | Body::Pumpkin3 | Body::Pumpkin4 | Body::Pumpkin5 => { - 10.0 - }, - Body::Scarecrow => 50.0, - Body::Steak => 2.0, - Body::Table | Body::Table2 | Body::Table3 => 50.0, - Body::Tent => 50.0, - Body::TrainingDummy => 60.0, - Body::WindowSpooky => 10.0, - Body::SilverOre => 1000.0, - Body::GoldOre => 1000.0, - Body::ClayRocket => 50.0, - Body::HaniwaSentry => 300.0, - }; - - Mass(m) - } - - pub fn dimensions(&self) -> Vec3 { - match self { - Body::Arrow | Body::ArrowSnake | Body::MultiArrow | Body::ArrowTurret => { - Vec3::new(0.01, 0.8, 0.01) - }, - Body::BoltFire => Vec3::new(0.1, 0.1, 0.1), - Body::Crossbow => Vec3::new(3.0, 3.0, 1.5), - Body::HaniwaSentry => Vec3::new(0.8, 0.8, 1.4), - _ => Vec3::broadcast(0.2), + Reagent::Blue => Body { species: Species::FireworkBlue }, + Reagent::Green => Body { species: Species::FireworkGreen }, + Reagent::Purple => Body { species: Species::FireworkPurple }, + Reagent::Red => Body { species: Species::FireworkRed }, + Reagent::White => Body { species: Species::FireworkWhite }, + Reagent::Yellow => Body { species: Species::FireworkYellow }, } } } + +/// Data representing per-species generic data. +/// +/// NOTE: Deliberately don't (yet?) implement serialize. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct AllSpecies { + pub arrow: SpeciesMeta, + pub bomb: SpeciesMeta, + pub scarecrow: SpeciesMeta, + pub cauldron: SpeciesMeta, + pub chest_vines: SpeciesMeta, + pub chest: SpeciesMeta, + pub chest_dark: SpeciesMeta, + pub chest_demon: SpeciesMeta, + pub chest_gold: SpeciesMeta, + pub chest_light: SpeciesMeta, + pub chest_open: SpeciesMeta, + pub chest_skull: SpeciesMeta, + pub pumpkin: SpeciesMeta, + pub pumpkin_2: SpeciesMeta, + pub pumpkin_3: SpeciesMeta, + pub pumpkin_4: SpeciesMeta, + pub pumpkin_5: SpeciesMeta, + pub campfire: SpeciesMeta, + pub campfire_lit: SpeciesMeta, + pub lantern_ground: SpeciesMeta, + pub lantern_ground_open: SpeciesMeta, + pub lantern_standing: SpeciesMeta, + pub lantern_standing_2: SpeciesMeta, + pub potion_red: SpeciesMeta, + pub potion_blue: SpeciesMeta, + pub potion_green: SpeciesMeta, + pub crate_0: SpeciesMeta, + pub tent: SpeciesMeta, + pub window_spooky: SpeciesMeta, + pub door_spooky: SpeciesMeta, + pub anvil: SpeciesMeta, + pub gravestone: SpeciesMeta, + pub gravestone_2: SpeciesMeta, + pub bench: SpeciesMeta, + pub chair: SpeciesMeta, + pub chair_2: SpeciesMeta, + pub chair_3: SpeciesMeta, + pub table: SpeciesMeta, + pub table_2: SpeciesMeta, + pub table_3: SpeciesMeta, + pub drawer: SpeciesMeta, + pub bed_blue: SpeciesMeta, + pub carpet: SpeciesMeta, + pub bedroll: SpeciesMeta, + pub carpet_human_round: SpeciesMeta, + pub carpet_human_square: SpeciesMeta, + pub carpet_human_square_2: SpeciesMeta, + pub carpet_human_squircle: SpeciesMeta, + pub pouch: SpeciesMeta, + pub crafting_bench: SpeciesMeta, + pub bolt_fire: SpeciesMeta, + pub bolt_fire_big: SpeciesMeta, + pub arrow_snake: SpeciesMeta, + pub training_dummy: SpeciesMeta, + pub firework_blue: SpeciesMeta, + pub firework_green: SpeciesMeta, + pub firework_purple: SpeciesMeta, + pub firework_red: SpeciesMeta, + pub firework_white: SpeciesMeta, + pub firework_yellow: SpeciesMeta, + pub multi_arrow: SpeciesMeta, + pub bolt_nature: SpeciesMeta, + pub meat_drop: SpeciesMeta, + pub steak: SpeciesMeta, + pub crossbow: SpeciesMeta, + pub arrow_turret: SpeciesMeta, + pub coins: SpeciesMeta, + pub silver_ore: SpeciesMeta, + pub gold_ore: SpeciesMeta, + pub clay_rocket: SpeciesMeta, + pub haniwa_sentry: SpeciesMeta, +} + +impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies { + type Output = SpeciesMeta; + + #[inline] + fn index(&self, &index: &'a Species) -> &Self::Output { + match index { + Species::Arrow => &self.arrow, + Species::Bomb => &self.bomb, + Species::Scarecrow => &self.scarecrow, + Species::Cauldron => &self.cauldron, + Species::ChestVines => &self.chest_vines, + Species::Chest => &self.chest, + Species::ChestDark => &self.chest_dark, + Species::ChestDemon => &self.chest_demon, + Species::ChestGold => &self.chest_gold, + Species::ChestLight => &self.chest_light, + Species::ChestOpen => &self.chest_open, + Species::ChestSkull => &self.chest_skull, + Species::Pumpkin => &self.pumpkin, + Species::Pumpkin2 => &self.pumpkin_2, + Species::Pumpkin3 => &self.pumpkin_3, + Species::Pumpkin4 => &self.pumpkin_4, + Species::Pumpkin5 => &self.pumpkin_5, + Species::Campfire => &self.campfire, + Species::CampfireLit => &self.campfire_lit, + Species::LanternGround => &self.lantern_ground, + Species::LanternGroundOpen => &self.lantern_ground_open, + Species::LanternStanding => &self.lantern_standing, + Species::LanternStanding2 => &self.lantern_standing_2, + Species::PotionRed => &self.potion_red, + Species::PotionBlue => &self.potion_blue, + Species::PotionGreen => &self.potion_green, + Species::Crate => &self.crate_0, + Species::Tent => &self.tent, + Species::WindowSpooky => &self.window_spooky, + Species::DoorSpooky => &self.door_spooky, + Species::Anvil => &self.anvil, + Species::Gravestone => &self.gravestone, + Species::Gravestone2 => &self.gravestone_2, + Species::Bench => &self.bench, + Species::Chair => &self.chair, + Species::Chair2 => &self.chair_2, + Species::Chair3 => &self.chair_3, + Species::Table => &self.table, + Species::Table2 => &self.table_2, + Species::Table3 => &self.table_3, + Species::Drawer => &self.drawer, + Species::BedBlue => &self.bed_blue, + Species::Carpet => &self.carpet, + Species::Bedroll => &self.bedroll, + Species::CarpetHumanRound => &self.carpet_human_round, + Species::CarpetHumanSquare => &self.carpet_human_square, + Species::CarpetHumanSquare2 => &self.carpet_human_square_2, + Species::CarpetHumanSquircle => &self.carpet_human_squircle, + Species::Pouch => &self.pouch, + Species::CraftingBench => &self.crafting_bench, + Species::BoltFire => &self.bolt_fire, + Species::BoltFireBig => &self.bolt_fire_big, + Species::ArrowSnake => &self.arrow_snake, + Species::TrainingDummy => &self.training_dummy, + Species::FireworkBlue => &self.firework_blue, + Species::FireworkGreen => &self.firework_green, + Species::FireworkPurple => &self.firework_purple, + Species::FireworkRed => &self.firework_red, + Species::FireworkWhite => &self.firework_white, + Species::FireworkYellow => &self.firework_yellow, + Species::MultiArrow => &self.multi_arrow, + Species::BoltNature => &self.bolt_nature, + Species::MeatDrop => &self.meat_drop, + Species::Steak => &self.steak, + Species::Crossbow => &self.crossbow, + Species::ArrowTurret => &self.arrow_turret, + Species::Coins => &self.coins, + Species::SilverOre => &self.silver_ore, + Species::GoldOre => &self.gold_ore, + Species::ClayRocket => &self.clay_rocket, + Species::HaniwaSentry => &self.haniwa_sentry, + } + } +} + +pub const ALL_SPECIES: [Species; 71] = [ + Species::Arrow, + Species::Bomb, + Species::Scarecrow, + Species::Cauldron, + Species::ChestVines, + Species::Chest, + Species::ChestDark, + Species::ChestDemon, + Species::ChestGold, + Species::ChestLight, + Species::ChestOpen, + Species::ChestSkull, + Species::Pumpkin, + Species::Pumpkin2, + Species::Pumpkin3, + Species::Pumpkin4, + Species::Pumpkin5, + Species::Campfire, + Species::CampfireLit, + Species::LanternGround, + Species::LanternGroundOpen, + Species::LanternStanding, + Species::LanternStanding2, + Species::PotionRed, + Species::PotionBlue, + Species::PotionGreen, + Species::Crate, + Species::Tent, + Species::WindowSpooky, + Species::DoorSpooky, + Species::Anvil, + Species::Gravestone, + Species::Gravestone2, + Species::Bench, + Species::Chair, + Species::Chair2, + Species::Chair3, + Species::Table, + Species::Table2, + Species::Table3, + Species::Drawer, + Species::BedBlue, + Species::Carpet, + Species::Bedroll, + Species::CarpetHumanRound, + Species::CarpetHumanSquare, + Species::CarpetHumanSquare2, + Species::CarpetHumanSquircle, + Species::Pouch, + Species::CraftingBench, + Species::BoltFire, + Species::BoltFireBig, + Species::ArrowSnake, + Species::TrainingDummy, + Species::FireworkBlue, + Species::FireworkGreen, + Species::FireworkPurple, + Species::FireworkRed, + Species::FireworkWhite, + Species::FireworkYellow, + Species::MultiArrow, + Species::BoltNature, + Species::MeatDrop, + Species::Steak, + Species::Crossbow, + Species::ArrowTurret, + Species::Coins, + Species::SilverOre, + Species::GoldOre, + Species::ClayRocket, + Species::HaniwaSentry, +]; + +impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies { + type IntoIter = std::iter::Copied>; + type Item = Species; + + fn into_iter(self) -> Self::IntoIter { ALL_SPECIES.iter().copied() } +} + +impl From for super::Body { + fn from(body: Body) -> Self { super::Body::Object(body) } +} + +impl Species { + pub fn for_firework(reagent: Reagent) -> Species { + match reagent { + Reagent::Blue => Species::FireworkBlue, + Reagent::Green => Species::FireworkGreen, + Reagent::Purple => Species::FireworkPurple, + Reagent::Red => Species::FireworkRed, + Reagent::White => Species::FireworkWhite, + Reagent::Yellow => Species::FireworkYellow, + } + } + + pub fn to_string(&self) -> &str { + match self { + Species::Arrow => "arrow", + Species::Bomb => "bomb", + Species::Scarecrow => "scarecrow", + Species::Cauldron => "cauldron", + Species::ChestVines => "chest_vines", + Species::Chest => "chest", + Species::ChestDark => "chest_dark", + Species::ChestDemon => "chest_demon", + Species::ChestGold => "chest_gold", + Species::ChestLight => "chest_light", + Species::ChestOpen => "chest_open", + Species::ChestSkull => "chest_skull", + Species::Pumpkin => "pumpkin", + Species::Pumpkin2 => "pumpkin_2", + Species::Pumpkin3 => "pumpkin_3", + Species::Pumpkin4 => "pumpkin_4", + Species::Pumpkin5 => "pumpkin_5", + Species::Campfire => "campfire", + Species::CampfireLit => "campfire_lit", + Species::LanternGround => "lantern_ground", + Species::LanternGroundOpen => "lantern_ground_open", + Species::LanternStanding => "lantern_standing", + Species::LanternStanding2 => "lantern_standing_2", + Species::PotionRed => "potion_red", + Species::PotionBlue => "potion_blue", + Species::PotionGreen => "potion_green", + Species::Crate => "crate_0", + Species::Tent => "tent", + Species::WindowSpooky => "window_spooky", + Species::DoorSpooky => "door_spooky", + Species::Anvil => "anvil", + Species::Gravestone => "gravestone", + Species::Gravestone2 => "gravestone_2", + Species::Bench => "bench", + Species::Chair => "chair", + Species::Chair2 => "chair_2", + Species::Chair3 => "chair_3", + Species::Table => "table", + Species::Table2 => "table_2", + Species::Table3 => "table_3", + Species::Drawer => "drawer", + Species::BedBlue => "bed_blue", + Species::Carpet => "carpet", + Species::Bedroll => "bedroll", + Species::CarpetHumanRound => "carpet_human_round", + Species::CarpetHumanSquare => "carpet_human_square", + Species::CarpetHumanSquare2 => "carpet_human_square_2", + Species::CarpetHumanSquircle => "carpet_human_squircle", + Species::Pouch => "pouch", + Species::CraftingBench => "crafting_bench", + Species::BoltFire => "bolt_fire", + Species::BoltFireBig => "bolt_fire_big", + Species::ArrowSnake => "arrow_snake", + Species::TrainingDummy => "training_dummy", + Species::FireworkBlue => "firework_blue", + Species::FireworkGreen => "firework_green", + Species::FireworkPurple => "firework_purple", + Species::FireworkRed => "firework_red", + Species::FireworkWhite => "firework_white", + Species::FireworkYellow => "firework_yellow", + Species::MultiArrow => "multi_arrow", + Species::BoltNature => "bolt_nature", + Species::MeatDrop => "meat_drop", + Species::Steak => "steak", + Species::Crossbow => "crossbow", + Species::ArrowTurret => "arrow_turret", + Species::Coins => "coins", + Species::SilverOre => "silver_ore", + Species::GoldOre => "gold_ore", + Species::ClayRocket => "clay_rocket", + Species::HaniwaSentry => "haniwa_sentry", + } + } + + //pub fn density(&self) -> Density { + // let density = match self { + // Body::Anvil | Body::Cauldron => IRON_DENSITY, + // Body::Arrow | Body::ArrowSnake | Body::ArrowTurret | Body::MultiArrow => 500.0, + // Body::Bomb => 2000.0, // I have no idea what it's supposed to be + // Body::Crate => 300.0, // let's say it's a lot of wood and maybe some contents + // Body::Scarecrow => 900.0, + // Body::TrainingDummy => 2000.0, + // // let them sink + // _ => 1.1 * WATER_DENSITY, + // }; + + // Density(density) + //} + + //pub fn mass(&self) -> Mass { + // let m = match self { + // // I think MultiArrow is one of several arrows, not several arrows combined? + // Body::Anvil => 100.0, + // Body::Arrow | Body::ArrowSnake | Body::ArrowTurret | Body::MultiArrow => 0.003, + // Body::BedBlue => 50.0, + // Body::Bedroll => 3.0, + // Body::Bench => 100.0, + // Body::BoltFire | Body::BoltFireBig | Body::BoltNature => 1.0, + // Body::Bomb => { + // 0.5 * IRON_DENSITY * std::f32::consts::PI / 6.0 * self.dimensions().x.powi(3) + // }, + // Body::Campfire | Body::CampfireLit => 300.0, + // Body::Carpet + // | Body::CarpetHumanRound + // | Body::CarpetHumanSquare + // | Body::CarpetHumanSquare2 + // | Body::CarpetHumanSquircle => 10.0, + // Body::Cauldron => 5.0, + // Body::Chair | Body::Chair2 | Body::Chair3 => 10.0, + // Body::Chest + // | Body::ChestDark + // | Body::ChestDemon + // | Body::ChestGold + // | Body::ChestLight + // | Body::ChestOpen + // | Body::ChestSkull + // | Body::ChestVines => 100.0, + // Body::Coins => 1.0, + // Body::CraftingBench => 100.0, + // Body::Crate => 50.0, + // Body::Crossbow => 200.0, + // Body::DoorSpooky => 20.0, + // Body::Drawer => 50.0, + // Body::FireworkBlue + // | Body::FireworkGreen + // | Body::FireworkPurple + // | Body::FireworkRed + // | Body::FireworkWhite + // | Body::FireworkYellow => 1.0, + // Body::Gravestone => 100.0, + // Body::Gravestone2 => 100.0, + // Body::LanternGround + // | Body::LanternGroundOpen + // | Body::LanternStanding + // | Body::LanternStanding2 => 3.0, + // Body::MeatDrop => 5.0, + // Body::PotionBlue | Body::PotionGreen | Body::PotionRed => 5.0, + // Body::Pouch => 1.0, + // Body::Pumpkin | Body::Pumpkin2 | Body::Pumpkin3 | Body::Pumpkin4 | Body::Pumpkin5 => { + // 10.0 + // }, + // Body::Scarecrow => 50.0, + // Body::Steak => 2.0, + // Body::Table | Body::Table2 | Body::Table3 => 50.0, + // Body::Tent => 50.0, + // Body::TrainingDummy => 60.0, + // Body::WindowSpooky => 10.0, + // Body::SilverOre => 1000.0, + // Body::GoldOre => 1000.0, + // Body::ClayRocket => 50.0, + // Body::HaniwaSentry => 300.0, + // }; + + // Mass(m) + //} + + //pub fn dimensions(&self) -> Vec3 { + // match self { + // Body::Arrow | Body::ArrowSnake | Body::MultiArrow | Body::ArrowTurret => { + // Vec3::new(0.01, 0.8, 0.01) + // }, + // Body::BoltFire => Vec3::new(0.1, 0.1, 0.1), + // Body::Crossbow => Vec3::new(3.0, 3.0, 1.5), + // Body::HaniwaSentry => Vec3::new(0.8, 0.8, 1.4), + // _ => Vec3::broadcast(0.2), + // } + //} +} diff --git a/common/src/comp/body/ship.rs b/common/src/comp/body/ship.rs index d36c8823e7..040a9a90e7 100644 --- a/common/src/comp/body/ship.rs +++ b/common/src/comp/body/ship.rs @@ -1,7 +1,6 @@ use crate::{ comp::{Density, Mass}, consts::AIR_DENSITY, - make_case_elim, make_proj_elim, }; use serde::{Deserialize, Serialize}; diff --git a/common/src/comp/fluid_dynamics.rs b/common/src/comp/fluid_dynamics.rs index d80a277997..e09f55891f 100644 --- a/common/src/comp/fluid_dynamics.rs +++ b/common/src/comp/fluid_dynamics.rs @@ -219,36 +219,36 @@ impl Body { 0.031 * PI * dim.x * 0.2 * dim.z }, - Body::Object(object) => match object { + Body::Object(body) => match body.species { // very streamlined objects - object::Body::Arrow - | object::Body::ArrowSnake - | object::Body::ArrowTurret - | object::Body::FireworkBlue - | object::Body::FireworkGreen - | object::Body::FireworkPurple - | object::Body::FireworkRed - | object::Body::FireworkWhite - | object::Body::FireworkYellow - | object::Body::MultiArrow => { + object::Species::Arrow + | object::Species::ArrowSnake + | object::Species::ArrowTurret + | object::Species::FireworkBlue + | object::Species::FireworkGreen + | object::Species::FireworkPurple + | object::Species::FireworkRed + | object::Species::FireworkWhite + | object::Species::FireworkYellow + | object::Species::MultiArrow => { let dim = self.dimensions().map(|a| a * 0.5); 0.02 * PI * dim.x * dim.z }, // spherical-ish objects - object::Body::BoltFire - | object::Body::BoltFireBig - | object::Body::BoltNature - | object::Body::Bomb - | object::Body::PotionBlue - | object::Body::PotionGreen - | object::Body::PotionRed - | object::Body::Pouch - | object::Body::Pumpkin - | object::Body::Pumpkin2 - | object::Body::Pumpkin3 - | object::Body::Pumpkin4 - | object::Body::Pumpkin5 => { + object::Species::BoltFire + | object::Species::BoltFireBig + | object::Species::BoltNature + | object::Species::Bomb + | object::Species::PotionBlue + | object::Species::PotionGreen + | object::Species::PotionRed + | object::Species::Pouch + | object::Species::Pumpkin + | object::Species::Pumpkin2 + | object::Species::Pumpkin3 + | object::Species::Pumpkin4 + | object::Species::Pumpkin5 => { let dim = self.dimensions().map(|a| a * 0.5); 0.5 * PI * dim.x * dim.z }, diff --git a/common/src/comp/inventory/loadout_builder.rs b/common/src/comp/inventory/loadout_builder.rs index be0c2728c7..843ea9ee92 100644 --- a/common/src/comp/inventory/loadout_builder.rs +++ b/common/src/comp/inventory/loadout_builder.rs @@ -310,13 +310,13 @@ impl LoadoutBuilder { )); }, }, - Body::Object(body) => match body { - object::Body::Crossbow => { + Body::Object(body) => match body.species { + object::Species::Crossbow => { main_tool = Some(Item::new_from_asset_expect( "common.items.npc_weapons.unique.turret", )); }, - object::Body::HaniwaSentry => { + object::Species::HaniwaSentry => { main_tool = Some(Item::new_from_asset_expect( "common.items.npc_weapons.unique.haniwa_sentry", )); diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 0d4ebd855b..bdc1f1bfdc 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -420,7 +420,7 @@ fn handle_drop_all( server .state - .create_object(Default::default(), comp::object::Body::Pouch) + .create_object(Default::default(), comp::object::Species::Pouch) .with(comp::Pos(Vec3::new( pos.0.x + rng.gen_range(5.0..10.0), pos.0.y + rng.gen_range(5.0..10.0), @@ -1120,7 +1120,7 @@ fn handle_spawn_training_dummy( 10.0, ); - let body = comp::Body::Object(comp::object::Body::TrainingDummy); + let body = comp::Body::Object(comp::object::Body { species: comp::object::Species::TrainingDummy }); let stats = comp::Stats::new("Training Dummy".to_string()); let skill_set = comp::SkillSet::default(); @@ -1217,7 +1217,7 @@ fn handle_spawn_campfire( let pos = position(server, target, "target")?; server .state - .create_object(pos, comp::object::Body::CampfireLit) + .create_object(pos, comp::object::Species::CampfireLit) .with(LightEmitter { col: Rgb::new(1.0, 0.65, 0.2), strength: 2.0, @@ -1675,7 +1675,7 @@ fn handle_object( .create_object(pos, ori, obj_type) .with(ori);*/ let obj_str_res = obj_type.as_ref().map(String::as_str); - if let Some(obj_type) = comp::object::ALL_OBJECTS + if let Some(obj_type) = comp::object::ALL_SPECIES .iter() .find(|o| Ok(o.to_string()) == obj_str_res) { @@ -1944,7 +1944,7 @@ fn handle_spawn_wiring( let builder1 = server .state - .create_wiring(pos, comp::object::Body::Coins, WiringElement { + .create_wiring(pos, comp::object::Species::Coins, WiringElement { actions: vec![WiringAction { formula: wiring::OutputFormula::Constant { value: 1.0 }, threshold: 1.0, @@ -1969,7 +1969,7 @@ fn handle_spawn_wiring( pos.0.x += 3.0; let builder2 = server .state - .create_wiring(pos, comp::object::Body::Coins, WiringElement { + .create_wiring(pos, comp::object::Species::Coins, WiringElement { actions: vec![ WiringAction { formula: wiring::OutputFormula::Input { @@ -2008,7 +2008,7 @@ fn handle_spawn_wiring( pos.0.x += 3.0; let builder3 = server .state - .create_wiring(pos, comp::object::Body::TrainingDummy, WiringElement { + .create_wiring(pos, comp::object::Species::TrainingDummy, WiringElement { actions: vec![], inputs: HashMap::new(), outputs: HashMap::new(), diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 1a59e6096c..1926ed9d95 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -233,7 +233,7 @@ pub fn handle_beam(server: &mut Server, properties: beam::Properties, pos: Pos, pub fn handle_create_waypoint(server: &mut Server, pos: Vec3) { server .state - .create_object(Pos(pos), comp::object::Body::CampfireLit) + .create_object(Pos(pos), comp::object::Species::CampfireLit) .with(LightEmitter { col: Rgb::new(1.0, 0.3, 0.1), strength: 5.0, diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index fe1ab21a00..c1e254e18f 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -452,12 +452,12 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc if let Some(pos) = pos { let _ = state .create_object(comp::Pos(pos.0 + Vec3::unit_z() * 0.25), match old_body { - Some(common::comp::Body::Humanoid(_)) => object::Body::Pouch, - Some(common::comp::Body::BipedSmall(_)) => object::Body::Pouch, - Some(common::comp::Body::Golem(_)) => object::Body::Chest, + Some(common::comp::Body::Humanoid(_)) => object::Species::Pouch, + Some(common::comp::Body::BipedSmall(_)) => object::Species::Pouch, + Some(common::comp::Body::Golem(_)) => object::Species::Chest, Some(common::comp::Body::BipedLarge(_)) - | Some(common::comp::Body::QuadrupedLow(_)) => object::Body::MeatDrop, - _ => object::Body::Steak, + | Some(common::comp::Body::QuadrupedLow(_)) => object::Species::MeatDrop, + _ => object::Species::Steak, }) .maybe_with(vel) .with(item) diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index d671b1e341..ba1b2798e3 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -289,7 +289,7 @@ pub fn handle_mine_block(server: &mut Server, pos: Vec3, tool: Option comp::object::Body::Coins, - _ => comp::object::Body::Pouch, + "common.items.utility.coins" => comp::object::Species::Coins, + _ => comp::object::Species::Pouch, }; // If item is a container check inside of it for Debug items and remove them @@ -711,9 +711,9 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv let mut new_entity = state .create_object(Default::default(), match kind { - item::Throwable::Bomb => comp::object::Body::Bomb, - item::Throwable::Firework(reagent) => comp::object::Body::for_firework(reagent), - item::Throwable::TrainingDummy => comp::object::Body::TrainingDummy, + item::Throwable::Bomb => comp::object::Species::Bomb, + item::Throwable::Firework(reagent) => comp::object::Species::for_firework(reagent), + item::Throwable::TrainingDummy => comp::object::Species::TrainingDummy, }) .with(comp::Pos(pos.0 + Vec3::unit_z() * 0.25)) .with(comp::Vel(vel)); diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 7d10b9f53b..c33a962d70 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -45,7 +45,7 @@ pub trait StateExt { body: comp::Body, ) -> EcsEntityBuilder; /// Build a static object entity - fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder; + fn create_object(&mut self, pos: comp::Pos, species: comp::object::Species) -> EcsEntityBuilder; fn create_ship( &mut self, pos: comp::Pos, @@ -79,7 +79,7 @@ pub trait StateExt { fn create_wiring( &mut self, pos: comp::Pos, - object: comp::object::Body, + species: comp::object::Species, wiring_element: wiring::WiringElement, ) -> EcsEntityBuilder; // NOTE: currently only used for testing @@ -243,8 +243,8 @@ impl StateExt for State { .with(comp::Auras::default()) } - fn create_object(&mut self, pos: comp::Pos, object: comp::object::Body) -> EcsEntityBuilder { - let body = comp::Body::Object(object); + fn create_object(&mut self, pos: comp::Pos, species: comp::object::Species) -> EcsEntityBuilder { + let body = comp::Body::Object(comp::object::Body { species }); let (mass, density) = { let body_attributes = &self.ecs().read_resource::(); ( @@ -257,7 +257,6 @@ impl StateExt for State { .as_ref() .map_or(Density::default(), |bd| body.density(&bd)), ) - //(Mass::default(), Density::default()) }; self.ecs_mut() .create_entity_synced() @@ -271,7 +270,7 @@ impl StateExt for State { z_min: 0.0, z_max: body.height(), }) - .with(body) + .with(comp::Body::Object(comp::object::Body { species })) } fn create_ship( @@ -424,7 +423,7 @@ impl StateExt for State { fn create_wiring( &mut self, pos: comp::Pos, - object: comp::object::Body, + species: comp::object::Species, wiring_element: wiring::WiringElement, ) -> EcsEntityBuilder { self.ecs_mut() @@ -433,11 +432,11 @@ impl StateExt for State { .with(comp::Vel(Vec3::zero())) .with(comp::Ori::default()) .with(comp::Collider::Box { - radius: comp::Body::Object(object).radius(), + radius: comp::Body::Object(comp::body::object::Body { species }).radius(), z_min: 0.0, - z_max: comp::Body::Object(object).height() + z_max: comp::Body::Object(comp::body::object::Body { species }).height(), }) - .with(comp::Body::Object(object)) + .with(comp::Body::Object(comp::body::object::Body { species })) .with(comp::Mass(10.0)) // .with(comp::Sticky) .with(wiring_element) diff --git a/server/src/sys/wiring/dispatch_actions.rs b/server/src/sys/wiring/dispatch_actions.rs index 641275a006..248651f192 100644 --- a/server/src/sys/wiring/dispatch_actions.rs +++ b/server/src/sys/wiring/dispatch_actions.rs @@ -109,7 +109,7 @@ fn dispatch_action_spawn_projectile( server_emitter.emit(ServerEvent::Shoot { entity, dir: Dir::forward(), - body: Body::Object(object::Body::Arrow), + body: Body::Object(object::Body{ species: object::Species::Arrow }), projectile: constr.create_projectile(None, 1.0, 1.0), light: None, speed: 5.0, diff --git a/voxygen/anim/src/object/mod.rs b/voxygen/anim/src/object/mod.rs index 7a58390ed0..edd0ac3e89 100644 --- a/voxygen/anim/src/object/mod.rs +++ b/voxygen/anim/src/object/mod.rs @@ -67,14 +67,14 @@ impl Default for SkeletonAttr { impl<'a> From<&'a Body> for SkeletonAttr { fn from(body: &'a Body) -> Self { - use comp::object::Body::*; + use comp::object::Species::*; Self { - bone0: match body { + bone0: match body.species { Crossbow => (0.0, 0.0, 11.0), HaniwaSentry => (0.0, 0.0, 10.5), _ => (0.0, 0.0, 0.0), }, - bone1: match body { + bone1: match body.species { Crossbow => (0.0, 0.0, 8.0), HaniwaSentry => (0.0, 0.0, 3.0), _ => (0.0, 0.0, 0.0), diff --git a/voxygen/anim/src/object/shoot.rs b/voxygen/anim/src/object/shoot.rs index 32bcb56542..5949516d66 100644 --- a/voxygen/anim/src/object/shoot.rs +++ b/voxygen/anim/src/object/shoot.rs @@ -3,7 +3,7 @@ use super::{ ObjectSkeleton, SkeletonAttr, }; use common::{ - comp::{item::ToolKind, object::Body}, + comp::{item::ToolKind, object::{Species, Body}}, states::utils::StageSection, }; pub struct ShootAnimation; @@ -45,8 +45,8 @@ impl Animation for ShootAnimation { next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0; #[allow(clippy::single_match)] - match body { - Body::Crossbow => { + match body.species { + Species::Crossbow => { next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0; next.bone0.orientation = Quaternion::rotation_x(movement1 * 0.05 + movement2 * 0.1) * (1.0 - movement3); diff --git a/voxygen/src/audio/sfx/event_mapper/campfire/mod.rs b/voxygen/src/audio/sfx/event_mapper/campfire/mod.rs index cdd6f9ea68..64faa396db 100644 --- a/voxygen/src/audio/sfx/event_mapper/campfire/mod.rs +++ b/voxygen/src/audio/sfx/event_mapper/campfire/mod.rs @@ -59,7 +59,7 @@ impl EventMapper for CampfireEventMapper { .join() .filter(|(_, _, e_pos)| (e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR) { - if let Body::Object(object::Body::CampfireLit) = body { + if let Body::Object(object::Body { species: object::Species::CampfireLit }) = body { let internal_state = self.event_history.entry(entity).or_default(); let mapped_event = SfxEvent::Campfire; diff --git a/voxygen/src/audio/sfx/mod.rs b/voxygen/src/audio/sfx/mod.rs index b43417ed10..d15ff17dae 100644 --- a/voxygen/src/audio/sfx/mod.rs +++ b/voxygen/src/audio/sfx/mod.rs @@ -332,20 +332,16 @@ impl SfxMgr { }, Outcome::ProjectileShot { pos, body, .. } => { match body { - Body::Object( - object::Body::Arrow - | object::Body::MultiArrow - | object::Body::ArrowSnake - | object::Body::ArrowTurret, - ) => { + Body::Object(object::Body { species: object::Species::Arrow }) + | Body::Object(object::Body { species: object::Species::MultiArrow }) + | Body::Object(object::Body { species: object::Species::ArrowSnake }) + | Body::Object(object::Body { species: object::Species::ArrowTurret }) => { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowShot); audio.emit_sfx(sfx_trigger_item, *pos, None, false); }, - Body::Object( - object::Body::BoltFire - | object::Body::BoltFireBig - | object::Body::BoltNature, - ) => { + Body::Object(object::Body { species: object::Species::BoltFire }) + | Body::Object(object::Body { species: object::Species::BoltFireBig }) + | Body::Object(object::Body { species: object::Species::BoltNature }) => { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::FireShot); audio.emit_sfx(sfx_trigger_item, *pos, None, false); }, @@ -361,12 +357,10 @@ impl SfxMgr { target, .. } => match body { - Body::Object( - object::Body::Arrow - | object::Body::MultiArrow - | object::Body::ArrowSnake - | object::Body::ArrowTurret, - ) => { + Body::Object(object::Body { species: object::Species::Arrow }) + | Body::Object(object::Body { species: object::Species::MultiArrow }) + | Body::Object(object::Body { species: object::Species::ArrowSnake }) + | Body::Object(object::Body { species: object::Species::ArrowTurret }) => { if target.is_none() { let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowMiss); audio.emit_sfx(sfx_trigger_item, *pos, Some(2.0), false); diff --git a/voxygen/src/ecs/sys/interpolation.rs b/voxygen/src/ecs/sys/interpolation.rs index 97dba3a071..6e8a777ce5 100644 --- a/voxygen/src/ecs/sys/interpolation.rs +++ b/voxygen/src/ecs/sys/interpolation.rs @@ -90,8 +90,8 @@ impl<'a> System<'a> for Sys { #[allow(clippy::collapsible_match)] fn base_ori_interp(body: &Body) -> f32 { match body { - Body::Object(object) => match object { - object::Body::Crossbow | object::Body::HaniwaSentry => 100.0, + Body::Object(object) => match object.species { + object::Species::Crossbow | object::Species::HaniwaSentry => 100.0, _ => 10.0, }, _ => 10.0, diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 0cc0e5f1b6..1c51e4cf20 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -302,33 +302,32 @@ impl ParticleMgr { .join() { match body { - Body::Object(object::Body::CampfireLit) => { - self.maintain_campfirelit_particles(scene_data, pos, vel) - }, - Body::Object( - object::Body::Arrow - | object::Body::MultiArrow - | object::Body::ArrowSnake - | object::Body::ArrowTurret, - ) => self.maintain_arrow_particles(scene_data, pos, vel), - Body::Object(object::Body::BoltFire) => { - self.maintain_boltfire_particles(scene_data, pos, vel) - }, - Body::Object(object::Body::BoltFireBig) => { - self.maintain_boltfirebig_particles(scene_data, pos, vel) - }, - Body::Object(object::Body::BoltNature) => { - self.maintain_boltnature_particles(scene_data, pos, vel) - }, - Body::Object( - object::Body::Bomb - | object::Body::FireworkBlue - | object::Body::FireworkGreen - | object::Body::FireworkPurple - | object::Body::FireworkRed - | object::Body::FireworkWhite - | object::Body::FireworkYellow, - ) => self.maintain_bomb_particles(scene_data, pos, vel), + Body::Object(body) => match body.species { + object::Species::CampfireLit => { + self.maintain_campfirelit_particles(scene_data, pos, vel) + }, + object::Species::Arrow + | object::Species::MultiArrow + | object::Species::ArrowSnake + | object::Species::ArrowTurret => self.maintain_arrow_particles(scene_data, pos, vel), + object::Species::BoltFire => { + self.maintain_boltfire_particles(scene_data, pos, vel) + }, + object::Species::BoltFireBig => { + self.maintain_boltfirebig_particles(scene_data, pos, vel) + }, + object::Species::BoltNature => { + self.maintain_boltnature_particles(scene_data, pos, vel) + }, + object::Species::Bomb + | object::Species::FireworkBlue + | object::Species::FireworkGreen + | object::Species::FireworkPurple + | object::Species::FireworkRed + | object::Species::FireworkWhite + | object::Species::FireworkYellow => self.maintain_bomb_particles(scene_data, pos, vel), + _ => {}, + } _ => {}, } } diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index f0acba138b..c77a8d8123 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -673,7 +673,7 @@ impl Floor { )), 3 => match dynamic_rng.gen_range(0..4) { 0 => entity - .with_body(comp::Body::Object(comp::object::Body::HaniwaSentry)) + .with_body(comp::Body::Object(comp::object::Body { species: comp::object::Species::HaniwaSentry })) .with_name("Haniwa Sentry".to_string()) .with_loot_drop(comp::Item::new_from_asset_expect( "common.items.crafting_ing.stones", @@ -750,7 +750,7 @@ impl Floor { "common.items.weapons.staff.cultist_staff", )), 1 => entity - .with_body(comp::Body::Object(comp::object::Body::Crossbow)) + .with_body(comp::Body::Object(comp::object::Body { species: comp::object::Species::Crossbow })) .with_name("Possessed Turret".to_string()) .with_loot_drop(comp::Item::new_from_asset_expect( "common.items.crafting_ing.twigs", diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 0cecda5ac6..385f67cb4e 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -899,7 +899,7 @@ impl Settlement { .with_body(match dynamic_rng.gen_range(0..5) { _ if is_dummy => { is_human = false; - object::Body::TrainingDummy.into() + comp::Body::Object(object::Body { species: object::Species::TrainingDummy }) }, 0 => { let species = match dynamic_rng.gen_range(0..5) {