Skip to content

Commit

Permalink
refactor(audio): merged entity audios, param IDs, spatializers
Browse files Browse the repository at this point in the history
  • Loading branch information
FurkanKambay committed Aug 11, 2024
1 parent 4bdb401 commit 25688ff
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 268 deletions.
37 changes: 0 additions & 37 deletions Assets/Code/Audio/EnemyAudio.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Assets/Code/Audio/PlayerAudio.cs.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,54 @@

namespace Tulip.Audio
{
public class PlayerAudio : MonoBehaviour
public class WielderAudio : MonoBehaviour
{
[Header("References")]
[SerializeField, Required] SaintsInterface<Component, IHealth> health;
[SerializeField, Required] SaintsInterface<Component, IItemWielder> itemWielder;
[SerializeField] SaintsInterface<Component, IItemWielder> itemWielder;

[Header("FMOD Events")]
[SerializeField, Required] StudioEventEmitter hurtSfx;
[SerializeField, Required] StudioEventEmitter itemSfx;
[SerializeField] EventReference hurtEvent;
[SerializeField] EventReference itemSwingEvent;

private PARAMETER_ID paramLifeState;

private void Awake()
{
EventDescription description = RuntimeManager.GetEventDescription(hurtSfx.EventReference);
EventDescription description = RuntimeManager.GetEventDescription(hurtEvent);
description.getParameterDescriptionByName("Life State", out PARAMETER_DESCRIPTION paramDesc);
paramLifeState = paramDesc.id;
}

private void OnEnable()
{
health.I.OnHurt += HandleHurt;
itemWielder.I.OnSwingPerform += HandleItemSwing;

if (itemWielder.V)
itemWielder.I.OnSwingPerform += HandleItemSwing;
}

private void OnDisable()
{
health.I.OnHurt -= HandleHurt;
itemWielder.I.OnSwingPerform -= HandleItemSwing;

if (itemWielder.V)
itemWielder.I.OnSwingPerform -= HandleItemSwing;
}

private void HandleHurt(HealthChangeEventArgs damage)
{
EventInstance hurtSfx = RuntimeManager.CreateInstance(hurtEvent);
RuntimeManager.AttachInstanceToGameObject(hurtSfx, transform);

LifeState lifeState = damage.Target.IsAlive ? LifeState.Alive : LifeState.Dead;
hurtSfx.Play();
hurtSfx.SetParameter(paramLifeState, (float)lifeState);
hurtSfx.setParameterByID(paramLifeState, (float)lifeState);

hurtSfx.start();
hurtSfx.release();
}

private void HandleItemSwing(ItemStack stack, Vector3 _) => itemSfx.Play();
private void HandleItemSwing(ItemStack stack, Vector3 _) =>
RuntimeManager.PlayOneShotAttached(itemSwingEvent, transform.gameObject);
}
}
File renamed without changes.
1 change: 0 additions & 1 deletion Assets/Code/GameWorld/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public InventoryModification DamageTile(Vector3Int cell, TileType tileType, int
if (isReadonly)
return default;

// move on to tiles
Tilemap tilemap = GetTilemap(tileType);
Placeable placeable = GetTile(tileType, cell);

Expand Down
39 changes: 11 additions & 28 deletions Assets/Prefabs/Characters/Enemy.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ GameObject:
m_Component:
- component: {fileID: 351480472563880154}
- component: {fileID: 7947214954686311404}
- component: {fileID: 8304630222528222627}
m_Layer: 7
m_Name: Audio
m_TagString: Untagged
Expand All @@ -467,7 +466,7 @@ Transform:
m_GameObject: {fileID: 3888340314453382271}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
Expand All @@ -487,38 +486,22 @@ MonoBehaviour:
m_EditorClassIdentifier:
health:
<V>k__BackingField: {fileID: 1334333901957425893}
hurtSfx: {fileID: 8304630222528222627}
--- !u!114 &8304630222528222627
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3888340314453382271}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a6610d2e704f1648819acc8d7460285, type: 3}
m_Name:
m_EditorClassIdentifier:
CollisionTag:
EventReference:
itemWielder:
<V>k__BackingField: {fileID: 6883005073613853074}
hurtEvent:
Guid:
Data1: -1768576580
Data2: 1151959725
Data3: -866273913
Data4: 810694509
Path: event:/SFX/Hurt
Event:
PlayEvent: 0
StopEvent: 0
AllowFadeout: 1
TriggerOnce: 0
Preload: 0
NonRigidbodyVelocity: 0
Params: []
OverrideAttenuation: 0
OverrideMinDistance: 1
OverrideMaxDistance: 20
itemSwingEvent:
Guid:
Data1: 793295938
Data2: 1105161512
Data3: -2094091101
Data4: 498006989
Path: event:/SFX/Melee Attack
--- !u!1 &4788866980522632928
GameObject:
m_ObjectHideFlags: 0
Expand Down
64 changes: 6 additions & 58 deletions Assets/Prefabs/Characters/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 782185684793632868}
- component: {fileID: 405507308117652143}
- component: {fileID: 2461148172210768736}
- component: {fileID: 7331900004779792075}
- component: {fileID: 2259726738235934394}
m_Layer: 6
m_Name: Audio
m_TagString: Untagged
Expand All @@ -713,13 +711,13 @@ Transform:
m_GameObject: {fileID: 3988847855271664023}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8291246366843984804}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &405507308117652143
--- !u!114 &2259726738235934394
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -728,77 +726,27 @@ MonoBehaviour:
m_GameObject: {fileID: 3988847855271664023}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7510b374231144b5bc8a2f704017c6d3, type: 3}
m_Script: {fileID: 11500000, guid: 42c4603604fd42608b358258f353d561, type: 3}
m_Name:
m_EditorClassIdentifier:
health:
<V>k__BackingField: {fileID: 7186377946535505526}
itemWielder:
<V>k__BackingField: {fileID: 647329674294491017}
hurtSfx: {fileID: 2461148172210768736}
itemSfx: {fileID: 7331900004779792075}
--- !u!114 &2461148172210768736
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3988847855271664023}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a6610d2e704f1648819acc8d7460285, type: 3}
m_Name:
m_EditorClassIdentifier:
CollisionTag:
EventReference:
hurtEvent:
Guid:
Data1: -1768576580
Data2: 1151959725
Data3: -866273913
Data4: 810694509
Path: event:/SFX/Hurt
Event:
PlayEvent: 0
StopEvent: 0
AllowFadeout: 1
TriggerOnce: 0
Preload: 0
NonRigidbodyVelocity: 0
Params: []
OverrideAttenuation: 0
OverrideMinDistance: 1
OverrideMaxDistance: 20
--- !u!114 &7331900004779792075
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3988847855271664023}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a6610d2e704f1648819acc8d7460285, type: 3}
m_Name:
m_EditorClassIdentifier:
CollisionTag:
EventReference:
itemSwingEvent:
Guid:
Data1: 793295938
Data2: 1105161512
Data3: -2094091101
Data4: 498006989
Path: event:/SFX/Melee Attack
Event:
PlayEvent: 0
StopEvent: 0
AllowFadeout: 1
TriggerOnce: 0
Preload: 0
NonRigidbodyVelocity: 0
Params: []
OverrideAttenuation: 0
OverrideMinDistance: 1
OverrideMaxDistance: 20
--- !u!1 &4068249101980331751
GameObject:
m_ObjectHideFlags: 0
Expand Down
37 changes: 10 additions & 27 deletions Assets/Prefabs/Characters/Skull.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ GameObject:
m_Component:
- component: {fileID: 351480472563880154}
- component: {fileID: 7947214954686311404}
- component: {fileID: 8518578520888892457}
m_Layer: 7
m_Name: Audio
m_TagString: Untagged
Expand Down Expand Up @@ -428,38 +427,22 @@ MonoBehaviour:
m_EditorClassIdentifier:
health:
<V>k__BackingField: {fileID: 1334333901957425893}
hurtSfx: {fileID: 8518578520888892457}
--- !u!114 &8518578520888892457
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3888340314453382271}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a6610d2e704f1648819acc8d7460285, type: 3}
m_Name:
m_EditorClassIdentifier:
CollisionTag:
EventReference:
itemWielder:
<V>k__BackingField: {fileID: 8169639496971023625}
hurtEvent:
Guid:
Data1: -1768576580
Data2: 1151959725
Data3: -866273913
Data4: 810694509
Path: event:/SFX/Hurt
Event:
PlayEvent: 0
StopEvent: 0
AllowFadeout: 1
TriggerOnce: 0
Preload: 0
NonRigidbodyVelocity: 0
Params: []
OverrideAttenuation: 0
OverrideMinDistance: 1
OverrideMaxDistance: 20
itemSwingEvent:
Guid:
Data1: 793295938
Data2: 1105161512
Data3: -2094091101
Data4: 498006989
Path: event:/SFX/Melee Attack
--- !u!1 &4398918780429037188
GameObject:
m_ObjectHideFlags: 0
Expand Down
Loading

0 comments on commit 25688ff

Please sign in to comment.