mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Give ships species
This commit is contained in:
parent
4cf5134f23
commit
8e5f74c00c
@ -284,6 +284,7 @@ impl Client {
|
|||||||
client_timeout,
|
client_timeout,
|
||||||
world_map,
|
world_map,
|
||||||
recipe_book,
|
recipe_book,
|
||||||
|
body_attributes,
|
||||||
material_stats,
|
material_stats,
|
||||||
ability_map,
|
ability_map,
|
||||||
} => {
|
} => {
|
||||||
@ -297,6 +298,7 @@ impl Client {
|
|||||||
let entity = state.ecs_mut().apply_entity_package(entity_package);
|
let entity = state.ecs_mut().apply_entity_package(entity_package);
|
||||||
*state.ecs_mut().write_resource() = time_of_day;
|
*state.ecs_mut().write_resource() = time_of_day;
|
||||||
*state.ecs_mut().write_resource() = PlayerEntity(Some(entity));
|
*state.ecs_mut().write_resource() = PlayerEntity(Some(entity));
|
||||||
|
state.ecs_mut().insert(body_attributes);
|
||||||
state.ecs_mut().insert(material_stats);
|
state.ecs_mut().insert(material_stats);
|
||||||
state.ecs_mut().insert(ability_map);
|
state.ecs_mut().insert(ability_map);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use super::{
|
|||||||
use crate::sync;
|
use crate::sync;
|
||||||
use common::{
|
use common::{
|
||||||
character::{self, CharacterItem},
|
character::{self, CharacterItem},
|
||||||
comp::{self, invite::InviteKind, item::MaterialStatManifest},
|
comp::{self, body::BodyAttributes, invite::InviteKind, item::MaterialStatManifest},
|
||||||
outcome::Outcome,
|
outcome::Outcome,
|
||||||
recipe::RecipeBook,
|
recipe::RecipeBook,
|
||||||
resources::TimeOfDay,
|
resources::TimeOfDay,
|
||||||
@ -60,6 +60,7 @@ pub enum ServerInit {
|
|||||||
world_map: crate::msg::world_msg::WorldMapMsg,
|
world_map: crate::msg::world_msg::WorldMapMsg,
|
||||||
recipe_book: RecipeBook,
|
recipe_book: RecipeBook,
|
||||||
material_stats: MaterialStatManifest,
|
material_stats: MaterialStatManifest,
|
||||||
|
body_attributes: BodyAttributes,
|
||||||
ability_map: comp::item::tool::AbilityMap,
|
ability_map: comp::item::tool::AbilityMap,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,20 @@ make_case_elim!(
|
|||||||
#[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 Body {
|
||||||
Humanoid(body: humanoid::Body) = 0,
|
|
||||||
QuadrupedSmall(body: quadruped_small::Body) = 1,
|
|
||||||
QuadrupedMedium(body: quadruped_medium::Body) = 2,
|
|
||||||
BirdMedium(body: bird_medium::Body) = 3,
|
|
||||||
FishMedium(body: fish_medium::Body) = 4,
|
|
||||||
Dragon(body: dragon::Body) = 5,
|
|
||||||
BirdLarge(body: bird_large::Body) = 6,
|
|
||||||
FishSmall(body: fish_small::Body) = 7,
|
|
||||||
BipedLarge(body: biped_large::Body)= 8,
|
BipedLarge(body: biped_large::Body)= 8,
|
||||||
BipedSmall(body: biped_small::Body)= 9,
|
BipedSmall(body: biped_small::Body)= 9,
|
||||||
Object(body: object::Body) = 10,
|
BirdLarge(body: bird_large::Body) = 6,
|
||||||
|
BirdMedium(body: bird_medium::Body) = 3,
|
||||||
|
Dragon(body: dragon::Body) = 5,
|
||||||
|
FishMedium(body: fish_medium::Body) = 4,
|
||||||
|
FishSmall(body: fish_small::Body) = 7,
|
||||||
Golem(body: golem::Body) = 11,
|
Golem(body: golem::Body) = 11,
|
||||||
Theropod(body: theropod::Body) = 12,
|
Humanoid(body: humanoid::Body) = 0,
|
||||||
QuadrupedLow(body: quadruped_low::Body) = 13,
|
QuadrupedLow(body: quadruped_low::Body) = 13,
|
||||||
|
QuadrupedMedium(body: quadruped_medium::Body) = 2,
|
||||||
|
QuadrupedSmall(body: quadruped_small::Body) = 1,
|
||||||
|
Theropod(body: theropod::Body) = 12,
|
||||||
|
Object(body: object::Body) = 10,
|
||||||
Ship(body: ship::Body) = 14,
|
Ship(body: ship::Body) = 14,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -52,7 +52,7 @@ make_case_elim!(
|
|||||||
/// Data representing data generic to the body together with per-species data.
|
/// Data representing data generic to the body together with per-species data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct BodyData<BodyMeta, SpeciesData> {
|
pub struct BodyData<BodyMeta, SpeciesData> {
|
||||||
/// Shared metadata for this whole body type.
|
/// Shared metadata for this whole body type.
|
||||||
pub body: BodyMeta,
|
pub body: BodyMeta,
|
||||||
@ -64,9 +64,23 @@ pub struct BodyData<BodyMeta, SpeciesData> {
|
|||||||
/// stored for each species for each body.
|
/// stored for each species for each body.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// ##############################################################################################
|
||||||
|
/// ##############################################################################################
|
||||||
|
///
|
||||||
|
/// ##############################################################################################
|
||||||
|
/// ##############################################################################################
|
||||||
|
/// TALK TO SHARP ABOUT IMPLEMENTING SERIALIZE!!!!!!
|
||||||
|
/// ##############################################################################################
|
||||||
|
/// ##############################################################################################
|
||||||
|
///
|
||||||
|
/// ##############################################################################################
|
||||||
|
/// ##############################################################################################
|
||||||
|
///
|
||||||
/// NOTE: If you are adding new body kind and it should be spawned via /spawn
|
/// NOTE: If you are adding new body kind and it should be spawned via /spawn
|
||||||
/// please add it to `[ENTITIES](crate::cmd::ENTITIES)`
|
/// please add it to `[ENTITIES](crate::cmd::ENTITIES)`
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllBodies<BodyMeta, SpeciesMeta> {
|
pub struct AllBodies<BodyMeta, SpeciesMeta> {
|
||||||
pub humanoid: BodyData<BodyMeta, humanoid::AllSpecies<SpeciesMeta>>,
|
pub humanoid: BodyData<BodyMeta, humanoid::AllSpecies<SpeciesMeta>>,
|
||||||
pub quadruped_small: BodyData<BodyMeta, quadruped_small::AllSpecies<SpeciesMeta>>,
|
pub quadruped_small: BodyData<BodyMeta, quadruped_small::AllSpecies<SpeciesMeta>>,
|
||||||
@ -175,7 +189,7 @@ pub type SpeciesBaseHealthIncrease = Option<u32>;
|
|||||||
/// Type holding mass data for bodies and species.
|
/// Type holding mass data for bodies and species.
|
||||||
pub type AllBodiesBaseHealthIncrease = AllBodies<BodyBaseHealthIncrease, SpeciesBaseHealthIncrease>;
|
pub type AllBodiesBaseHealthIncrease = AllBodies<BodyBaseHealthIncrease, SpeciesBaseHealthIncrease>;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
pub struct BodyAttributes {
|
pub struct BodyAttributes {
|
||||||
pub aggro: Option<AllBodiesAggro>,
|
pub aggro: Option<AllBodiesAggro>,
|
||||||
pub density: Option<AllBodiesDensity>,
|
pub density: Option<AllBodiesDensity>,
|
||||||
@ -251,83 +265,134 @@ pub fn get_body_u32_attribute<
|
|||||||
body_data.species[&species].unwrap_or_else(|| body_data.body)
|
body_data.species[&species].unwrap_or_else(|| body_data.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_body_attribute<
|
||||||
|
'a,
|
||||||
|
T: Copy,
|
||||||
|
Species,
|
||||||
|
SpeciesData: for<'b> core::ops::Index<&'b Species, Output = Option<T>>,
|
||||||
|
>(
|
||||||
|
body_data: &'a BodyData<T, SpeciesData>,
|
||||||
|
species: Species,
|
||||||
|
) -> T {
|
||||||
|
body_data.species[&species].unwrap_or_else(|| body_data.body)
|
||||||
|
}
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
pub fn is_humanoid(&self) -> bool { matches!(self, Body::Humanoid(_)) }
|
pub fn is_humanoid(&self) -> bool { matches!(self, Body::Humanoid(_)) }
|
||||||
|
|
||||||
|
pub fn get_attribute_value<T: Default + Copy>(&self, body_attribute: &AllBodies<T, Option<T>>) -> T {
|
||||||
|
match self {
|
||||||
|
Body::BipedLarge(body) => {
|
||||||
|
get_body_attribute(&body_attribute.biped_large, body.species)
|
||||||
|
},
|
||||||
|
Body::BipedSmall(body) => {
|
||||||
|
get_body_attribute(&body_attribute.biped_small, body.species)
|
||||||
|
},
|
||||||
|
Body::BirdMedium(body) => {
|
||||||
|
get_body_attribute(&body_attribute.bird_medium, body.species)
|
||||||
|
},
|
||||||
|
Body::BirdLarge(body) => {
|
||||||
|
get_body_attribute(&body_attribute.bird_large, body.species)
|
||||||
|
},
|
||||||
|
Body::Dragon(body) => get_body_attribute(&body_attribute.dragon, body.species),
|
||||||
|
Body::FishMedium(body) => {
|
||||||
|
get_body_attribute(&body_attribute.fish_medium, body.species)
|
||||||
|
},
|
||||||
|
Body::FishSmall(body) => {
|
||||||
|
get_body_attribute(&body_attribute.fish_small, body.species)
|
||||||
|
},
|
||||||
|
Body::Golem(body) => get_body_attribute(&body_attribute.golem, body.species),
|
||||||
|
Body::Humanoid(body) => get_body_attribute(&body_attribute.humanoid, body.species),
|
||||||
|
Body::QuadrupedLow(body) => {
|
||||||
|
get_body_attribute(&body_attribute.quadruped_low, body.species)
|
||||||
|
},
|
||||||
|
Body::QuadrupedMedium(body) => {
|
||||||
|
get_body_attribute(&body_attribute.quadruped_medium, body.species)
|
||||||
|
},
|
||||||
|
Body::QuadrupedSmall(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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Average density of the body
|
/// Average density of the body
|
||||||
/// Units are based on kg/m³
|
/// Units are based on kg/m³
|
||||||
pub fn density(&self, body_densities: &AllBodiesDensity) -> Density {
|
pub fn density(&self, body_densities: &AllBodiesDensity) -> Density {
|
||||||
let density_value = match self {
|
let density_value = 1000.0;//match self {
|
||||||
Body::BipedLarge(body) => {
|
// Body::BipedLarge(body) => {
|
||||||
get_body_f32_attribute(&body_densities.biped_large, body.species)
|
// get_body_f32_attribute(&body_densities.biped_large, body.species)
|
||||||
},
|
// },
|
||||||
Body::BipedSmall(body) => {
|
// Body::BipedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_densities.biped_small, body.species)
|
// get_body_f32_attribute(&body_densities.biped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdMedium(body) => {
|
// Body::BirdMedium(body) => {
|
||||||
get_body_f32_attribute(&body_densities.bird_medium, body.species)
|
// get_body_f32_attribute(&body_densities.bird_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdLarge(body) => {
|
// Body::BirdLarge(body) => {
|
||||||
get_body_f32_attribute(&body_densities.bird_large, body.species)
|
// get_body_f32_attribute(&body_densities.bird_large, body.species)
|
||||||
},
|
// },
|
||||||
Body::Dragon(body) => get_body_f32_attribute(&body_densities.dragon, body.species),
|
// Body::Dragon(body) => get_body_f32_attribute(&body_densities.dragon, body.species),
|
||||||
Body::FishMedium(body) => {
|
// Body::FishMedium(body) => {
|
||||||
get_body_f32_attribute(&body_densities.fish_medium, body.species)
|
// get_body_f32_attribute(&body_densities.fish_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::FishSmall(body) => {
|
// Body::FishSmall(body) => {
|
||||||
get_body_f32_attribute(&body_densities.fish_small, body.species)
|
// get_body_f32_attribute(&body_densities.fish_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::Golem(body) => get_body_f32_attribute(&body_densities.golem, body.species),
|
// Body::Golem(body) => get_body_f32_attribute(&body_densities.golem, body.species),
|
||||||
Body::Humanoid(body) => get_body_f32_attribute(&body_densities.humanoid, body.species),
|
// Body::Humanoid(body) => get_body_f32_attribute(&body_densities.humanoid, body.species),
|
||||||
Body::QuadrupedLow(body) => {
|
// Body::QuadrupedLow(body) => {
|
||||||
get_body_f32_attribute(&body_densities.quadruped_low, body.species)
|
// get_body_f32_attribute(&body_densities.quadruped_low, body.species)
|
||||||
},
|
// },
|
||||||
Body::QuadrupedMedium(body) => {
|
// Body::QuadrupedMedium(body) => {
|
||||||
get_body_f32_attribute(&body_densities.quadruped_medium, body.species)
|
// get_body_f32_attribute(&body_densities.quadruped_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::QuadrupedSmall(body) => {
|
// Body::QuadrupedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_densities.quadruped_small, body.species)
|
// get_body_f32_attribute(&body_densities.quadruped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::Theropod(body) => get_body_f32_attribute(&body_densities.theropod, body.species),
|
// Body::Theropod(body) => get_body_f32_attribute(&body_densities.theropod, body.species),
|
||||||
Body::Ship(ship) => ship.density().0,
|
// Body::Ship(body) => get_body_f32_attribute(&body_densities.ship, body.species),
|
||||||
Body::Object(object) => object.density().0,
|
// Body::Object(object) => object.density().0,
|
||||||
};
|
//};
|
||||||
Density(density_value)
|
Density(density_value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Units are kg
|
/// Units are kg
|
||||||
pub fn mass(&self, body_masses: &AllBodiesMass) -> Mass {
|
pub fn mass(&self, body_masses: &AllBodiesMass) -> Mass {
|
||||||
let m = match self {
|
let m = 100.0;//match self {
|
||||||
Body::BipedLarge(body) => {
|
// Body::BipedLarge(body) => {
|
||||||
get_body_f32_attribute(&body_masses.biped_large, body.species)
|
// get_body_f32_attribute(&body_masses.biped_large, body.species)
|
||||||
},
|
// },
|
||||||
Body::BipedSmall(body) => {
|
// Body::BipedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_masses.biped_small, body.species)
|
// get_body_f32_attribute(&body_masses.biped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdMedium(body) => {
|
// Body::BirdMedium(body) => {
|
||||||
get_body_f32_attribute(&body_masses.bird_medium, body.species)
|
// get_body_f32_attribute(&body_masses.bird_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::BirdLarge(body) => get_body_f32_attribute(&body_masses.bird_large, body.species),
|
// Body::BirdLarge(body) => get_body_f32_attribute(&body_masses.bird_large, body.species),
|
||||||
Body::Dragon(body) => get_body_f32_attribute(&body_masses.dragon, body.species),
|
// Body::Dragon(body) => get_body_f32_attribute(&body_masses.dragon, body.species),
|
||||||
Body::FishMedium(body) => {
|
// Body::FishMedium(body) => {
|
||||||
get_body_f32_attribute(&body_masses.fish_medium, body.species)
|
// get_body_f32_attribute(&body_masses.fish_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::FishSmall(body) => get_body_f32_attribute(&body_masses.fish_small, body.species),
|
// Body::FishSmall(body) => get_body_f32_attribute(&body_masses.fish_small, body.species),
|
||||||
Body::Golem(body) => get_body_f32_attribute(&body_masses.golem, body.species),
|
// Body::Golem(body) => get_body_f32_attribute(&body_masses.golem, body.species),
|
||||||
Body::Humanoid(body) => get_body_f32_attribute(&body_masses.humanoid, body.species),
|
// Body::Humanoid(body) => get_body_f32_attribute(&body_masses.humanoid, body.species),
|
||||||
Body::QuadrupedLow(body) => {
|
// Body::QuadrupedLow(body) => {
|
||||||
get_body_f32_attribute(&body_masses.quadruped_low, body.species)
|
// get_body_f32_attribute(&body_masses.quadruped_low, body.species)
|
||||||
},
|
// },
|
||||||
Body::QuadrupedMedium(body) => {
|
// Body::QuadrupedMedium(body) => {
|
||||||
get_body_f32_attribute(&body_masses.quadruped_medium, body.species)
|
// get_body_f32_attribute(&body_masses.quadruped_medium, body.species)
|
||||||
},
|
// },
|
||||||
Body::QuadrupedSmall(body) => {
|
// Body::QuadrupedSmall(body) => {
|
||||||
get_body_f32_attribute(&body_masses.quadruped_small, body.species)
|
// get_body_f32_attribute(&body_masses.quadruped_small, body.species)
|
||||||
},
|
// },
|
||||||
Body::Theropod(body) => get_body_f32_attribute(&body_masses.theropod, body.species),
|
// Body::Theropod(body) => get_body_f32_attribute(&body_masses.theropod, body.species),
|
||||||
Body::Ship(ship) => ship.density().0,
|
// Body::Ship(body) => get_body_f32_attribute(&body_masses.ship, body.species),
|
||||||
Body::Object(object) => object.density().0,
|
// Body::Object(object) => object.density().0,
|
||||||
};
|
//};
|
||||||
Mass(m)
|
Mass(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +506,7 @@ impl Body {
|
|||||||
quadruped_low::Species::Tortoise => Vec3::new(1.0, 1.6, 2.0),
|
quadruped_low::Species::Tortoise => Vec3::new(1.0, 1.6, 2.0),
|
||||||
_ => Vec3::new(1.0, 1.6, 1.3),
|
_ => Vec3::new(1.0, 1.6, 1.3),
|
||||||
},
|
},
|
||||||
Body::Ship(ship) => ship.dimensions(),
|
Body::Ship(ship) => Vec3::new(1.0, 1.0, 1.0),//ship.dimensions(),
|
||||||
Body::Theropod(body) => match body.species {
|
Body::Theropod(body) => match body.species {
|
||||||
theropod::Species::Archaeos => Vec3::new(4.0, 7.0, 8.0),
|
theropod::Species::Archaeos => Vec3::new(4.0, 7.0, 8.0),
|
||||||
theropod::Species::Ntouka => Vec3::new(4.0, 6.0, 8.0),
|
theropod::Species::Ntouka => Vec3::new(4.0, 6.0, 8.0),
|
||||||
@ -590,7 +655,8 @@ impl Body {
|
|||||||
Body::BirdLarge(_) => 50.0,
|
Body::BirdLarge(_) => 50.0,
|
||||||
Body::BirdMedium(_) => 40.0,
|
Body::BirdMedium(_) => 40.0,
|
||||||
Body::Dragon(_) => 60.0,
|
Body::Dragon(_) => 60.0,
|
||||||
Body::Ship(ship::Body::DefaultAirship) => 60.0,
|
//Body::Ship(ship::Body::DefaultAirship) => 60.0,
|
||||||
|
Body::Ship(_) => 60.0,
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,7 +722,8 @@ impl Body {
|
|||||||
|
|
||||||
pub fn mounting_offset(&self) -> Vec3<f32> {
|
pub fn mounting_offset(&self) -> Vec3<f32> {
|
||||||
match self {
|
match self {
|
||||||
Body::Ship(ship::Body::DefaultAirship) => Vec3::from([0.0, 0.0, 10.0]),
|
//Body::Ship(ship::Body::DefaultAirship) => Vec3::from([0.0, 0.0, 10.0]),
|
||||||
|
Body::Ship(_) => Vec3::from([0.0, 0.0, 10.0]),
|
||||||
_ => Vec3::unit_z(),
|
_ => Vec3::unit_z(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub ogre: SpeciesMeta,
|
pub ogre: SpeciesMeta,
|
||||||
pub cyclops: SpeciesMeta,
|
pub cyclops: SpeciesMeta,
|
||||||
|
@ -51,7 +51,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub gnome: SpeciesMeta,
|
pub gnome: SpeciesMeta,
|
||||||
pub sahagin: SpeciesMeta,
|
pub sahagin: SpeciesMeta,
|
||||||
|
@ -42,7 +42,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub phoenix: SpeciesMeta,
|
pub phoenix: SpeciesMeta,
|
||||||
pub cockatrice: SpeciesMeta,
|
pub cockatrice: SpeciesMeta,
|
||||||
|
@ -47,7 +47,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub duck: SpeciesMeta,
|
pub duck: SpeciesMeta,
|
||||||
pub chicken: SpeciesMeta,
|
pub chicken: SpeciesMeta,
|
||||||
|
@ -41,7 +41,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub reddragon: SpeciesMeta,
|
pub reddragon: SpeciesMeta,
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub marlin: SpeciesMeta,
|
pub marlin: SpeciesMeta,
|
||||||
pub icepike: SpeciesMeta,
|
pub icepike: SpeciesMeta,
|
||||||
|
@ -42,7 +42,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub clownfish: SpeciesMeta,
|
pub clownfish: SpeciesMeta,
|
||||||
pub piranha: SpeciesMeta,
|
pub piranha: SpeciesMeta,
|
||||||
|
@ -43,7 +43,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub stonegolem: SpeciesMeta,
|
pub stonegolem: SpeciesMeta,
|
||||||
pub treant: SpeciesMeta,
|
pub treant: SpeciesMeta,
|
||||||
|
@ -54,7 +54,7 @@ make_case_elim!(
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub crocodile: SpeciesMeta,
|
pub crocodile: SpeciesMeta,
|
||||||
pub alligator: SpeciesMeta,
|
pub alligator: SpeciesMeta,
|
||||||
|
@ -67,7 +67,7 @@ pub enum Species {
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub grolgar: SpeciesMeta,
|
pub grolgar: SpeciesMeta,
|
||||||
pub saber: SpeciesMeta,
|
pub saber: SpeciesMeta,
|
||||||
|
@ -64,7 +64,7 @@ pub enum Species {
|
|||||||
/// Data representing per-species generic data.
|
/// Data representing per-species generic data.
|
||||||
///
|
///
|
||||||
/// NOTE: Deliberately don't (yet?) implement serialize.
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AllSpecies<SpeciesMeta> {
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
pub pig: SpeciesMeta,
|
pub pig: SpeciesMeta,
|
||||||
pub fox: SpeciesMeta,
|
pub fox: SpeciesMeta,
|
||||||
|
@ -2,16 +2,16 @@ use crate::{
|
|||||||
comp::{Density, Mass},
|
comp::{Density, Mass},
|
||||||
consts::AIR_DENSITY,
|
consts::AIR_DENSITY,
|
||||||
make_case_elim,
|
make_case_elim,
|
||||||
|
make_proj_elim,
|
||||||
};
|
};
|
||||||
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)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
#[repr(u32)]
|
pub struct Body {
|
||||||
pub enum Body {
|
pub species: Species,
|
||||||
DefaultAirship = 0,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -19,10 +19,52 @@ impl From<Body> for super::Body {
|
|||||||
fn from(body: Body) -> Self { super::Body::Ship(body) }
|
fn from(body: Body) -> Self { super::Body::Ship(body) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Body {
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum Species {
|
||||||
|
DefaultAirship = 0,
|
||||||
|
NonDefaultAirship = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Data representing per-species generic data.
|
||||||
|
///
|
||||||
|
/// NOTE: Deliberately don't (yet?) implement serialize.
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct AllSpecies<SpeciesMeta> {
|
||||||
|
pub default_airship: SpeciesMeta,
|
||||||
|
// TODO remove this
|
||||||
|
pub non_default_airship: SpeciesMeta,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta> {
|
||||||
|
type Output = SpeciesMeta;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn index(&self, &index: &'a Species) -> &Self::Output {
|
||||||
|
match index {
|
||||||
|
Species::DefaultAirship => &self.default_airship,
|
||||||
|
Species::NonDefaultAirship => &self.non_default_airship,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const ALL_SPECIES: [Species; 2] = [
|
||||||
|
Species::DefaultAirship,
|
||||||
|
Species::NonDefaultAirship,
|
||||||
|
];
|
||||||
|
|
||||||
|
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 Species {
|
||||||
pub fn manifest_entry(&self) -> &'static str {
|
pub fn manifest_entry(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Body::DefaultAirship => "Human_Airship",
|
Species::DefaultAirship => "Human_Airship",
|
||||||
|
Species::NonDefaultAirship => "Nonexistent_Airship",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ impl Body {
|
|||||||
Body::BirdMedium(_) => Some(GRAVITY * 0.5),
|
Body::BirdMedium(_) => Some(GRAVITY * 0.5),
|
||||||
Body::BirdLarge(_) => Some(GRAVITY * 2.0),
|
Body::BirdLarge(_) => Some(GRAVITY * 2.0),
|
||||||
Body::Dragon(_) => Some(200_000.0),
|
Body::Dragon(_) => Some(200_000.0),
|
||||||
Body::Ship(ship::Body::DefaultAirship) => Some(300_000.0),
|
Body::Ship(_) => Some(300_000.0),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,28 +395,27 @@ pub fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) -> b
|
|||||||
let anti_grav = GRAVITY * (1.0 + data.inputs.move_z.min(0.0));
|
let anti_grav = GRAVITY * (1.0 + data.inputs.move_z.min(0.0));
|
||||||
update.vel.0.z += data.dt.0 * (anti_grav + accel * data.inputs.move_z.max(0.0));
|
update.vel.0.z += data.dt.0 * (anti_grav + accel * data.inputs.move_z.max(0.0));
|
||||||
},
|
},
|
||||||
// floaty floaty
|
// TODO fix this
|
||||||
Body::Ship(ship @ ship::Body::DefaultAirship) => {
|
//Body::Ship(ship @ ship::Body::DefaultAirship) => {
|
||||||
let regulate_density = |min: f32, max: f32, def: f32, rate: f32| -> Density {
|
// let regulate_density = |min: f32, max: f32, def: f32, rate: f32| -> Density {
|
||||||
// Reset to default on no input
|
// // Reset to default on no input
|
||||||
let change = if data.inputs.move_z.abs() > std::f32::EPSILON {
|
// let change = if data.inputs.move_z.abs() > std::f32::EPSILON {
|
||||||
-data.inputs.move_z
|
// -data.inputs.move_z
|
||||||
} else {
|
// } else {
|
||||||
(def - data.density.0).max(-1.0).min(1.0)
|
// (def - data.density.0).max(-1.0).min(1.0)
|
||||||
};
|
// };
|
||||||
Density((update.density.0 + data.dt.0 * rate * change).clamp(min, max))
|
// Density((update.density.0 + data.dt.0 * rate * change).clamp(min, max))
|
||||||
};
|
// };
|
||||||
let def_density = ship.density().0;
|
// let def_density = 1000.0;//ship.density().0;
|
||||||
if data.physics.in_liquid().is_some() {
|
// if data.physics.in_liquid().is_some() {
|
||||||
let hull_density = ship.hull_density().0;
|
// let hull_density = 1000.0;//ship.hull_density().0;
|
||||||
update.density.0 =
|
// update.density.0 =
|
||||||
regulate_density(def_density * 0.6, hull_density, hull_density, 25.0).0;
|
// regulate_density(def_density * 0.6, hull_density, hull_density, 25.0).0;
|
||||||
} else {
|
// } else {
|
||||||
update.density.0 =
|
// update.density.0 =
|
||||||
regulate_density(def_density * 0.5, def_density * 1.5, def_density, 0.5).0;
|
// regulate_density(def_density * 0.5, def_density * 1.5, def_density, 0.5).0;
|
||||||
};
|
// };
|
||||||
},
|
//},
|
||||||
// oopsie woopsie
|
|
||||||
// TODO: refactor to make this state impossible
|
// TODO: refactor to make this state impossible
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
|
@ -1188,7 +1188,7 @@ fn handle_spawn_airship(
|
|||||||
});
|
});
|
||||||
let mut builder = server
|
let mut builder = server
|
||||||
.state
|
.state
|
||||||
.create_ship(pos, comp::ship::Body::DefaultAirship, true)
|
.create_ship(pos, comp::ship::Body { species: comp::ship::Species::DefaultAirship }, true)
|
||||||
.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,
|
||||||
|
@ -837,6 +837,7 @@ impl Server {
|
|||||||
client_timeout: self.settings().client_timeout,
|
client_timeout: self.settings().client_timeout,
|
||||||
world_map: self.map.clone(),
|
world_map: self.map.clone(),
|
||||||
recipe_book: default_recipe_book().cloned(),
|
recipe_book: default_recipe_book().cloned(),
|
||||||
|
body_attributes: (&*self.state.ecs().read_resource::<comp::body::BodyAttributes>()).clone(),
|
||||||
material_stats: MaterialStatManifest::default(),
|
material_stats: MaterialStatManifest::default(),
|
||||||
ability_map: (&*self
|
ability_map: (&*self
|
||||||
.state
|
.state
|
||||||
|
@ -37,7 +37,9 @@ impl Entity {
|
|||||||
pub fn get_body(&self) -> comp::Body {
|
pub fn get_body(&self) -> comp::Body {
|
||||||
match self.rng(PERM_GENUS).gen::<f32>() {
|
match self.rng(PERM_GENUS).gen::<f32>() {
|
||||||
// we want 5% airships, 45% birds, 50% humans
|
// we want 5% airships, 45% birds, 50% humans
|
||||||
x if x < 0.05 => comp::Body::Ship(comp::ship::Body::DefaultAirship),
|
x if x < 0.05 => comp::Body::Ship(comp::ship::Body {
|
||||||
|
species: comp::ship::Species::DefaultAirship,
|
||||||
|
}),
|
||||||
x if x < 0.45 => {
|
x if x < 0.45 => {
|
||||||
let species = *(&comp::bird_medium::ALL_SPECIES)
|
let species = *(&comp::bird_medium::ALL_SPECIES)
|
||||||
.choose(&mut self.rng(PERM_SPECIES))
|
.choose(&mut self.rng(PERM_SPECIES))
|
||||||
|
@ -213,8 +213,8 @@ impl StateExt for State {
|
|||||||
.with(mass)
|
.with(mass)
|
||||||
.with(density)
|
.with(density)
|
||||||
.with(match body {
|
.with(match body {
|
||||||
comp::Body::Ship(ship) => comp::Collider::Voxel {
|
comp::Body::Ship(comp::ship::Body { species }) => comp::Collider::Voxel {
|
||||||
id: ship.manifest_entry().to_string(),
|
id: species.manifest_entry().to_string(),
|
||||||
},
|
},
|
||||||
_ => comp::Collider::Box {
|
_ => comp::Collider::Box {
|
||||||
radius: body.radius(),
|
radius: body.radius(),
|
||||||
@ -307,8 +307,11 @@ impl StateExt for State {
|
|||||||
.with(comp::Ori::default())
|
.with(comp::Ori::default())
|
||||||
.with(mass)
|
.with(mass)
|
||||||
.with(density)
|
.with(density)
|
||||||
|
//.with(comp::Collider::Voxel {
|
||||||
|
// id: ship.manifest_entry().to_string(),
|
||||||
|
//})
|
||||||
.with(comp::Collider::Voxel {
|
.with(comp::Collider::Voxel {
|
||||||
id: ship.manifest_entry().to_string(),
|
id: ship.species.manifest_entry().to_string(),
|
||||||
})
|
})
|
||||||
.with(body)
|
.with(body)
|
||||||
.with(comp::Scale(comp::ship::AIRSHIP_SCALE))
|
.with(comp::Scale(comp::ship::AIRSHIP_SCALE))
|
||||||
|
Loading…
Reference in New Issue
Block a user