Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LocationMusic.c
Go to the documentation of this file.
2 {
3  protected bool m_bPlayerIsInHQ = false;
4 
5 
6  override void Init()
7  {
8  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
9 
10  if (!campaign)
11  return;
12 
13  SCR_CampaignMilitaryBaseManager baseManager = campaign.GetBaseManager();
14 
15  if (!baseManager)
16  return;
17 
18  baseManager.GetOnLocalPlayerEnteredBase().Insert(PlayerEnteredHQ);
19  baseManager.GetOnLocalPlayerLeftBase().Insert(PlayerLeftHQ);
20  }
21 
22  override void OnDelete()
23  {
24  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
25 
26  if (!campaign)
27  return;
28 
29  SCR_CampaignMilitaryBaseManager baseManager = campaign.GetBaseManager();
30 
31  if (!baseManager)
32  return;
33 
34  baseManager.GetOnLocalPlayerEnteredBase().Remove(PlayerEnteredHQ);
35  baseManager.GetOnLocalPlayerLeftBase().Remove(PlayerLeftHQ);
36  }
37 
38  //~ Player entered their faction HQ
39  protected void PlayerEnteredHQ(SCR_CampaignMilitaryBaseComponent base)
40  {
41  if (m_bPlayerIsInHQ)
42  return;
43 
44  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
45 
46  if (!campaign)
47  return;
48 
49  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
50  if (!factionManager)
51  return;
52 
53  SCR_CampaignFaction pFaction = SCR_CampaignFaction.Cast(factionManager.GetLocalPlayerFaction());
54 
55  if (!pFaction)
56  return;
57 
58  SCR_CampaignMilitaryBaseComponent HQ = pFaction.GetMainBase();
59 
60  //~ No HQ or the given base is not HQ then ignore
61  if (!HQ || base != HQ)
62  return;
63 
64  m_bPlayerIsInHQ = true;
65  }
66 
67  //~ Player left their faction HQ
68  protected void PlayerLeftHQ(SCR_CampaignMilitaryBaseComponent base)
69  {
70  if (!m_bPlayerIsInHQ)
71  return;
72 
73  SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
74 
75  if (!campaign)
76  return;
77 
78  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
79  if (!factionManager)
80  return;
81 
82  SCR_CampaignFaction pFaction = SCR_CampaignFaction.Cast(factionManager.GetLocalPlayerFaction());
83 
84  if (!pFaction)
85  return;
86 
87  SCR_CampaignMilitaryBaseComponent HQ = pFaction.GetMainBase();
88 
89  //~ No HQ or the given base is not HQ then ignore
90  if (!HQ || base != HQ)
91  return;
92 
93  m_bPlayerIsInHQ = false;
94  }
95 
96  override bool ShouldPlay()
97  {
98  return !m_bPlayerIsInHQ;
99  }
100 }
SCR_LocationMusic
Definition: SCR_LocationMusic.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
SCR_CampaignMilitaryBaseManager
Created in SCR_GameModeCampaign.
Definition: SCR_CampaignMilitaryBaseManager.c:21
SCR_CampaignFaction
Definition: SCR_CampaignFaction.c:2
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
LocationMusic
Definition: LocationMusic.c:12
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38