hitbox audio service bugfixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
7e752644d9
commit
b50ba66cd8
@ -63,7 +63,7 @@ public class HitboxAudioService {
|
||||
*/
|
||||
public void playAudioPositional(Entity senderEntity, Entity receiverEntity, String hitboxType, String hurtboxType, Vector3d position){
|
||||
String audioPath = this.getAudioPath(senderEntity, receiverEntity, hitboxType, hurtboxType);
|
||||
if(audioPath != null){
|
||||
if(audioPath != null && Globals.virtualAudioSourceManager != null){
|
||||
Globals.virtualAudioSourceManager.createVirtualAudioSource(audioPath, VirtualAudioSourceType.CREATURE, false, position);
|
||||
}
|
||||
}
|
||||
@ -76,9 +76,12 @@ public class HitboxAudioService {
|
||||
* @param hurtboxType The hurthox type
|
||||
* @return The audio file to play
|
||||
*/
|
||||
private String getAudioPath(Entity senderEntity, Entity receiverEntity, String hitboxType, String hurtboxType){
|
||||
protected String getAudioPath(Entity senderEntity, Entity receiverEntity, String hitboxType, String hurtboxType){
|
||||
boolean isBlockSound = false;
|
||||
boolean isDamageSound = false;
|
||||
if(hitboxType == null){
|
||||
return null;
|
||||
}
|
||||
switch(hitboxType){
|
||||
case HitboxData.HITBOX_TYPE_HIT:
|
||||
case HitboxData.HITBOX_TYPE_HIT_CONNECTED: {
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package electrosphere.audio.collision;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import annotations.FastTest;
|
||||
import annotations.UnitTest;
|
||||
|
||||
/**
|
||||
* Unit tests for hitbox audio service
|
||||
*/
|
||||
public class HitboxAudioServiceUnitTests {
|
||||
|
||||
@UnitTest
|
||||
@FastTest
|
||||
public void playAudioPositional_WithNull_NoThrow(){
|
||||
HitboxAudioService hitboxAudioService = new HitboxAudioService();
|
||||
Assertions.assertDoesNotThrow(() -> {
|
||||
hitboxAudioService.playAudioPositional(null, null, null, null, null);
|
||||
});
|
||||
}
|
||||
|
||||
@UnitTest
|
||||
@FastTest
|
||||
public void getAudioPath_WithNullHitboxType_ReturnsNull(){
|
||||
HitboxAudioService hitboxAudioService = new HitboxAudioService();
|
||||
Assertions.assertEquals(null, hitboxAudioService.getAudioPath(null, null, null, null));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user