DayZ 1.24
Loading...
Searching...
No Matches
QuickBarBase.c File Reference

Go to the source code of this file.

Classes

class  QuickBarItem
 

Functions

void QuickBarBase (PlayerBase player)
 
void SetSize (int newSize)
 
int GetNonEmptyCount ()
 
EntityAI GetEntity (int index)
 
int GetSize ()
 
int FindEntityIndex (EntityAI entity)
 
bool OnInputUserDataProcess (int userDataType, ParamsReadContext ctx)
 
void UpdateShotcutVisibility (int index)
 
void SetShotcutEnable (int index, bool value)
 
bool CanAddAsShortcut (EntityAI entity)
 
void SetEntityShortcut (EntityAI entity, int index, bool force=false)
 
void OnSetEntityNoSync (EntityAI entity, int index, bool force=false)
 
void OnSetEntityRPC (ParamsReadContext ctx)
 Reaction on Rpc from server for set inicial state for quickbar.
 
void OnSetEntityRequest (ParamsReadContext ctx)
 Reaction on SetEntityShortcut from client.
 
void _SetEntityShortcut (EntityAI entity, int index, bool force=false)
 
void updateSlotsCount ()
 
void _RemoveEntity (int index)
 
void _SetEntity (EntityAI entity, int index, bool force=false)
 
void ~QuickBarBase ()
 
void CancelContinuousUse (int index)
 

Variables

const int MAX_QUICKBAR_SLOTS_COUNT = 10
 
class QuickBarItem m_aQuickbarEnts [MAX_QUICKBAR_SLOTS_COUNT]
 
PlayerBase _player
 
int m_slotsCount
 

Function Documentation

◆ _RemoveEntity()

void _RemoveEntity ( int index)
protected

Definition at line 236 of file QuickBarBase.c.

237 {
239 {
241
242 m_aQuickbarEnts[index].m_entity = NULL;
243 m_aQuickbarEnts[index].m_enabled = false;
244
245 if (_player.m_Hud)
246 _player.m_Hud.RefreshQuickbar(true);
247 }
248 }
class QuickBarItem m_aQuickbarEnts[MAX_QUICKBAR_SLOTS_COUNT]
PlayerBase _player
const int MAX_QUICKBAR_SLOTS_COUNT
Definition QuickBarBase.c:1
void CancelContinuousUse(int index)

References _player, CancelContinuousUse(), m_aQuickbarEnts, and MAX_QUICKBAR_SLOTS_COUNT.

Referenced by _SetEntityShortcut().

◆ _SetEntity()

void _SetEntity ( EntityAI entity,
int index,
bool force = false )
protected

Definition at line 250 of file QuickBarBase.c.

251 {
253 {
255 {
256 m_aQuickbarEnts[index].m_entity = entity;
257 m_aQuickbarEnts[index].m_enabled = true;
258 }
259 else
260 {
262 m_aQuickbarEnts[index].m_enabled = false;
263 }
264
265 if (_player.m_Hud)
266 _player.m_Hud.RefreshQuickbar(true);
267 }
268 }
bool CanAddAsShortcut(EntityAI entity)

References _player, CanAddAsShortcut(), CancelContinuousUse(), m_aQuickbarEnts, and MAX_QUICKBAR_SLOTS_COUNT.

Referenced by _SetEntityShortcut().

◆ _SetEntityShortcut()

void _SetEntityShortcut ( EntityAI entity,
int index,
bool force = false )
protected

Definition at line 205 of file QuickBarBase.c.

206 {
207 //TODO Check, if is in inventory
208 //if(entity.GetLoca)
209 if (entity == NULL)
210 {
212 return;
213 }
214
215 int i = FindEntityIndex(entity);
216
217 if (i != -1)
219
222 }
void _RemoveEntity(int index)
void _SetEntity(EntityAI entity, int index, bool force=false)
int FindEntityIndex(EntityAI entity)

References _RemoveEntity(), _SetEntity(), and FindEntityIndex().

Referenced by OnSetEntityNoSync(), OnSetEntityRequest(), OnSetEntityRPC(), and SetEntityShortcut().

◆ CanAddAsShortcut()

bool CanAddAsShortcut ( EntityAI entity)
protected

Definition at line 135 of file QuickBarBase.c.

136 {
138 entity.GetInventory().GetCurrentInventoryLocation(loc);
139 EntityAI parent = loc.GetParent();
140
141 return (entity && entity.GetHierarchyRootPlayer() == _player && parent.CanAssignAttachmentsToQuickbar() && entity.CanAssignToQuickbar());
142 }
InventoryLocation.

