Add a coin item and make amounts visible on dropped items.

This commit is contained in:
Avi Weinstock 2021-02-25 21:31:30 -05:00
parent 00937a4e8b
commit 7d2e8f72eb
8 changed files with 47 additions and 4 deletions

View File

@ -0,0 +1,11 @@
ItemDef(
name: "Coins",
description: "Money can be exchanged for goods and services.",
kind: Utility(
kind: Coins,
),
amount: 1,
quality: Common,
tags: [],
)

View File

@ -887,6 +887,10 @@
),
// Other
Utility(Coins): VoxTrans(
"voxel.object.coins",
(0.0, 0.0, 0.0), (0.0, 0.0, 0.0), 0.6,
),
Utility(Collar): Png(
"element.icons.collar",
),

BIN
assets/voxygen/voxel/object/coins.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -539,6 +539,16 @@
central: ("armor.empty"),
)
),
Coins: (
bone0: (
offset: (0.0, 0.0, 0.0),
central: ("object.coins"),
),
bone1: (
offset: (0.0, 0.0, 0.0),
central: ("armor.empty"),
)
),
CraftingBench: (
bone0: (
offset: (-9.5, -7.0, 0.0),
@ -649,4 +659,4 @@
central: ("armor.empty"),
)
),
})
})

View File

@ -72,6 +72,7 @@ make_case_elim!(
Steak = 62,
Crossbow = 63,
ArrowTurret = 64,
Coins = 65,
}
);
@ -82,7 +83,7 @@ impl Body {
}
}
pub const ALL_OBJECTS: [Body; 65] = [
pub const ALL_OBJECTS: [Body; 66] = [
Body::Arrow,
Body::Bomb,
Body::Scarecrow,
@ -148,6 +149,7 @@ pub const ALL_OBJECTS: [Body; 65] = [
Body::Steak,
Body::Crossbow,
Body::ArrowTurret,
Body::Coins,
];
impl From<Body> for super::Body {
@ -222,6 +224,7 @@ impl Body {
Body::Steak => "steak",
Body::Crossbow => "crossbow",
Body::ArrowTurret => "arrow_turret",
Body::Coins => "coins",
}
}
}

View File

@ -47,6 +47,7 @@ pub enum Reagent {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Utility {
Coins,
Collar,
}

View File

@ -523,8 +523,13 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Slo
// Drop items
for (pos, ori, item) in dropped_items {
// hack: special case coins for now
let body = match item.item_definition_id() {
"common.items.utility.coins" => comp::object::Body::Coins,
_ => comp::object::Body::Pouch,
};
state
.create_object(Default::default(), comp::object::Body::Pouch)
.create_object(Default::default(), body)
.with(comp::Pos(pos.0 + *ori.look_dir() + Vec3::unit_z()))
.with(item)
.with(comp::Vel(Vec3::zero()))

View File

@ -1290,9 +1290,15 @@ impl Hud {
);
let ingame_pos = pos.0 + Vec3::unit_z() * 1.2;
let text = if item.amount() > 1 {
format!("{} x {}", item.amount(), item.name())
} else {
item.name().to_string()
};
// Item
overitem::Overitem::new(
&item.name(),
&text,
&distance,
&self.fonts,
&global_state.settings.controls,