10 protected ref array<ref SCR_VoiceoverLine> m_aQueue = {};
11 protected ref array<IEntity> m_aActors = {};
13 protected SCR_CommunicationSoundComponent m_PlayingSoundComponent;
15 protected AudioHandle m_iAudioHandle;
17 protected float m_fTimer;
19 protected static const float PAUSE_BETWEEN_LINES = 0.5;
22 override event protected void OnUpdate(ESystemPoint point)
24 if (!m_PlayingSoundComponent)
32 if (!m_PlayingSoundComponent.IsFinishedPlaying(m_iAudioHandle))
35 if (m_aQueue.IsEmpty())
43 m_fTimer += GetWorld().GetFixedTimeSlice();
54 override event bool ShouldBePaused()
62 World world =
GetGame().GetWorld();
83 void SetData(ResourceName config)
85 Resource container = BaseContainerTools.LoadContainer(config);
86 m_Data =
SCR_VoiceoverData.Cast(BaseContainerTools.CreateInstanceFromContainer(container.GetResource().ToBaseContainer()));
99 void PlaySequence(
string sequenceName, IEntity actor1 =
null, IEntity actor2 =
null, IEntity actor3 =
null, IEntity actor4 =
null, IEntity actor5 =
null)
104 SCR_VoiceoverSequence sequence = m_Data.GetSequenceByName(sequenceName);
109 sequence.GetLines(m_aQueue);
110 m_aActors = {actor1, actor2, actor3, actor4, actor5};
119 void PlayLine(
string lineName, IEntity actor1 =
null, IEntity actor2 =
null, IEntity actor3 =
null, IEntity actor4 =
null, IEntity actor5 =
null)
124 SCR_VoiceoverLineStandalone line = m_Data.GetLineByName(lineName);
130 m_aActors = {actor1, actor2, actor3, actor4, actor5};
139 void PlayCustomLine(
string soundEventName,
string subtitle, IEntity actor =
null)
141 PlayLine(soundEventName, subtitle, actor);
147 if (m_PlayingSoundComponent && m_iAudioHandle != AudioHandle.Invalid)
148 m_PlayingSoundComponent.Terminate(m_iAudioHandle);
150 m_iAudioHandle = AudioHandle.Invalid;
154 protected void PlayFromQueue()
156 if (m_aQueue.IsEmpty())
160 m_aQueue.RemoveOrdered(0);
162 PlayLine(line.GetSoundEventName(), line.GetSubtitleText(), m_aActors[line.GetActor()]);
166 protected void PlayLine(
string eventName,
string subtitle, IEntity actor =
null)
169 actor = GetDefaultActor();
174 m_PlayingSoundComponent = SCR_CommunicationSoundComponent.Cast(actor.FindComponent(SCR_CommunicationSoundComponent));
176 if (!m_PlayingSoundComponent)
179 if (m_iAudioHandle != AudioHandle.Invalid)
180 AudioSystem.TerminateSound(m_iAudioHandle);
182 m_iAudioHandle = m_PlayingSoundComponent.SoundEvent(eventName);
184 if (m_iAudioHandle != AudioHandle.Invalid)
186 ShowSubtitle(subtitle);
192 protected void ShowSubtitle(
string subtitle)
194 if (!m_SubtitlesDisplay)
203 if (!m_SubtitlesDisplay)
207 GetGame().GetCallqueue().Remove(m_SubtitlesDisplay.Show);
208 m_SubtitlesDisplay.ShowSubtitle(subtitle);
212 protected IEntity GetDefaultActor()
214 PlayerController pc =
GetGame().GetPlayerController();
219 return pc.GetControlledEntity();
223 protected void OnFinished()
225 m_iAudioHandle = AudioHandle.Invalid;
228 m_OnFinished.Invoke();
230 if (!m_SubtitlesDisplay)
233 GetGame().GetCallqueue().Remove(m_SubtitlesDisplay.Show);