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

Go to the source code of this file.

Enumerations

enum  DSLevels { WARNING = 1 , CRITICAL = 2 , BLINKING = 3 , EXTRA = 4 }
 

Functions

void VirtualHud (PlayerBase player)
 
void OnScheduledTick ()
 
void RegisterElement (DisplayElementBase element)
 
DisplayElementBase GetElement (eDisplayElements element_id)
 
void SerializeElements (ref array< int > mask_array)
 
void DeserializeElements (ref array< int > mask_array)
 
int BitToDec (int mask, int index, int compareMask)
 
void PrintElements ()
 
void SendRPC ()
 
bool AreArraysSame (notnull array< int > array_a, notnull array< int > array_b)
 
void ImmediateUpdate ()
 
void UpdateStatus ()
 
void OnRPC (ParamsReadContext ctx)
 
void Debug ()
 

Variables

enum DSLevels NORMAL = 0
 
enum DSLevels WARNING_MINUS = 1
 
enum DSLevels CRITICAL_MINUS = 2
 
enum DSLevels BLINKING_MINUS = 3
 
enum DSLevels WARNING_PLUS = 4
 
enum DSLevels CRITICAL_PLUS = 5
 
enum DSLevels BLINKING_PLUS = 6
 
enum DSLevels NUMBER_OF_MASKS = 2
 
ref array< intm_LastSentArray
 
const int NUMBER_OF_ELEMENTS = eDisplayElements.COUNT
 
ref DisplayElementBase m_Elements [NUMBER_OF_ELEMENTS]
 
Mission mission
 
Hud m_Hud
 
int m_LastTick
 
PlayerBase m_Player
 
string m_System = "VirtualHud"
 
ref array< ref ParamrpcParams
 

Enumeration Type Documentation

◆ DSLevels

Enumerator
WARNING 
CRITICAL 
BLINKING 
EXTRA 

Definition at line 1 of file DisplayStatus.c.

2{
3 NORMAL = 0,//no bit, default
4 WARNING = 1,//first bit
5 CRITICAL = 2,//second bit
6 BLINKING = 3,//first + second bit
7 EXTRA = 4,//third bit
8}
enum DSLevels NORMAL
@ BLINKING
@ WARNING
@ CRITICAL
@ EXTRA

Function Documentation

◆ AreArraysSame()

bool AreArraysSame ( notnull array< int > array_a,
notnull array< int > array_b )

Definition at line 174 of file DisplayStatus.c.

175 {
176 if (array_a.Count() != array_b.Count()) return false;
177 for (int i = 0; i < array_a.Count(); i++)
178 {
179 if (array_a.Get(i) != array_b.Get(i))
180 return false;
181 }
182 return true;
183 }

Referenced by SendRPC().

◆ BitToDec()

int BitToDec ( int mask,
int index,
int compareMask )

Definition at line 147 of file DisplayStatus.c.

148 {
149 int value = mask & (compareMask << index);
150 value = value >> index;
151 return value;
152 }

Referenced by DeserializeElements().

◆ Debug()

void Debug ( )

Definition at line 215 of file DisplayStatus.c.

216 {
217 Log("debug");
218 PluginPlayerStatus m_ModulePlayerStatus = PluginPlayerStatus.Cast(GetPlugin(PluginPlayerStatus));
219 m_ModulePlayerStatus.DisplayTendency(NTFKEY_HUNGRY, 2);
220 }
const int NTFKEY_HUNGRY
Definition _constants.c:34
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.
PluginPlayerStatus m_ModulePlayerStatus
PluginBase GetPlugin(typename plugin_type)

References GetPlugin(), Log(), m_ModulePlayerStatus, and NTFKEY_HUNGRY.

◆ DeserializeElements()

void DeserializeElements ( ref array< int > mask_array)

Definition at line 123 of file DisplayStatus.c.

