Skip to content

Commit

Permalink
Merge pull request #24 from rwth-acis/feature/audio
Browse files Browse the repository at this point in the history
Feature/audio
  • Loading branch information
BenediktHensen authored Oct 8, 2024
2 parents 9e43bd4 + 4d39998 commit eaa5f51
Show file tree
Hide file tree
Showing 22 changed files with 2,757 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
insertIndex: -1
addedObject: {fileID: 4269083640301180635}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
insertIndex: -1
addedObject: {fileID: 2241099583876537163}
m_SourcePrefab: {fileID: 100100000, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
--- !u!1 &212402951927973884 stripped
GameObject:
Expand Down Expand Up @@ -1882,6 +1885,102 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: afa2f315da5127e47a996e328f4ffff3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!82 &2241099583876537163
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 212402951927973884}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!4 &447753056685965252 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8645416474800241303, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
insertIndex: -1
addedObject: {fileID: 8327870396362132631}
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
insertIndex: -1
addedObject: {fileID: 8651058445503294158}
m_SourcePrefab: {fileID: 100100000, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
--- !u!1 &212402951927973884 stripped
GameObject:
Expand Down Expand Up @@ -1884,6 +1887,102 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: afa2f315da5127e47a996e328f4ffff3, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!82 &8651058445503294158
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 212402951927973884}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!4 &700674713753034054 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 26f8cd740528f3b469c4f32fe28b8306, type: 3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public override void StartExecution(Agent agent)

public void Serialize(SerializationDataContainer serializer)
{
//TODO: add shouldStartOrStop when bool types are supported
//serializer.AddSerializedData("Should Start Or Stop", shouldStartOrStop);
}

public void Deserialize(SerializationDataContainer serializer)
{
//TODO: add shouldStartOrStop when bool types are supported
//shouldStartOrStop = serializer.GetSerializedBool("Should Start Or Stop");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using UnityEngine;

namespace i5.VirtualAgents.AgentTasks
{
public class AgentAudioTask : AgentBaseTask, ISerializable
{
/// <summary>
/// The audio to be played
/// </summary>
public AudioClip Audio;

/// <summary>
/// The audio source which plays the audio
/// </summary>
public AudioSource AgentAudioSource;

/// <summary>
/// Creates a new audio task
/// </summary>
/// <param name="audio">The audio to be played</param>
public AgentAudioTask(AudioClip audio, int priority = 0)
{
Audio = audio;
}

/// <summary>
/// Starts the audio task
/// </summary>
/// <param name="agent">The agent which should execute the movement task</param>
public override void StartExecution(Agent agent)
{
base.StartExecution(agent);
AgentAudioSource = agent.GetComponent<AudioSource>();
AgentAudioSource.clip = Audio;
AgentAudioSource.Play();
}

public override TaskState EvaluateTaskState()
{
if (AgentAudioSource.time < Audio.length)
{
return TaskState.Running;
}
else
{
return TaskState.Success;
}
}
/// <summary>
/// Finish the task
/// </summary>
public override void StopExecution()
{
base.StopExecution();
AgentAudioSource.Stop();
}

/// <summary>
/// Method to pause the audio
/// </summary>
public void PauseAudio()
{
AgentAudioSource.Pause();
}

/// <summary>
/// Method to continue the audio
/// </summary>
public void ContinueAudio()
{
AgentAudioSource.UnPause();
}
public void Serialize(SerializationDataContainer serializer)
{
serializer.AddSerializedData("Audio", Audio);
serializer.AddSerializedData("Agent Audio Source", AgentAudioSource);
}

public void Deserialize(SerializationDataContainer serializer)
{
Audio = serializer.GetSerializedAudioClip("Audio");
AgentAudioSource = serializer.GetSerializedAudioSource("Agent Audio Source");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eaa5f51

Please sign in to comment.