References _player.

Referenced by _SetEntity(), SetShotcutEnable(), and UpdateShotcutVisibility().

◆ CancelContinuousUse()

void CancelContinuousUse ( int index)
protected

Definition at line 275 of file QuickBarBase.c.

276 {
277 if (_player.m_QuickBarHold)
278 {
279 HumanInputController hic = _player.GetInputController();
280 if (hic && hic.IsQuickBarSlot() == index + 1)
281 _player.OnQuickBarContinuousUseEnd(index + 1);
282 }
283 }

References _player.

Referenced by _RemoveEntity(), _SetEntity(), SetShotcutEnable(), and UpdateShotcutVisibility().

◆ FindEntityIndex()

int FindEntityIndex ( EntityAI entity)
protected

Definition at line 93 of file QuickBarBase.c.

94 {
95 for (int i = 0; i < MAX_QUICKBAR_SLOTS_COUNT; i++)
96 {
97 if (m_aQuickbarEnts[i].m_entity == entity)
98 return i;
99 }
100
101 return -1;
102 }

References m_aQuickbarEnts, and MAX_QUICKBAR_SLOTS_COUNT.

Referenced by _SetEntityShortcut().

◆ GetEntity()

EntityAI GetEntity ( int index)
protected

Definition at line 76 of file QuickBarBase.c.

77 {
79 return NULL;
80
81 if (m_aQuickbarEnts[index].m_enabled)
82 return m_aQuickbarEnts[index].m_entity;
83
84 return NULL;
85 }
int m_slotsCount

References m_aQuickbarEnts, and m_slotsCount.

◆ GetNonEmptyCount()

int GetNonEmptyCount ( )
protected

Definition at line 64 of file QuickBarBase.c.

65 {
66 int count = 0;
67 for (int i = 0; i < m_slotsCount; i++)
68 {
69 if (m_aQuickbarEnts[i].m_enabled)
70 count++;
71 }
72
73 return count;
74 }

References m_aQuickbarEnts, and m_slotsCount.

◆ GetSize()

int GetSize ( )
protected

Definition at line 88 of file QuickBarBase.c.

89 {
90 return m_slotsCount;
91 }

References m_slotsCount.

◆ OnInputUserDataProcess()

bool OnInputUserDataProcess ( int userDataType,
ParamsReadContext ctx )
protected

Definition at line 104 of file QuickBarBase.c.

105 {
107 {
109 return true;
110 }
111
112 return false;
113 }
const int INPUT_UDT_QUICKABARSHORTCUT
Definition _constants.c:5
void OnSetEntityRequest(ParamsReadContext ctx)
Reaction on SetEntityShortcut from client.

References INPUT_UDT_QUICKABARSHORTCUT, and OnSetEntityRequest().

◆ OnSetEntityNoSync()

void OnSetEntityNoSync ( EntityAI entity,
int index,
bool force = false )
protected

Definition at line 171 of file QuickBarBase.c.

172 {
174 }
void _SetEntityShortcut(EntityAI entity, int index, bool force=false)

References _SetEntityShortcut().

◆ OnSetEntityRequest()

void OnSetEntityRequest ( ParamsReadContext ctx)
protected

Reaction on SetEntityShortcut from client.

Definition at line 188 of file QuickBarBase.c.

189 {
190 EntityAI eai = null;
191 if (!ctx.Read(eai))
192 return;
193
194 int index = -1;
195 if (!ctx.Read(index))
196 return;
197
198 bool force = false;
199 if (!ctx.Read(force))
200 return
201
203 }

References _SetEntityShortcut().

Referenced by OnInputUserDataProcess().

◆ OnSetEntityRPC()

void OnSetEntityRPC ( ParamsReadContext ctx)
protected

Reaction on Rpc from server for set inicial state for quickbar.

Definition at line 177 of file QuickBarBase.c.

178 {
180 if (!ctx.Read(param))
181 return;
182
183 EntityAI entity1 = EntityAI.Cast(param.param1);
184 _SetEntityShortcut(entity1, param.param2, false);
185 }

References _SetEntityShortcut().

◆ QuickBarBase()

void QuickBarBase ( PlayerBase player)
protected

Definition at line 21 of file QuickBarBase.c.

22 {
23 for (int i = 0; i < MAX_QUICKBAR_SLOTS_COUNT; i++)
24 {
26 m_aQuickbarEnts[i].m_enabled = false;
27 m_aQuickbarEnts[i].m_entity = NULL;
28 }
29
31 m_slotsCount = 0;
32 }

