Basic implementation of hat visuals.

This commit is contained in:
Avi Weinstock 2021-06-20 19:45:49 -04:00
parent f38cde9d40
commit 0a33c98268
6 changed files with 76 additions and 3 deletions

View File

@ -0,0 +1,17 @@
ItemDef(
name: "Exclamation hat",
description: "You feel like bestowing quests.",
kind: Armor((
kind: Head("Exclamation"),
stats: (
protection: Normal(0.0),
poise_resilience: Normal(0.0),
energy_max: 0,
energy_reward: 0.0,
crit_power: 0.0,
stealth: 0.0,
),
)),
quality: Common,
tags: [],
)

View File

@ -2194,6 +2194,10 @@
"voxel.armor.misc.head.assa_mask-0",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.0,
),
Armor(Head("Exclamation")): VoxTrans(
"voxel.armor.misc.head.exclamation",
(0.0, 15.0, 0.0), (-75.0, 135.0, 0.0), 3.0,
),
// Bags
Armor(Bag("RedFace")): Png (
"element.items.item_bag_red_face",

BIN
assets/voxygen/voxel/armor/misc/head/exclamation.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,12 @@
((
default: (
vox_spec: ("armor.empty", (0.0, 0.0, 0.0)),
color: None
),
map: {
"Exclamation": (
vox_spec: ("armor.misc.head.exclamation", (-10.0, -10.0, 20.0)),
color: None
),
}
))

View File

@ -113,6 +113,7 @@ pub(super) struct CharacterCacheKey {
pub glider: Option<String>,
pub hand: Option<String>,
pub foot: Option<String>,
pub head: Option<String>,
}
impl CharacterCacheKey {
@ -264,6 +265,17 @@ impl CharacterCacheKey {
} else {
None
},
head: if let Some(ItemKind::Armor(Armor {
kind: ArmorKind::Head(armor),
..
})) = inventory
.equipped(EquipSlot::Armor(ArmorSlot::Head))
.map(|i| i.kind())
{
Some(armor.clone())
} else {
None
},
}
}
}

View File

@ -234,7 +234,12 @@ struct HumHeadSubSpec {
struct HumHeadSpec(HashMap<(Species, BodyType), HumHeadSubSpec>);
impl HumHeadSpec {
fn mesh_head(&self, body: &Body, color_spec: &HumColorSpec) -> BoneMeshes {
fn mesh_head(
&self,
body: &Body,
color_spec: &HumColorSpec,
helmet: Option<(Segment, Vec3<i32>)>,
) -> BoneMeshes {
let spec = match self.0.get(&(body.species, body.body_type)) {
Some(spec) => spec,
None => {
@ -311,6 +316,7 @@ impl HumHeadSpec {
.maybe_add(hair)
.maybe_add(beard)
.maybe_add(accessory)
.maybe_add(helmet)
.unify();
(
@ -373,9 +379,9 @@ make_vox_spec!(
modular_components: HumModularComponentSpec = "voxygen.voxel.humanoid_modular_component_manifest",
armor_lantern: HumArmorLanternSpec = "voxygen.voxel.humanoid_lantern_manifest",
armor_glider: HumArmorGliderSpec = "voxygen.voxel.humanoid_glider_manifest",
armor_head: HumArmorHeadSpec = "voxygen.voxel.humanoid_armor_head_manifest",
// TODO: Add these.
/* armor_head: HumArmorHeadSpec = "voxygen.voxel.humanoid_armor_head_manifest",
tabard: HumArmorTabardSpec = "voxygen.voxel.humanoid_armor_tabard_manifest", */
/* tabard: HumArmorTabardSpec = "voxygen.voxel.humanoid_armor_tabard_manifest", */
},
|FigureKey { body, extra }, spec| {
const DEFAULT_LOADOUT: super::cache::CharacterCacheKey = super::cache::CharacterCacheKey {
@ -385,6 +391,7 @@ make_vox_spec!(
glider: None,
hand: None,
foot: None,
head: None,
};
// TODO: This is bad code, maybe this method should return Option<_>
@ -403,6 +410,9 @@ make_vox_spec!(
spec.head.read().0.mesh_head(
body,
color,
spec.armor_head.read().0.load_head(
loadout.head.as_deref()
),
)
}),
third_person.map(|loadout| {
@ -957,6 +967,19 @@ impl HumArmorLanternSpec {
}
}
impl HumArmorHeadSpec {
fn load_head(&self, head: Option<&str>) -> Option<(Segment, Vec3<i32>)> {
match self.0.map.get(head?) {
Some(spec) => Some((
graceful_load_segment(&spec.vox_spec.0),
Vec3::<f32>::from(spec.vox_spec.1).as_(),
)),
None => {
warn!("No specification for this head: {:?}", head);
None
},
}
}
/// FIXME: Either use this, or remove it.
#[allow(dead_code)]
fn mesh_head(&self, body: &Body, color_spec: &HumColorSpec, head: Option<&str>) -> BoneMeshes {
@ -2516,6 +2539,7 @@ make_vox_spec!(
glider: None,
hand: None,
foot: None,
head: None,
};
// TODO: This is bad code, maybe this method should return Option<_>
@ -3544,6 +3568,7 @@ make_vox_spec!(
glider: None,
hand: None,
foot: None,
head: None,
};
// TODO: This is bad code, maybe this method should return Option<_>