124 {
125 int maskArrayIndex = 0;
126 int offset = 0;
127 int mask = 0;
128
129 for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
130 {
131 if (GetElement(i) && !GetElement(i).IsClientOnly())
132 {
133 //Log("entity> " + ToString(GetElement(i)) );
134 if (offset + GetElement(i).GetNumberOfBits() > BIT_INT_SIZE)
135 {
137 offset = 0;
138 }
140 int value = BitToDec(mask, offset, GetElement(i).GetCompareMask());
141 offset = offset + GetElement(i).GetNumberOfBits();
142 GetElement(i).SetValue(value);
143 }
144 }
145 }
const int BIT_INT_SIZE
Definition BitArray.c:4
const int NUMBER_OF_ELEMENTS
DisplayElementBase GetElement(eDisplayElements element_id)
int BitToDec(int mask, int index, int compareMask)

References BIT_INT_SIZE, BitToDec(), GetElement(), and NUMBER_OF_ELEMENTS.

Referenced by OnRPC().

◆ GetElement()

◆ ImmediateUpdate()

void ImmediateUpdate ( )

Definition at line 185 of file DisplayStatus.c.

186 {
187 for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
188 {
190 if (element && element.IsClientOnly() && element.IsValueChanged())
191 element.UpdateHUD();
192 }
193 }

References GetElement(), and NUMBER_OF_ELEMENTS.

Referenced by OnScheduledTick().

◆ OnRPC()

void OnRPC ( ParamsReadContext ctx)

Definition at line 206 of file DisplayStatus.c.

207 {
208 //Log("OnRPC called");
210 ctx.Read(mask_array);
212 UpdateStatus();
213 }
void UpdateStatus()
void DeserializeElements(ref array< int > mask_array)

References DeserializeElements(), and UpdateStatus().

◆ OnScheduledTick()

void OnScheduledTick ( )

Definition at line 69 of file DisplayStatus.c.

70 {
71 if (GetGame().IsServer())
72 {
74 {
75 SendRPC();
76 m_LastTick = GetGame().GetTime();
77 }
78 }
79 if (!GetGame().IsDedicatedServer())
80 {
82 //DisplayPresence();
83 }
84 }
VIRTUAL_HUD_UPDATE_INTERVAL
how often virtual hud checks if there is a difference since last sync
int m_LastTick
void ImmediateUpdate()
void SendRPC()
float GetTime()
proto native CGame GetGame()

References GetGame(), GetTime(), ImmediateUpdate(), m_LastTick, SendRPC(), and VIRTUAL_HUD_UPDATE_INTERVAL.

◆ PrintElements()

void PrintElements ( )

Definition at line 155 of file DisplayStatus.c.

156 {
157 for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
158 PrintString(i.ToString() + ": " + GetElement(i).m_Value.ToString());
159 }
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344
string m_Value
Definition EnEntity.c:805
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.

References GetElement(), m_Value, NUMBER_OF_ELEMENTS, PrintString(), and string::ToString().

◆ RegisterElement()

void RegisterElement ( DisplayElementBase element)

Definition at line 86 of file DisplayStatus.c.

87 {
88 int id = element.GetType();
90 //Log("adding element:"+id.ToString());
91 }

References m_Elements.

Referenced by VirtualHud().

◆ SendRPC()

void SendRPC ( )

Definition at line 161 of file DisplayStatus.c.

162 {
166 {
167 ScriptRPC rpc = new ScriptRPC();
168 rpc.Write(mask_array);
169 rpc.Send(m_Player, ERPCs.RPC_SYNC_DISPLAY_STATUS, false, m_Player.GetIdentity());
171 }
172 }
PlayerBase m_Player
void SerializeElements(ref array< int > mask_array)
ref array< int > m_LastSentArray
bool AreArraysSame(notnull array< int > array_a, notnull array< int > array_b)
ERPCs
Definition ERPCs.c:2

References AreArraysSame(), m_LastSentArray, m_Player, and SerializeElements().

Referenced by ScriptConsoleWeatherTab::InvokeSendRPC(), ScriptConsoleWeatherTab::OnClick(), ActionEmptyBottleBase::OnEndAnimationLoop(), ActionEmptyBottleBase::OnEndServer(), OnScheduledTick(), ActionEmptyBottleBase::OnStartAnimationLoop(), and Tick().

◆ SerializeElements()

void SerializeElements ( ref array< int > mask_array)

Definition at line 101 of file DisplayStatus.c.

