-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECS wrapper for the sound system #590
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of good work here, thanks. And sorry for the extended delay :(
You may have to explain some things to me if I don't understand it properly :)
|
||
/** | ||
* Gets the damage sound associated with the given {@link MaterialType} and {@link DmgType}. If no sound is defined, | ||
* null is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return an Optional instead then for these two methods?
UPDATE: In light of later review comments, you may not even want this method at all
public DebugHint(SolObject owner, Vector2 position) { | ||
private EntityRef entity; | ||
|
||
public DebugHint(SolObject owner, EntityRef entity, Vector2 position) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this would be appropriate as an overload so you don't have to send through arbitrary null values
public float getDamage() { | ||
return damage; | ||
} | ||
|
||
public DmgType getDamageType() { | ||
return damageType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if damageType
is null? Could make it an Optional
PlayableSound sound = specialSounds.getHitSound(materialType, event.getDamageType()); | ||
if (sound != null) { | ||
Vector2 position = entity.getComponent(Position.class).get().position; | ||
soundManager.play(game, sound, position, entity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reuse SpecialSounds.playColl()
?
MaterialType materialType = entity.getComponent(Material.class).get().materialType; | ||
PlayableSound collisionSound = specialSounds.getCollisionSound(materialType); | ||
if (collisionSound != null) { | ||
soundManager.play(game, collisionSound, position, entity, magnitude * Const.IMPULSE_TO_COLL_VOL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not reuse SpecialSounds.playHit()
?
return false; | ||
} | ||
|
||
Map<OggSound, Float> looped = loopedSoundMapOfEntities.get(source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all duplicated code. Can you really not unify this?
* @param damageType the type of damage done | ||
* @return the sound of the damage | ||
*/ | ||
public PlayableSound getHitSound(MaterialType materialType, DmgType damageType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this deserve to exist if hitSound(metal, dmgType)
is already a thing?
Description
This is an ECS-based method for playing sounds. It makes use of the existing
OggSoundManager
, but adds support for entities. It also adds aMaterialType
enum, currently only used for determining which sounds to play. In addition, it removes the duplicate, unused classes fromgame/sounds
, which were identical to classes with the same names inassets/sounds
.There are three types of sound-playing added:
SoundEvent
can be sent.This PR also adds in Asteroid's
AsteroidCrack
sound, which is the sound played when an asteroid gets destroyed.Testing
I wasn't able to test the collision sound locally (my setup has a few issues for me to work out), so that one especially needs testing.