Material Item equip sound
This commit is contained in:
parent
d53379f6c2
commit
1af5e5cc89
@ -56,6 +56,7 @@ ItemPtr MaterialItem::clone() const {
|
|||||||
void MaterialItem::init(ToolUserEntity* owner, ToolHand hand) {
|
void MaterialItem::init(ToolUserEntity* owner, ToolHand hand) {
|
||||||
FireableItem::init(owner, hand);
|
FireableItem::init(owner, hand);
|
||||||
BeamItem::init(owner, hand);
|
BeamItem::init(owner, hand);
|
||||||
|
owner->addSound(Random::randValueFrom(m_placeSounds), 0.8f, 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialItem::uninit() {
|
void MaterialItem::uninit() {
|
||||||
@ -112,8 +113,7 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
|||||||
steps = (int)ceil(magnitude * (Constants::pi / 2));
|
steps = (int)ceil(magnitude * (Constants::pi / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned total = 0;
|
size_t total = 0;
|
||||||
bool fail = true;
|
|
||||||
for (int i = 0; i != steps; ++i) {
|
for (int i = 0; i != steps; ++i) {
|
||||||
auto placementOrigin = aimPosition + diff * (1.0f - ((float)i / steps));
|
auto placementOrigin = aimPosition + diff * (1.0f - ((float)i / steps));
|
||||||
for (Vec2I pos : tileAreaBrush(radius, placementOrigin, true))
|
for (Vec2I pos : tileAreaBrush(radius, placementOrigin, true))
|
||||||
@ -124,19 +124,15 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
|||||||
modifications.resize(count());
|
modifications.resize(count());
|
||||||
size_t failed = world()->applyTileModifications(modifications, false).size();
|
size_t failed = world()->applyTileModifications(modifications, false).size();
|
||||||
if (failed < modifications.size()) {
|
if (failed < modifications.size()) {
|
||||||
fail = false;
|
size_t placed = modifications.size() - failed;
|
||||||
unsigned placed = modifications.size() - failed;
|
|
||||||
consume(placed);
|
consume(placed);
|
||||||
total += placed;
|
total += placed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fail) {
|
if (total) {
|
||||||
auto sound = Random::randValueFrom(m_placeSounds, "");
|
float intensity = clamp((float)total / 96, 0.0f, 1.0f);
|
||||||
if (total && !sound.empty()) {
|
owner()->addSound(Random::randValueFrom(m_placeSounds), 1.0f + intensity, (1.125f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
||||||
float intensity = clamp((float)total / 96, 0.0f, 1.0f);
|
|
||||||
owner()->addSound(sound, 1.0f + intensity, (1.125f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
|
||||||
}
|
|
||||||
FireableItem::fire(mode, shifting, edgeTriggered);
|
FireableItem::fire(mode, shifting, edgeTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user