References _player, m_aQuickbarEnts, m_slotsCount, and MAX_QUICKBAR_SLOTS_COUNT.

Referenced by ManBase::Init().

◆ SetEntityShortcut()

void SetEntityShortcut ( EntityAI entity,
int index,
bool force = false )
protected

Definition at line 144 of file QuickBarBase.c.

145 {
146 //Client
147 if (GetGame().IsClient())
148 {
150 {
153 ctx.Write(entity);
154 ctx.Write(index);
155 ctx.Write(force);
156 ctx.Send();
157
159 }
160 }
161 //Server
162 else if (GetGame().IsMultiplayer() && GetGame().IsServer())
164 else
165 {
166 // Single player
168 }
169 }
static void SendQuickbarSetShortcut(DayZPlayer pPlayer, EntityAI item, int index, bool force=false)
proto static native bool CanStoreInputUserData()
proto native CGame GetGame()

References _player, _SetEntityShortcut(), ScriptInputUserData::CanStoreInputUserData(), GetGame(), INPUT_UDT_QUICKABARSHORTCUT, and DayZPlayerSyncJunctures::SendQuickbarSetShortcut().

◆ SetShotcutEnable()

void SetShotcutEnable ( int index,
bool value )
protected

Definition at line 125 of file QuickBarBase.c.

126 {
128 if (!m_aQuickbarEnts[index].m_enabled)
130
131 if (_player.m_Hud)
132 _player.m_Hud.RefreshQuickbar(true);
133 }

References _player, CanAddAsShortcut(), CancelContinuousUse(), and m_aQuickbarEnts.

◆ SetSize()

void SetSize ( int newSize)
protected

Definition at line 34 of file QuickBarBase.c.

35 {
36 int i = m_slotsCount;
37 if (newSize == m_slotsCount)
38 return;
39
42
43 if (newSize > i)
44 {
45 for (; i < newSize; i++)
46 {
47 EntityAI entity = m_aQuickbarEnts[i].m_entity;
48 if (entity != NULL && entity.GetHierarchyRootPlayer() == _player)
49 m_aQuickbarEnts[i].m_enabled = true;
50 }
51 }
52 else
53 {
54 for (i--; i >= newSize; i--)
55 m_aQuickbarEnts[i].m_enabled = false;
56 }
57
59
60 if (_player.m_Hud)
61 _player.m_Hud.RefreshQuickbar(true);
62 }

References _player, m_aQuickbarEnts, m_slotsCount, and MAX_QUICKBAR_SLOTS_COUNT.

◆ UpdateShotcutVisibility()

void UpdateShotcutVisibility ( int index)
protected

Definition at line 115 of file QuickBarBase.c.

116 {
118 if (!m_aQuickbarEnts[index].m_enabled)
120
121 if (_player.m_Hud)
122 _player.m_Hud.RefreshQuickbar(true);
123 }

References _player, CanAddAsShortcut(), CancelContinuousUse(), and m_aQuickbarEnts.

◆ updateSlotsCount()

void updateSlotsCount ( )
protected

Definition at line 224 of file QuickBarBase.c.

225 {
226 int slotsCount = _player.GetQuickBarBonus();
227 int attCount = _player.GetInventory().AttachmentCount();
228
229 for (int i = 0; i < attCount; ++i)
230 slotsCount += _player.GetInventory().GetAttachmentFromIndex(i).GetQuickBarBonus();
231
232 //max slots is 10
234 }
void SetSize(int newSize)
Definition EnMath.c:7
static proto float Min(float x, float y)
Returns smaller of two given values.

References _player, Math::Min(), and SetSize().

◆ ~QuickBarBase()

void ~QuickBarBase ( )
protected

Definition at line 270 of file QuickBarBase.c.

271 {
272
273 }

Variable Documentation

◆ _player

◆ m_aQuickbarEnts

◆ m_slotsCount

int m_slotsCount
protected

Definition at line 19 of file QuickBarBase.c.

Referenced by GetEntity(), GetNonEmptyCount(), GetSize(), QuickBarBase(), and SetSize().

◆ MAX_QUICKBAR_SLOTS_COUNT

const int MAX_QUICKBAR_SLOTS_COUNT = 10

Definition at line 1 of file QuickBarBase.c.

Referenced by _RemoveEntity(), _SetEntity(), FindEntityIndex(), QuickBarBase(), and SetSize().