Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CallsignBaseComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Callsign", description: "")]
2 class SCR_CallsignBaseComponentClass : ScriptComponentClass
3 {
4 }
5 
6 //~ ScriptInvokers
7 void SCR_CallsignBaseComponent_OnCallsignChanged(int companyIndex, int platoonIndex, int squadIndex, int characterNumber, ERoleCallsign characterRole);
9 
12 {
13  protected Faction m_Faction;
14  protected SCR_FactionCallsignInfo m_CallsignInfo;
15 
16  //Callsign IDs(Broadcast)
17  protected int m_iCompanyCallsign = -1;
18  protected int m_iPlatoonCallsign = -1;
19  protected int m_iSquadCallsign = -1;
20 
21  //State
22  protected bool m_bIsServer;
23 
24  //Ref
25  protected SCR_CallsignManagerComponent m_CallsignManager;
26 
27  //Will always return int Company, int Platoon, int squad, int character number and character role (See GetCallsignIndexes() comments for more information). Also called when assigning callsigns for first time
28  protected ref ScriptInvokerBase<SCR_CallsignBaseComponent_OnCallsignChanged> Event_OnCallsignChanged = new ScriptInvokerBase<SCR_CallsignBaseComponent_OnCallsignChanged>();
29 
30  //------------------------------------------------------------------------------------------------
38  bool GetCallsignNames(out string company, out string platoon, out string squad, out string character, out string format)
39  {
40  return false;
41  }
42 
43  //------------------------------------------------------------------------------------------------
51  bool GetCallsignIndexes(out int companyIndex, out int platoonIndex, out int squadIndex, out int characterNumber = -1, out ERoleCallsign characterRole = ERoleCallsign.NONE)
52  {
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  protected void ClearCallsigns()
57  {
58  m_CallsignInfo = null;
59 
60  m_iCompanyCallsign = -1;
61  m_iPlatoonCallsign = -1;
62  m_iSquadCallsign = -1;
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  protected bool SetCallsignInfo()
67  {
68  Faction currentFaction;
69 
70  SCR_AIGroup group = SCR_AIGroup.Cast(GetOwner());
71  if (group && group.IsPlayable())
72  currentFaction = group.GetFaction();
73  else
74  {
75  SCR_EditableEntityComponent editableEntityComponent = SCR_EditableEntityComponent.GetEditableEntity(GetOwner());
76  if (editableEntityComponent)
77  currentFaction = editableEntityComponent.GetFaction();
78  }
79 
80  if (m_Faction != currentFaction && currentFaction != null)
81  {
82  m_Faction = currentFaction;
83  m_CallsignInfo = null;
84  }
85  else
86  {
87  if (m_CallsignInfo)
88  return true;
89  }
90 
91  SCR_Faction scrFaction = SCR_Faction.Cast(m_Faction);
92 
93  if (!scrFaction)
94  return false;
95 
96  m_CallsignInfo = scrFaction.GetCallsignInfo();
97  return m_CallsignInfo != null;
98  }
99 
100  //------------------------------------------------------------------------------------------------
102  ScriptInvokerBase<SCR_CallsignBaseComponent_OnCallsignChanged> GetOnCallsignChanged()
103  {
104  return Event_OnCallsignChanged;
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  protected void InitOnServer(IEntity owner)
109  {
110  }
111 
112  //------------------------------------------------------------------------------------------------
113  override void EOnInit(IEntity owner)
114  {
115  if (SCR_Global.IsEditMode(owner))
116  return;
117 
118  BaseGameMode gameMode = GetGame().GetGameMode();
119  if (!gameMode)
120  return;
121 
122  m_CallsignManager = SCR_CallsignManagerComponent.Cast(gameMode.FindComponent(SCR_CallsignManagerComponent));
123  if (!m_CallsignManager)
124  return;
125 
126  SCR_EditableEntityComponent editableEntityComponent = SCR_EditableEntityComponent.GetEditableEntity(owner);
127  if (editableEntityComponent)
128  m_Faction = editableEntityComponent.GetFaction();
129  m_bIsServer = Replication.IsServer();
130 
131  if (!m_bIsServer)
132  return;
133 
134  GetGame().GetCallqueue().CallLater(InitOnServer, 1, false, owner);
135  }
136 
137  //------------------------------------------------------------------------------------------------
138  override void OnPostInit(IEntity owner)
139  {
140  SetEventMask(owner, EntityEvent.INIT);
141  }
142 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_FactionCallsignInfo
Definition: SCR_FactionCallsignInfo.c:5
ERoleCallsign
ERoleCallsign
Definition: ERoleCallsign.c:4
func
func
Definition: SCR_AIThreatSystem.c:5
SCR_CallsignBaseComponent
Component of assigning and storing squad names.
Definition: SCR_CallsignBaseComponent.c:11
m_CallsignInfo
protected ref SCR_FactionCallsignInfo m_CallsignInfo
Definition: SCR_Faction.c:29
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
Faction
Definition: Faction.c:12
SCR_Global
Definition: Functions.c:6
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_CallsignManagerComponent
Definition: SCR_CallsignManagerComponent.c:12
SCR_CallsignBaseComponentClass
Definition: SCR_CallsignBaseComponent.c:2
m_Faction
Faction m_Faction
Definition: SCR_AITargetInfo.c:18
SCR_Faction
Definition: SCR_Faction.c:6
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_CallsignBaseComponent_OnCallsignChanged
func SCR_CallsignBaseComponent_OnCallsignChanged
Definition: SCR_CallsignBaseComponent.c:8