mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add documentation for localize_npc methods
This commit is contained in:
parent
3ebf17370c
commit
7bb2d11c98
@ -1346,12 +1346,20 @@ impl Body {
|
||||
Vec3::new(0.0, self.dimensions().y * 0.6, self.dimensions().z * 0.7)
|
||||
}
|
||||
|
||||
pub fn localize(&self) -> Content {
|
||||
match self {
|
||||
Self::BipedLarge(biped_large) => biped_large.localize(),
|
||||
_ => Content::localized("body-generic"),
|
||||
/// Should be only used with npc-tell_monster.
|
||||
///
|
||||
/// If you want to use for displaying names in HUD, add new strings.
|
||||
/// If you want to use for anything else, add new strings.
|
||||
pub fn localize_npc(&self) -> Content {
|
||||
fn try_localize(body: &Body) -> Option<Content> {
|
||||
match body {
|
||||
Body::BipedLarge(biped_large) => biped_large.localize_npc(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
try_localize(self).unwrap_or_else(|| Content::localized("body-generic"))
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Body {
|
||||
|
@ -25,9 +25,16 @@ impl Body {
|
||||
Self { species, body_type }
|
||||
}
|
||||
|
||||
pub fn localize(&self) -> Content {
|
||||
Content::localized(match &self.species {
|
||||
Species::Ogre => "body-biped_large-ogre",
|
||||
/// Should be only used with npc-tell_monster.
|
||||
///
|
||||
/// If you want to use for displaying names in HUD, add new strings.
|
||||
/// If you want to use for anything else, add new strings.
|
||||
pub fn localize_npc(&self) -> Option<Content> {
|
||||
let key = match &self.species {
|
||||
Species::Ogre => match self.body_type {
|
||||
BodyType::Male => "body-biped_large-ogre-male",
|
||||
BodyType::Female => "body-biped_large-ogre-female",
|
||||
},
|
||||
Species::Cyclops => "body-biped_large-cyclops",
|
||||
Species::Wendigo => "body-biped_large-wendigo",
|
||||
Species::Werewolf => "body-biped_large-werewolf",
|
||||
@ -37,8 +44,10 @@ impl Body {
|
||||
Species::Blueoni => "body-biped_large-blue_oni",
|
||||
Species::Redoni => "body-biped_large-red_oni",
|
||||
Species::Tursus => "body-biped_large-tursus",
|
||||
_ => "body-generic",
|
||||
})
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(Content::localized(key))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@ impl Direction {
|
||||
}
|
||||
}
|
||||
|
||||
/// Should be only used with care with npc-tell_monster and npc-tell_site
|
||||
///
|
||||
/// If you add new usages for it, please consult i18n team.
|
||||
pub fn localize_npc(&self) -> Content {
|
||||
Content::localized(match self {
|
||||
Direction::North => "npc-speech-dir_north",
|
||||
@ -103,6 +106,9 @@ impl Distance {
|
||||
}
|
||||
}
|
||||
|
||||
/// Should be only used with care with npc-tell_monster and npc-tell_site
|
||||
///
|
||||
/// If you add new usages for it, please consult i18n team.
|
||||
pub fn localize_npc(&self) -> Content {
|
||||
Content::localized(match self {
|
||||
Self::VeryFar => "npc-speech-dist_very_far",
|
||||
|
@ -610,7 +610,7 @@ fn talk_to<S: State>(tgt: Actor, _subject: Option<Subject>) -> impl Action<S> +
|
||||
.min_by_key(|other| other.wpos.xy().distance(ctx.npc.wpos.xy()) as i32)
|
||||
{
|
||||
Content::localized_with_args("npc-speech-tell_monster", [
|
||||
("body", monster.body.localize()),
|
||||
("body", monster.body.localize_npc()),
|
||||
("dir", Direction::from_dir(monster.wpos.xy() - ctx.npc.wpos.xy()).localize_npc()),
|
||||
("dist", Distance::from_length(monster.wpos.xy().distance(ctx.npc.wpos.xy()) as i32).localize_npc()),
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user