Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SourceBaseAudioComponent.c
Go to the documentation of this file.
4
5class SCR_SourceBaseAudioComponent : ScriptComponent
6{
7 [Attribute()]
8 protected ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
9
10 protected SCR_CampaignSourceBaseComponent m_SourceBaseComponent;
11
12 //------------------------------------------------------------------------------------------------
13 override void OnPostInit(IEntity owner)
14 {
15 super.OnPostInit(owner);
16
17 // Spawning of base building is delayed, so we also delay the assignment of source base component
18 GetGame().GetCallqueue().CallLater(SetSourceBaseComponent, 1500, false);
19 }
20
21 //------------------------------------------------------------------------------------------------
23 protected void SetSourceBaseComponent()
24 {
25 IEntity ancestor = GetOwner().GetRootParent();
26 if (!ancestor)
27 return;
28
30 if (!baseSystem)
31 return;
32
33 array<SCR_MilitaryBaseComponent> bases = {};
34 baseSystem.GetBases(bases);
35
36 foreach (SCR_MilitaryBaseComponent base : bases)
37 {
38 SCR_CampaignSourceBaseComponent sourceBaseComponent = SCR_CampaignSourceBaseComponent.Cast(base);
39 if (!sourceBaseComponent)
40 continue;
41
42 if (sourceBaseComponent.GetBaseBuildingComposition() != ancestor)
43 continue;
44
45 m_SourceBaseComponent = sourceBaseComponent;
46 break;
47 }
48
50 return;
51
52 m_SourceBaseComponent.GetOnSuppliesArrivalInvoker().Insert(PlaySupplyArrivalSound);
53 }
54
55 //------------------------------------------------------------------------------------------------
61
62 //------------------------------------------------------------------------------------------------
63 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
65 {
66 SCR_SoundManagerModule soundManagerModule = SCR_SoundManagerModule.GetInstance(GetGame().GetWorld());
67 if (!soundManagerModule)
68 return;
69
70 soundManagerModule.CreateAndPlayAudioSource(GetOwner(), m_AudioSourceConfiguration);
71 }
72
73 //------------------------------------------------------------------------------------------------
75 {
77 return;
78
79 m_SourceBaseComponent.GetOnSuppliesArrivalInvoker().Remove(PlaySupplyArrivalSound);
80 }
81}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
void RpcDo_PlaySupplyArrivalSound()
SCR_CampaignSourceBaseComponent m_SourceBaseComponent
void PlaySupplyArrivalSound()
void ~SCR_SourceBaseAudioComponent()
void SetSourceBaseComponent()
Find the source base component of owner base, caches it and subscribes to GetOnSuppliesArrivalInvoker...
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external IEntity GetRootParent()
int GetBases(notnull out array< SCR_MilitaryBaseComponent > bases)
static SCR_MilitaryBaseSystem GetInstance()
proto external GenericEntity GetOwner()
Get owner entity.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14