mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Give objects species
This commit is contained in:
parent
8e5f74c00c
commit
5e5924e931
@ -244,7 +244,7 @@ lazy_static! {
|
|||||||
|
|
||||||
souls
|
souls
|
||||||
};
|
};
|
||||||
static ref OBJECTS: Vec<String> = comp::object::ALL_OBJECTS
|
static ref OBJECTS: Vec<String> = comp::object::ALL_SPECIES
|
||||||
.iter()
|
.iter()
|
||||||
.map(|o| o.to_string().to_string())
|
.map(|o| o.to_string().to_string())
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -92,11 +92,11 @@ pub struct AllBodies<BodyMeta, SpeciesMeta> {
|
|||||||
pub fish_small: BodyData<BodyMeta, fish_small::AllSpecies<SpeciesMeta>>,
|
pub fish_small: BodyData<BodyMeta, fish_small::AllSpecies<SpeciesMeta>>,
|
||||||
pub biped_large: BodyData<BodyMeta, biped_large::AllSpecies<SpeciesMeta>>,
|
pub biped_large: BodyData<BodyMeta, biped_large::AllSpecies<SpeciesMeta>>,
|
||||||
pub biped_small: BodyData<BodyMeta, biped_small::AllSpecies<SpeciesMeta>>,
|
pub biped_small: BodyData<BodyMeta, biped_small::AllSpecies<SpeciesMeta>>,
|
||||||
pub object: BodyData<BodyMeta, ()>,
|
pub object: BodyData<BodyMeta, object::AllSpecies<SpeciesMeta>>,
|
||||||
pub golem: BodyData<BodyMeta, golem::AllSpecies<SpeciesMeta>>,
|
pub golem: BodyData<BodyMeta, golem::AllSpecies<SpeciesMeta>>,
|
||||||
pub theropod: BodyData<BodyMeta, theropod::AllSpecies<SpeciesMeta>>,
|
pub theropod: BodyData<BodyMeta, theropod::AllSpecies<SpeciesMeta>>,
|
||||||
pub quadruped_low: BodyData<BodyMeta, quadruped_low::AllSpecies<SpeciesMeta>>,
|
pub quadruped_low: BodyData<BodyMeta, quadruped_low::AllSpecies<SpeciesMeta>>,
|
||||||
pub ship: BodyData<BodyMeta, ()>,
|
pub ship: BodyData<BodyMeta, ship::AllSpecies<SpeciesMeta>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can only retrieve body metadata by direct index.
|
/// Can only retrieve body metadata by direct index.
|
||||||
@ -313,9 +313,8 @@ impl Body {
|
|||||||
get_body_attribute(&body_attribute.quadruped_small, body.species)
|
get_body_attribute(&body_attribute.quadruped_small, body.species)
|
||||||
},
|
},
|
||||||
Body::Theropod(body) => get_body_attribute(&body_attribute.theropod, 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(body) => get_body_attribute(&body_attribute.ship, body.species),
|
||||||
Body::Ship(ship) => T::default(),
|
Body::Object(body) => get_body_attribute(&body_attribute.object, body.species),
|
||||||
Body::Object(object) => T::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,36 +396,37 @@ impl Body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn aggro(&self, body_aggros: &AllBodiesAggro) -> f32 {
|
pub fn aggro(&self, body_aggros: &AllBodiesAggro) -> f32 {
|
||||||
match self {
|
0.0 //match self {
|
||||||
Body::BipedLarge(body) => {
|
// Body::BipedLarge(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.biped_large, body.species)
|
// get_body_f32_attribute(&body_aggros.biped_large, body.species)
|
||||||
},
|
// },
|
||||||
Body::BipedSmall(body) => {
|
// Body::BipedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.biped_small, body.species)
|
// get_body_f32_attribute(&body_aggros.biped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdMedium(body) => {
|
// Body::BirdMedium(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.bird_medium, body.species)
|
// get_body_f32_attribute(&body_aggros.bird_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdLarge(body) => get_body_f32_attribute(&body_aggros.bird_large, 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::FishSmall(body) => get_body_f32_attribute(&body_aggros.fish_small, body.species),
|
||||||
Body::FishMedium(body) => {
|
// Body::FishMedium(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.fish_medium, body.species)
|
// get_body_f32_attribute(&body_aggros.fish_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::Humanoid(body) => get_body_f32_attribute(&body_aggros.humanoid, body.species),
|
// Body::Humanoid(body) => get_body_f32_attribute(&body_aggros.humanoid, body.species),
|
||||||
Body::QuadrupedMedium(body) => {
|
// Body::QuadrupedMedium(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.quadruped_medium, body.species)
|
// get_body_f32_attribute(&body_aggros.quadruped_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::QuadrupedSmall(body) => {
|
// Body::QuadrupedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.quadruped_small, body.species)
|
// get_body_f32_attribute(&body_aggros.quadruped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::Theropod(body) => get_body_f32_attribute(&body_aggros.theropod, 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::Dragon(body) => get_body_f32_attribute(&body_aggros.dragon, body.species),
|
||||||
Body::QuadrupedLow(body) => {
|
// Body::QuadrupedLow(body) => {
|
||||||
get_body_f32_attribute(&body_aggros.quadruped_low, body.species)
|
// get_body_f32_attribute(&body_aggros.quadruped_low, body.species)
|
||||||
},
|
// },
|
||||||
Body::Golem(body) => get_body_f32_attribute(&body_aggros.golem, body.species),
|
// Body::Golem(body) => get_body_f32_attribute(&body_aggros.golem, body.species),
|
||||||
Body::Ship(_) | Body::Object(_) => 0.0,
|
// 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
|
/// The width (shoulder to shoulder), length (nose to tail) and height
|
||||||
@ -469,7 +469,7 @@ impl Body {
|
|||||||
};
|
};
|
||||||
Vec3::new(1.5, 0.5, height)
|
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 {
|
Body::QuadrupedMedium(body) => match body.species {
|
||||||
quadruped_medium::Species::Barghest => Vec3::new(2.0, 3.6, 2.5),
|
quadruped_medium::Species::Barghest => Vec3::new(2.0, 3.6, 2.5),
|
||||||
quadruped_medium::Species::Bear => Vec3::new(2.0, 3.6, 2.0),
|
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 height(&self) -> f32 { self.dimensions().z }
|
||||||
|
|
||||||
pub fn base_energy(&self, body_energies: &AllBodiesBaseEnergy) -> u32 {
|
pub fn base_energy(&self, body_energies: &AllBodiesBaseEnergy) -> u32 {
|
||||||
match self {
|
1000
|
||||||
Body::BipedLarge(body) => {
|
//match self {
|
||||||
get_body_u32_attribute(&body_energies.biped_large, body.species)
|
// 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::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::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::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::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::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) => {
|
// Body::Humanoid(body) => get_body_u32_attribute(&body_energies.humanoid, body.species),
|
||||||
get_body_u32_attribute(&body_energies.quadruped_medium, 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::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::Theropod(body) => get_body_u32_attribute(&body_energies.theropod, body.species),
|
||||||
Body::QuadrupedLow(body) => {
|
// Body::Dragon(body) => get_body_u32_attribute(&body_energies.dragon, body.species),
|
||||||
get_body_u32_attribute(&body_energies.quadruped_low, 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,
|
// 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 {
|
pub fn base_health(&self, body_healths: &AllBodiesBaseHealth) -> u32 {
|
||||||
match self {
|
1000
|
||||||
Body::BipedLarge(body) => {
|
//match self {
|
||||||
get_body_u32_attribute(&body_healths.biped_large, body.species)
|
// 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::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::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::BirdLarge(body) => get_body_u32_attribute(&body_healths.bird_large, body.species),
|
||||||
Body::FishMedium(body) => {
|
// Body::FishSmall(body) => get_body_u32_attribute(&body_healths.fish_small, body.species),
|
||||||
get_body_u32_attribute(&body_healths.fish_medium, 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) => {
|
// Body::Humanoid(body) => get_body_u32_attribute(&body_healths.humanoid, body.species),
|
||||||
get_body_u32_attribute(&body_healths.quadruped_medium, 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::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::Theropod(body) => get_body_u32_attribute(&body_healths.theropod, body.species),
|
||||||
Body::QuadrupedLow(body) => {
|
// Body::Dragon(body) => get_body_u32_attribute(&body_healths.dragon, body.species),
|
||||||
get_body_u32_attribute(&body_healths.quadruped_low, 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::Golem(body) => get_body_u32_attribute(&body_healths.golem, body.species),
|
||||||
Body::Object(object) => match object {
|
// Body::Ship(body) => get_body_u32_attribute(&body_healths.ship, body.species), //10000,
|
||||||
object::Body::TrainingDummy => 10000,
|
// Body::Object(body) => get_body_u32_attribute(&body_healths.object, body.species), //match object {
|
||||||
object::Body::Crossbow => 800,
|
// // object::Body::TrainingDummy => 10000,
|
||||||
object::Body::HaniwaSentry => 600,
|
// // object::Body::Crossbow => 800,
|
||||||
_ => 10000,
|
// // object::Body::HaniwaSentry => 600,
|
||||||
},
|
// // _ => 10000,
|
||||||
}
|
// //},
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn base_health_increase(&self, body_health_increases: &AllBodiesBaseHealthIncrease) -> u32 {
|
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)
|
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::Golem(body) => get_body_u32_attribute(&body_health_increases.golem, body.species),
|
||||||
Body::Ship(_) => 500,
|
Body::Ship(body) => get_body_u32_attribute(&body_health_increases.ship, body.species), //500,
|
||||||
Body::Object(_) => 10,
|
Body::Object(body) => get_body_u32_attribute(&body_health_increases.object, body.species), //10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +670,7 @@ impl Body {
|
|||||||
BuffKind::Burning => match self {
|
BuffKind::Burning => match self {
|
||||||
Body::Golem(g) => matches!(g.species, golem::Species::ClayGolem),
|
Body::Golem(g) => matches!(g.species, golem::Species::ClayGolem),
|
||||||
Body::BipedSmall(b) => matches!(b.species, biped_small::Species::Haniwa),
|
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,
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{item::Reagent, Density, Mass},
|
comp::{item::Reagent, Density, Mass},
|
||||||
consts::{IRON_DENSITY, WATER_DENSITY},
|
consts::{IRON_DENSITY, WATER_DENSITY},
|
||||||
make_case_elim,
|
make_proj_elim,
|
||||||
};
|
};
|
||||||
use rand::{seq::SliceRandom, thread_rng};
|
use rand::{seq::SliceRandom, thread_rng};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::Vec3;
|
use vek::Vec3;
|
||||||
|
|
||||||
make_case_elim!(
|
make_proj_elim!(
|
||||||
body,
|
body,
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub struct Body {
|
||||||
|
pub species: Species,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum Body {
|
pub enum Species {
|
||||||
Arrow = 0,
|
Arrow = 0,
|
||||||
Bomb = 1,
|
Bomb = 1,
|
||||||
Scarecrow = 2,
|
Scarecrow = 2,
|
||||||
@ -84,272 +90,450 @@ make_case_elim!(
|
|||||||
ClayRocket = 69,
|
ClayRocket = 69,
|
||||||
HaniwaSentry = 70,
|
HaniwaSentry = 70,
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
pub fn random() -> Self {
|
pub fn random() -> Self {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
*(&ALL_OBJECTS).choose(&mut rng).unwrap()
|
Body {
|
||||||
}
|
species: *(&ALL_SPECIES).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<Body> 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",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_firework(reagent: Reagent) -> Body {
|
pub fn for_firework(reagent: Reagent) -> Body {
|
||||||
match reagent {
|
match reagent {
|
||||||
Reagent::Blue => Body::FireworkBlue,
|
Reagent::Blue => Body { species: Species::FireworkBlue },
|
||||||
Reagent::Green => Body::FireworkGreen,
|
Reagent::Green => Body { species: Species::FireworkGreen },
|
||||||
Reagent::Purple => Body::FireworkPurple,
|
Reagent::Purple => Body { species: Species::FireworkPurple },
|
||||||
Reagent::Red => Body::FireworkRed,
|
Reagent::Red => Body { species: Species::FireworkRed },
|
||||||
Reagent::White => Body::FireworkWhite,
|
Reagent::White => Body { species: Species::FireworkWhite },
|
||||||
Reagent::Yellow => Body::FireworkYellow,
|
Reagent::Yellow => Body { species: Species::FireworkYellow },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn density(&self) -> Density {
|
/// Data representing per-species generic data.
|
||||||
let density = match self {
|
///
|
||||||
Body::Anvil | Body::Cauldron => IRON_DENSITY,
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
Body::Arrow | Body::ArrowSnake | Body::ArrowTurret | Body::MultiArrow => 500.0,
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
Body::Bomb => 2000.0, // I have no idea what it's supposed to be
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
Body::Crate => 300.0, // let's say it's a lot of wood and maybe some contents
|
pub arrow: SpeciesMeta,
|
||||||
Body::Scarecrow => 900.0,
|
pub bomb: SpeciesMeta,
|
||||||
Body::TrainingDummy => 2000.0,
|
pub scarecrow: SpeciesMeta,
|
||||||
// let them sink
|
pub cauldron: SpeciesMeta,
|
||||||
_ => 1.1 * WATER_DENSITY,
|
pub chest_vines: SpeciesMeta,
|
||||||
};
|
pub chest: SpeciesMeta,
|
||||||
|
pub chest_dark: SpeciesMeta,
|
||||||
Density(density)
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mass(&self) -> Mass {
|
impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta> {
|
||||||
let m = match self {
|
type Output = SpeciesMeta;
|
||||||
// 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)
|
#[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 fn dimensions(&self) -> Vec3<f32> {
|
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<SpeciesMeta> {
|
||||||
|
type IntoIter = std::iter::Copied<std::slice::Iter<'static, Self::Item>>;
|
||||||
|
type Item = Species;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter { ALL_SPECIES.iter().copied() }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Body> 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 {
|
match self {
|
||||||
Body::Arrow | Body::ArrowSnake | Body::MultiArrow | Body::ArrowTurret => {
|
Species::Arrow => "arrow",
|
||||||
Vec3::new(0.01, 0.8, 0.01)
|
Species::Bomb => "bomb",
|
||||||
},
|
Species::Scarecrow => "scarecrow",
|
||||||
Body::BoltFire => Vec3::new(0.1, 0.1, 0.1),
|
Species::Cauldron => "cauldron",
|
||||||
Body::Crossbow => Vec3::new(3.0, 3.0, 1.5),
|
Species::ChestVines => "chest_vines",
|
||||||
Body::HaniwaSentry => Vec3::new(0.8, 0.8, 1.4),
|
Species::Chest => "chest",
|
||||||
_ => Vec3::broadcast(0.2),
|
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<f32> {
|
||||||
|
// 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),
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{Density, Mass},
|
comp::{Density, Mass},
|
||||||
consts::AIR_DENSITY,
|
consts::AIR_DENSITY,
|
||||||
make_case_elim,
|
|
||||||
make_proj_elim,
|
make_proj_elim,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -219,36 +219,36 @@ impl Body {
|
|||||||
0.031 * PI * dim.x * 0.2 * dim.z
|
0.031 * PI * dim.x * 0.2 * dim.z
|
||||||
},
|
},
|
||||||
|
|
||||||
Body::Object(object) => match object {
|
Body::Object(body) => match body.species {
|
||||||
// very streamlined objects
|
// very streamlined objects
|
||||||
object::Body::Arrow
|
object::Species::Arrow
|
||||||
| object::Body::ArrowSnake
|
| object::Species::ArrowSnake
|
||||||
| object::Body::ArrowTurret
|
| object::Species::ArrowTurret
|
||||||
| object::Body::FireworkBlue
|
| object::Species::FireworkBlue
|
||||||
| object::Body::FireworkGreen
|
| object::Species::FireworkGreen
|
||||||
| object::Body::FireworkPurple
|
| object::Species::FireworkPurple
|
||||||
| object::Body::FireworkRed
|
| object::Species::FireworkRed
|
||||||
| object::Body::FireworkWhite
|
| object::Species::FireworkWhite
|
||||||
| object::Body::FireworkYellow
|
| object::Species::FireworkYellow
|
||||||
| object::Body::MultiArrow => {
|
| object::Species::MultiArrow => {
|
||||||
let dim = self.dimensions().map(|a| a * 0.5);
|
let dim = self.dimensions().map(|a| a * 0.5);
|
||||||
0.02 * PI * dim.x * dim.z
|
0.02 * PI * dim.x * dim.z
|
||||||
},
|
},
|
||||||
|
|
||||||
// spherical-ish objects
|
// spherical-ish objects
|
||||||
object::Body::BoltFire
|
object::Species::BoltFire
|
||||||
| object::Body::BoltFireBig
|
| object::Species::BoltFireBig
|
||||||
| object::Body::BoltNature
|
| object::Species::BoltNature
|
||||||
| object::Body::Bomb
|
| object::Species::Bomb
|
||||||
| object::Body::PotionBlue
|
| object::Species::PotionBlue
|
||||||
| object::Body::PotionGreen
|
| object::Species::PotionGreen
|
||||||
| object::Body::PotionRed
|
| object::Species::PotionRed
|
||||||
| object::Body::Pouch
|
| object::Species::Pouch
|
||||||
| object::Body::Pumpkin
|
| object::Species::Pumpkin
|
||||||
| object::Body::Pumpkin2
|
| object::Species::Pumpkin2
|
||||||
| object::Body::Pumpkin3
|
| object::Species::Pumpkin3
|
||||||
| object::Body::Pumpkin4
|
| object::Species::Pumpkin4
|
||||||
| object::Body::Pumpkin5 => {
|
| object::Species::Pumpkin5 => {
|
||||||
let dim = self.dimensions().map(|a| a * 0.5);
|
let dim = self.dimensions().map(|a| a * 0.5);
|
||||||
0.5 * PI * dim.x * dim.z
|
0.5 * PI * dim.x * dim.z
|
||||||
},
|
},
|
||||||
|
@ -310,13 +310,13 @@ impl LoadoutBuilder {
|
|||||||
));
|
));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Body::Object(body) => match body {
|
Body::Object(body) => match body.species {
|
||||||
object::Body::Crossbow => {
|
object::Species::Crossbow => {
|
||||||
main_tool = Some(Item::new_from_asset_expect(
|
main_tool = Some(Item::new_from_asset_expect(
|
||||||
"common.items.npc_weapons.unique.turret",
|
"common.items.npc_weapons.unique.turret",
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
object::Body::HaniwaSentry => {
|
object::Species::HaniwaSentry => {
|
||||||
main_tool = Some(Item::new_from_asset_expect(
|
main_tool = Some(Item::new_from_asset_expect(
|
||||||
"common.items.npc_weapons.unique.haniwa_sentry",
|
"common.items.npc_weapons.unique.haniwa_sentry",
|
||||||
));
|
));
|
||||||
|
@ -420,7 +420,7 @@ fn handle_drop_all(
|
|||||||
|
|
||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.create_object(Default::default(), comp::object::Body::Pouch)
|
.create_object(Default::default(), comp::object::Species::Pouch)
|
||||||
.with(comp::Pos(Vec3::new(
|
.with(comp::Pos(Vec3::new(
|
||||||
pos.0.x + rng.gen_range(5.0..10.0),
|
pos.0.x + rng.gen_range(5.0..10.0),
|
||||||
pos.0.y + 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,
|
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 stats = comp::Stats::new("Training Dummy".to_string());
|
||||||
let skill_set = comp::SkillSet::default();
|
let skill_set = comp::SkillSet::default();
|
||||||
@ -1217,7 +1217,7 @@ fn handle_spawn_campfire(
|
|||||||
let pos = position(server, target, "target")?;
|
let pos = position(server, target, "target")?;
|
||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.create_object(pos, comp::object::Body::CampfireLit)
|
.create_object(pos, comp::object::Species::CampfireLit)
|
||||||
.with(LightEmitter {
|
.with(LightEmitter {
|
||||||
col: Rgb::new(1.0, 0.65, 0.2),
|
col: Rgb::new(1.0, 0.65, 0.2),
|
||||||
strength: 2.0,
|
strength: 2.0,
|
||||||
@ -1675,7 +1675,7 @@ fn handle_object(
|
|||||||
.create_object(pos, ori, obj_type)
|
.create_object(pos, ori, obj_type)
|
||||||
.with(ori);*/
|
.with(ori);*/
|
||||||
let obj_str_res = obj_type.as_ref().map(String::as_str);
|
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()
|
.iter()
|
||||||
.find(|o| Ok(o.to_string()) == obj_str_res)
|
.find(|o| Ok(o.to_string()) == obj_str_res)
|
||||||
{
|
{
|
||||||
@ -1944,7 +1944,7 @@ fn handle_spawn_wiring(
|
|||||||
|
|
||||||
let builder1 = server
|
let builder1 = server
|
||||||
.state
|
.state
|
||||||
.create_wiring(pos, comp::object::Body::Coins, WiringElement {
|
.create_wiring(pos, comp::object::Species::Coins, WiringElement {
|
||||||
actions: vec![WiringAction {
|
actions: vec![WiringAction {
|
||||||
formula: wiring::OutputFormula::Constant { value: 1.0 },
|
formula: wiring::OutputFormula::Constant { value: 1.0 },
|
||||||
threshold: 1.0,
|
threshold: 1.0,
|
||||||
@ -1969,7 +1969,7 @@ fn handle_spawn_wiring(
|
|||||||
pos.0.x += 3.0;
|
pos.0.x += 3.0;
|
||||||
let builder2 = server
|
let builder2 = server
|
||||||
.state
|
.state
|
||||||
.create_wiring(pos, comp::object::Body::Coins, WiringElement {
|
.create_wiring(pos, comp::object::Species::Coins, WiringElement {
|
||||||
actions: vec![
|
actions: vec![
|
||||||
WiringAction {
|
WiringAction {
|
||||||
formula: wiring::OutputFormula::Input {
|
formula: wiring::OutputFormula::Input {
|
||||||
@ -2008,7 +2008,7 @@ fn handle_spawn_wiring(
|
|||||||
pos.0.x += 3.0;
|
pos.0.x += 3.0;
|
||||||
let builder3 = server
|
let builder3 = server
|
||||||
.state
|
.state
|
||||||
.create_wiring(pos, comp::object::Body::TrainingDummy, WiringElement {
|
.create_wiring(pos, comp::object::Species::TrainingDummy, WiringElement {
|
||||||
actions: vec![],
|
actions: vec![],
|
||||||
inputs: HashMap::new(),
|
inputs: HashMap::new(),
|
||||||
outputs: HashMap::new(),
|
outputs: HashMap::new(),
|
||||||
|
@ -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<f32>) {
|
pub fn handle_create_waypoint(server: &mut Server, pos: Vec3<f32>) {
|
||||||
server
|
server
|
||||||
.state
|
.state
|
||||||
.create_object(Pos(pos), comp::object::Body::CampfireLit)
|
.create_object(Pos(pos), comp::object::Species::CampfireLit)
|
||||||
.with(LightEmitter {
|
.with(LightEmitter {
|
||||||
col: Rgb::new(1.0, 0.3, 0.1),
|
col: Rgb::new(1.0, 0.3, 0.1),
|
||||||
strength: 5.0,
|
strength: 5.0,
|
||||||
|
@ -452,12 +452,12 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
|
|||||||
if let Some(pos) = pos {
|
if let Some(pos) = pos {
|
||||||
let _ = state
|
let _ = state
|
||||||
.create_object(comp::Pos(pos.0 + Vec3::unit_z() * 0.25), match old_body {
|
.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::Humanoid(_)) => object::Species::Pouch,
|
||||||
Some(common::comp::Body::BipedSmall(_)) => object::Body::Pouch,
|
Some(common::comp::Body::BipedSmall(_)) => object::Species::Pouch,
|
||||||
Some(common::comp::Body::Golem(_)) => object::Body::Chest,
|
Some(common::comp::Body::Golem(_)) => object::Species::Chest,
|
||||||
Some(common::comp::Body::BipedLarge(_))
|
Some(common::comp::Body::BipedLarge(_))
|
||||||
| Some(common::comp::Body::QuadrupedLow(_)) => object::Body::MeatDrop,
|
| Some(common::comp::Body::QuadrupedLow(_)) => object::Species::MeatDrop,
|
||||||
_ => object::Body::Steak,
|
_ => object::Species::Steak,
|
||||||
})
|
})
|
||||||
.maybe_with(vel)
|
.maybe_with(vel)
|
||||||
.with(item)
|
.with(item)
|
||||||
|
@ -289,7 +289,7 @@ pub fn handle_mine_block(server: &mut Server, pos: Vec3<i32>, tool: Option<ToolK
|
|||||||
// Drop item if one is recoverable from the block
|
// Drop item if one is recoverable from the block
|
||||||
if let Some(item) = comp::Item::try_reclaim_from_block(block) {
|
if let Some(item) = comp::Item::try_reclaim_from_block(block) {
|
||||||
state
|
state
|
||||||
.create_object(Default::default(), comp::object::Body::Pouch)
|
.create_object(Default::default(), comp::object::Species::Pouch)
|
||||||
.with(comp::Pos(pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0)))
|
.with(comp::Pos(pos.map(|e| e as f32) + Vec3::new(0.5, 0.5, 0.0)))
|
||||||
.with(item)
|
.with(item)
|
||||||
.build();
|
.build();
|
||||||
|
@ -668,8 +668,8 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
{
|
{
|
||||||
// hack: special case coins for now
|
// hack: special case coins for now
|
||||||
let body = match item.item_definition_id() {
|
let body = match item.item_definition_id() {
|
||||||
"common.items.utility.coins" => comp::object::Body::Coins,
|
"common.items.utility.coins" => comp::object::Species::Coins,
|
||||||
_ => comp::object::Body::Pouch,
|
_ => comp::object::Species::Pouch,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If item is a container check inside of it for Debug items and remove them
|
// 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
|
let mut new_entity = state
|
||||||
.create_object(Default::default(), match kind {
|
.create_object(Default::default(), match kind {
|
||||||
item::Throwable::Bomb => comp::object::Body::Bomb,
|
item::Throwable::Bomb => comp::object::Species::Bomb,
|
||||||
item::Throwable::Firework(reagent) => comp::object::Body::for_firework(reagent),
|
item::Throwable::Firework(reagent) => comp::object::Species::for_firework(reagent),
|
||||||
item::Throwable::TrainingDummy => comp::object::Body::TrainingDummy,
|
item::Throwable::TrainingDummy => comp::object::Species::TrainingDummy,
|
||||||
})
|
})
|
||||||
.with(comp::Pos(pos.0 + Vec3::unit_z() * 0.25))
|
.with(comp::Pos(pos.0 + Vec3::unit_z() * 0.25))
|
||||||
.with(comp::Vel(vel));
|
.with(comp::Vel(vel));
|
||||||
|
@ -45,7 +45,7 @@ pub trait StateExt {
|
|||||||
body: comp::Body,
|
body: comp::Body,
|
||||||
) -> EcsEntityBuilder;
|
) -> EcsEntityBuilder;
|
||||||
/// Build a static object entity
|
/// 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(
|
fn create_ship(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: comp::Pos,
|
pos: comp::Pos,
|
||||||
@ -79,7 +79,7 @@ pub trait StateExt {
|
|||||||
fn create_wiring(
|
fn create_wiring(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: comp::Pos,
|
pos: comp::Pos,
|
||||||
object: comp::object::Body,
|
species: comp::object::Species,
|
||||||
wiring_element: wiring::WiringElement,
|
wiring_element: wiring::WiringElement,
|
||||||
) -> EcsEntityBuilder;
|
) -> EcsEntityBuilder;
|
||||||
// NOTE: currently only used for testing
|
// NOTE: currently only used for testing
|
||||||
@ -243,8 +243,8 @@ impl StateExt for State {
|
|||||||
.with(comp::Auras::default())
|
.with(comp::Auras::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
let body = comp::Body::Object(object);
|
let body = comp::Body::Object(comp::object::Body { species });
|
||||||
let (mass, density) = {
|
let (mass, density) = {
|
||||||
let body_attributes = &self.ecs().read_resource::<comp::body::BodyAttributes>();
|
let body_attributes = &self.ecs().read_resource::<comp::body::BodyAttributes>();
|
||||||
(
|
(
|
||||||
@ -257,7 +257,6 @@ impl StateExt for State {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(Density::default(), |bd| body.density(&bd)),
|
.map_or(Density::default(), |bd| body.density(&bd)),
|
||||||
)
|
)
|
||||||
//(Mass::default(), Density::default())
|
|
||||||
};
|
};
|
||||||
self.ecs_mut()
|
self.ecs_mut()
|
||||||
.create_entity_synced()
|
.create_entity_synced()
|
||||||
@ -271,7 +270,7 @@ impl StateExt for State {
|
|||||||
z_min: 0.0,
|
z_min: 0.0,
|
||||||
z_max: body.height(),
|
z_max: body.height(),
|
||||||
})
|
})
|
||||||
.with(body)
|
.with(comp::Body::Object(comp::object::Body { species }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_ship(
|
fn create_ship(
|
||||||
@ -424,7 +423,7 @@ impl StateExt for State {
|
|||||||
fn create_wiring(
|
fn create_wiring(
|
||||||
&mut self,
|
&mut self,
|
||||||
pos: comp::Pos,
|
pos: comp::Pos,
|
||||||
object: comp::object::Body,
|
species: comp::object::Species,
|
||||||
wiring_element: wiring::WiringElement,
|
wiring_element: wiring::WiringElement,
|
||||||
) -> EcsEntityBuilder {
|
) -> EcsEntityBuilder {
|
||||||
self.ecs_mut()
|
self.ecs_mut()
|
||||||
@ -433,11 +432,11 @@ impl StateExt for State {
|
|||||||
.with(comp::Vel(Vec3::zero()))
|
.with(comp::Vel(Vec3::zero()))
|
||||||
.with(comp::Ori::default())
|
.with(comp::Ori::default())
|
||||||
.with(comp::Collider::Box {
|
.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_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::Mass(10.0))
|
||||||
// .with(comp::Sticky)
|
// .with(comp::Sticky)
|
||||||
.with(wiring_element)
|
.with(wiring_element)
|
||||||
|
@ -109,7 +109,7 @@ fn dispatch_action_spawn_projectile(
|
|||||||
server_emitter.emit(ServerEvent::Shoot {
|
server_emitter.emit(ServerEvent::Shoot {
|
||||||
entity,
|
entity,
|
||||||
dir: Dir::forward(),
|
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),
|
projectile: constr.create_projectile(None, 1.0, 1.0),
|
||||||
light: None,
|
light: None,
|
||||||
speed: 5.0,
|
speed: 5.0,
|
||||||
|
@ -67,14 +67,14 @@ impl Default for SkeletonAttr {
|
|||||||
|
|
||||||
impl<'a> From<&'a Body> for SkeletonAttr {
|
impl<'a> From<&'a Body> for SkeletonAttr {
|
||||||
fn from(body: &'a Body) -> Self {
|
fn from(body: &'a Body) -> Self {
|
||||||
use comp::object::Body::*;
|
use comp::object::Species::*;
|
||||||
Self {
|
Self {
|
||||||
bone0: match body {
|
bone0: match body.species {
|
||||||
Crossbow => (0.0, 0.0, 11.0),
|
Crossbow => (0.0, 0.0, 11.0),
|
||||||
HaniwaSentry => (0.0, 0.0, 10.5),
|
HaniwaSentry => (0.0, 0.0, 10.5),
|
||||||
_ => (0.0, 0.0, 0.0),
|
_ => (0.0, 0.0, 0.0),
|
||||||
},
|
},
|
||||||
bone1: match body {
|
bone1: match body.species {
|
||||||
Crossbow => (0.0, 0.0, 8.0),
|
Crossbow => (0.0, 0.0, 8.0),
|
||||||
HaniwaSentry => (0.0, 0.0, 3.0),
|
HaniwaSentry => (0.0, 0.0, 3.0),
|
||||||
_ => (0.0, 0.0, 0.0),
|
_ => (0.0, 0.0, 0.0),
|
||||||
|
@ -3,7 +3,7 @@ use super::{
|
|||||||
ObjectSkeleton, SkeletonAttr,
|
ObjectSkeleton, SkeletonAttr,
|
||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
comp::{item::ToolKind, object::Body},
|
comp::{item::ToolKind, object::{Species, Body}},
|
||||||
states::utils::StageSection,
|
states::utils::StageSection,
|
||||||
};
|
};
|
||||||
pub struct ShootAnimation;
|
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;
|
next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0;
|
||||||
|
|
||||||
#[allow(clippy::single_match)]
|
#[allow(clippy::single_match)]
|
||||||
match body {
|
match body.species {
|
||||||
Body::Crossbow => {
|
Species::Crossbow => {
|
||||||
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
|
next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0;
|
||||||
next.bone0.orientation =
|
next.bone0.orientation =
|
||||||
Quaternion::rotation_x(movement1 * 0.05 + movement2 * 0.1) * (1.0 - movement3);
|
Quaternion::rotation_x(movement1 * 0.05 + movement2 * 0.1) * (1.0 - movement3);
|
||||||
|
@ -59,7 +59,7 @@ impl EventMapper for CampfireEventMapper {
|
|||||||
.join()
|
.join()
|
||||||
.filter(|(_, _, e_pos)| (e_pos.0.distance_squared(cam_pos)) < SFX_DIST_LIMIT_SQR)
|
.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 internal_state = self.event_history.entry(entity).or_default();
|
||||||
|
|
||||||
let mapped_event = SfxEvent::Campfire;
|
let mapped_event = SfxEvent::Campfire;
|
||||||
|
@ -332,20 +332,16 @@ impl SfxMgr {
|
|||||||
},
|
},
|
||||||
Outcome::ProjectileShot { pos, body, .. } => {
|
Outcome::ProjectileShot { pos, body, .. } => {
|
||||||
match body {
|
match body {
|
||||||
Body::Object(
|
Body::Object(object::Body { species: object::Species::Arrow })
|
||||||
object::Body::Arrow
|
| Body::Object(object::Body { species: object::Species::MultiArrow })
|
||||||
| object::Body::MultiArrow
|
| Body::Object(object::Body { species: object::Species::ArrowSnake })
|
||||||
| object::Body::ArrowSnake
|
| Body::Object(object::Body { species: object::Species::ArrowTurret }) => {
|
||||||
| object::Body::ArrowTurret,
|
|
||||||
) => {
|
|
||||||
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowShot);
|
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowShot);
|
||||||
audio.emit_sfx(sfx_trigger_item, *pos, None, false);
|
audio.emit_sfx(sfx_trigger_item, *pos, None, false);
|
||||||
},
|
},
|
||||||
Body::Object(
|
Body::Object(object::Body { species: object::Species::BoltFire })
|
||||||
object::Body::BoltFire
|
| Body::Object(object::Body { species: object::Species::BoltFireBig })
|
||||||
| object::Body::BoltFireBig
|
| Body::Object(object::Body { species: object::Species::BoltNature }) => {
|
||||||
| object::Body::BoltNature,
|
|
||||||
) => {
|
|
||||||
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::FireShot);
|
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::FireShot);
|
||||||
audio.emit_sfx(sfx_trigger_item, *pos, None, false);
|
audio.emit_sfx(sfx_trigger_item, *pos, None, false);
|
||||||
},
|
},
|
||||||
@ -361,12 +357,10 @@ impl SfxMgr {
|
|||||||
target,
|
target,
|
||||||
..
|
..
|
||||||
} => match body {
|
} => match body {
|
||||||
Body::Object(
|
Body::Object(object::Body { species: object::Species::Arrow })
|
||||||
object::Body::Arrow
|
| Body::Object(object::Body { species: object::Species::MultiArrow })
|
||||||
| object::Body::MultiArrow
|
| Body::Object(object::Body { species: object::Species::ArrowSnake })
|
||||||
| object::Body::ArrowSnake
|
| Body::Object(object::Body { species: object::Species::ArrowTurret }) => {
|
||||||
| object::Body::ArrowTurret,
|
|
||||||
) => {
|
|
||||||
if target.is_none() {
|
if target.is_none() {
|
||||||
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowMiss);
|
let sfx_trigger_item = triggers.get_key_value(&SfxEvent::ArrowMiss);
|
||||||
audio.emit_sfx(sfx_trigger_item, *pos, Some(2.0), false);
|
audio.emit_sfx(sfx_trigger_item, *pos, Some(2.0), false);
|
||||||
|
@ -90,8 +90,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
#[allow(clippy::collapsible_match)]
|
#[allow(clippy::collapsible_match)]
|
||||||
fn base_ori_interp(body: &Body) -> f32 {
|
fn base_ori_interp(body: &Body) -> f32 {
|
||||||
match body {
|
match body {
|
||||||
Body::Object(object) => match object {
|
Body::Object(object) => match object.species {
|
||||||
object::Body::Crossbow | object::Body::HaniwaSentry => 100.0,
|
object::Species::Crossbow | object::Species::HaniwaSentry => 100.0,
|
||||||
_ => 10.0,
|
_ => 10.0,
|
||||||
},
|
},
|
||||||
_ => 10.0,
|
_ => 10.0,
|
||||||
|
@ -302,33 +302,32 @@ impl ParticleMgr {
|
|||||||
.join()
|
.join()
|
||||||
{
|
{
|
||||||
match body {
|
match body {
|
||||||
Body::Object(object::Body::CampfireLit) => {
|
Body::Object(body) => match body.species {
|
||||||
|
object::Species::CampfireLit => {
|
||||||
self.maintain_campfirelit_particles(scene_data, pos, vel)
|
self.maintain_campfirelit_particles(scene_data, pos, vel)
|
||||||
},
|
},
|
||||||
Body::Object(
|
object::Species::Arrow
|
||||||
object::Body::Arrow
|
| object::Species::MultiArrow
|
||||||
| object::Body::MultiArrow
|
| object::Species::ArrowSnake
|
||||||
| object::Body::ArrowSnake
|
| object::Species::ArrowTurret => self.maintain_arrow_particles(scene_data, pos, vel),
|
||||||
| object::Body::ArrowTurret,
|
object::Species::BoltFire => {
|
||||||
) => self.maintain_arrow_particles(scene_data, pos, vel),
|
|
||||||
Body::Object(object::Body::BoltFire) => {
|
|
||||||
self.maintain_boltfire_particles(scene_data, pos, vel)
|
self.maintain_boltfire_particles(scene_data, pos, vel)
|
||||||
},
|
},
|
||||||
Body::Object(object::Body::BoltFireBig) => {
|
object::Species::BoltFireBig => {
|
||||||
self.maintain_boltfirebig_particles(scene_data, pos, vel)
|
self.maintain_boltfirebig_particles(scene_data, pos, vel)
|
||||||
},
|
},
|
||||||
Body::Object(object::Body::BoltNature) => {
|
object::Species::BoltNature => {
|
||||||
self.maintain_boltnature_particles(scene_data, pos, vel)
|
self.maintain_boltnature_particles(scene_data, pos, vel)
|
||||||
},
|
},
|
||||||
Body::Object(
|
object::Species::Bomb
|
||||||
object::Body::Bomb
|
| object::Species::FireworkBlue
|
||||||
| object::Body::FireworkBlue
|
| object::Species::FireworkGreen
|
||||||
| object::Body::FireworkGreen
|
| object::Species::FireworkPurple
|
||||||
| object::Body::FireworkPurple
|
| object::Species::FireworkRed
|
||||||
| object::Body::FireworkRed
|
| object::Species::FireworkWhite
|
||||||
| object::Body::FireworkWhite
|
| object::Species::FireworkYellow => self.maintain_bomb_particles(scene_data, pos, vel),
|
||||||
| object::Body::FireworkYellow,
|
_ => {},
|
||||||
) => self.maintain_bomb_particles(scene_data, pos, vel),
|
}
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ impl Floor {
|
|||||||
)),
|
)),
|
||||||
3 => match dynamic_rng.gen_range(0..4) {
|
3 => match dynamic_rng.gen_range(0..4) {
|
||||||
0 => entity
|
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_name("Haniwa Sentry".to_string())
|
||||||
.with_loot_drop(comp::Item::new_from_asset_expect(
|
.with_loot_drop(comp::Item::new_from_asset_expect(
|
||||||
"common.items.crafting_ing.stones",
|
"common.items.crafting_ing.stones",
|
||||||
@ -750,7 +750,7 @@ impl Floor {
|
|||||||
"common.items.weapons.staff.cultist_staff",
|
"common.items.weapons.staff.cultist_staff",
|
||||||
)),
|
)),
|
||||||
1 => entity
|
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_name("Possessed Turret".to_string())
|
||||||
.with_loot_drop(comp::Item::new_from_asset_expect(
|
.with_loot_drop(comp::Item::new_from_asset_expect(
|
||||||
"common.items.crafting_ing.twigs",
|
"common.items.crafting_ing.twigs",
|
||||||
|
@ -899,7 +899,7 @@ impl Settlement {
|
|||||||
.with_body(match dynamic_rng.gen_range(0..5) {
|
.with_body(match dynamic_rng.gen_range(0..5) {
|
||||||
_ if is_dummy => {
|
_ if is_dummy => {
|
||||||
is_human = false;
|
is_human = false;
|
||||||
object::Body::TrainingDummy.into()
|
comp::Body::Object(object::Body { species: object::Species::TrainingDummy })
|
||||||
},
|
},
|
||||||
0 => {
|
0 => {
|
||||||
let species = match dynamic_rng.gen_range(0..5) {
|
let species = match dynamic_rng.gen_range(0..5) {
|
||||||
|
Loading…
Reference in New Issue
Block a user