102 {
103 int offset = 0;
104 int mask = 0;
105
106 for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
107 {
108 if (GetElement(i) && !GetElement(i).IsClientOnly())
109 {
110 if ((GetElement(i).GetNumberOfBits() + offset) > BIT_INT_SIZE)
111 {
112 mask_array.Insert(mask);
113 offset = 0;
114 mask = 0;
115 }
116 mask = mask | (GetElement(i).GetValue() << offset);
117 offset = offset + GetElement(i).GetNumberOfBits();
118 }
119 }
120 mask_array.Insert(mask);
121 }

References BIT_INT_SIZE, GetElement(), and NUMBER_OF_ELEMENTS.

Referenced by SendRPC().

◆ UpdateStatus()

void UpdateStatus ( )

Definition at line 195 of file DisplayStatus.c.

196 {
197 //Log("UpdateStatus called for entity: "+ToString(m_Player));
198 for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
199 {
201 if (element && !element.IsClientOnly() && element.IsValueChanged())
202 element.UpdateHUD();
203 }
204 }

References GetElement(), and NUMBER_OF_ELEMENTS.

Referenced by OnRPC().

◆ VirtualHud()

void VirtualHud ( PlayerBase player)

Definition at line 36 of file DisplayStatus.c.

37 {
39 m_LastTick = 0;
40
41 RegisterElement(new BadgeStuffed(m_Player));
42 RegisterElement(new BadgeWet(m_Player));
43 RegisterElement(new BadgeSick(m_Player));
44 RegisterElement(new BadgePills(m_Player));
45 RegisterElement(new BadgePoisoned(m_Player));
46 RegisterElement(new BadgeFracture(m_Player));
47 RegisterElement(new TendencyHealth(m_Player));
48 RegisterElement(new TendencyBlood(m_Player));
49 RegisterElement(new TendencyTemperature(m_Player));
50
51 RegisterElement(new TendencyHunger(m_Player));
52 RegisterElement(new TendencyThirst(m_Player));
53 RegisterElement(new TendencyBacteria(m_Player));
54 RegisterElement(new BadgeHeartbeat(m_Player));
55 RegisterElement(new BadgeLegs(m_Player));
56
57
58 RegisterElement(new ElementStance(m_Player));// client only
59 RegisterElement(new BadgeBleeding(m_Player));// client only
60
61
62 mission = GetGame().GetMission();
63 if (mission)
65 //UpdateStatus();
66 }
void RegisterElement(DisplayElementBase element)
Hud m_Hud
Mission mission
Hud GetHud()
Definition gameplay.c:701

References GetGame(), Mission::GetHud(), m_Hud, m_LastTick, m_Player, mission, and RegisterElement().

Referenced by ManBase::GetVirtualHud(), ManBase::Init(), and ManBase::OnPlayerLoaded().

Variable Documentation

◆ BLINKING_MINUS

enum DSLevels BLINKING_MINUS = 3

◆ BLINKING_PLUS

enum DSLevels BLINKING_PLUS = 6

◆ CRITICAL_MINUS

enum DSLevels CRITICAL_MINUS = 2

◆ CRITICAL_PLUS

enum DSLevels CRITICAL_PLUS = 5

◆ m_Elements

Definition at line 27 of file DisplayStatus.c.

Referenced by GetElement(), and RegisterElement().

◆ m_Hud

◆ m_LastSentArray

ref array<int> m_LastSentArray

Definition at line 24 of file DisplayStatus.c.

Referenced by SendRPC().

◆ m_LastTick

int m_LastTick

Definition at line 30 of file DisplayStatus.c.

Referenced by OnScheduledTick(), ManBase::OnTick(), and VirtualHud().

◆ m_Player

PlayerBase m_Player

Definition at line 31 of file DisplayStatus.c.

◆ m_System

string m_System = "VirtualHud"

Definition at line 32 of file DisplayStatus.c.

◆ mission

◆ NORMAL

@ NORMAL = 0

Definition at line 3 of file DisplayStatus.c.

◆ NUMBER_OF_ELEMENTS

◆ NUMBER_OF_MASKS

enum DSLevels NUMBER_OF_MASKS = 2

◆ rpcParams

ref array<ref Param> rpcParams

Definition at line 34 of file DisplayStatus.c.

◆ WARNING_MINUS

enum DSLevels WARNING_MINUS = 1

◆ WARNING_PLUS

enum DSLevels WARNING_PLUS = 4