DayZ 1.24
Loading...
Searching...
No Matches
PlayerAgentPool Class Reference
Collaboration diagram for PlayerAgentPool:
[legend]

Private Member Functions

void PlayerAgentPool (PlayerBase player)
 
void ~PlayerAgentPool ()
 
int GetStorageVersion ()
 
void PrintAgents ()
 
void ImmuneSystemTick (float value, float deltaT)
 
void GrowAgents (float deltaT)
 
void OnStoreSave (ParamsWriteContext ctx)
 
bool OnStoreLoad (ParamsReadContext ctx, int version)
 
void DigestAgent (int agent_id, float count)
 
void AddAgent (int agent_id, float count)
 
void RemoveAgent (int agent_id)
 
void RemoveAllAgents ()
 
int GetAgents ()
 
int GetSingleAgentCount (int agent_id)
 
float GetTotalAgentCount ()
 
void SpawnAgents (float deltaT)
 
void SetAgentCount (int agent_id, float count)
 
void AntibioticsAttack (float attack_value)
 
void RemoteGrowRequestDebug (ParamsReadContext ctx)
 
void GetDebugObject (array< ref Param > object_out)
 

Private Attributes

ref map< int, floatm_VirusPool = new map<int, float>
 
ref array< intm_VirusPoolArray = new array<int>
 
float m_LastTicked = 0
 
float m_TotalAgentCount
 
PlayerBase m_Player
 
int m_AgentMask
 
const int STORAGE_VERSION = 100
 
PluginTransmissionAgents m_PluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents))
 

Detailed Description

Definition at line 1 of file PlayerAgentPool.c.

Constructor & Destructor Documentation

◆ PlayerAgentPool()

void PlayerAgentPool::PlayerAgentPool ( PlayerBase player)
inlineprivate

Definition at line 14 of file PlayerAgentPool.c.

15 {
17 }
PlayerBase m_Player

References m_Player.

◆ ~PlayerAgentPool()

void PlayerAgentPool::~PlayerAgentPool ( )
inlineprivate

Definition at line 19 of file PlayerAgentPool.c.

20 {
21
22 }

Member Function Documentation

◆ AddAgent()

void PlayerAgentPool::AddAgent ( int agent_id,
float count )
inlineprivate

Definition at line 133 of file PlayerAgentPool.c.

134 {
135 int max_count = m_PluginTransmissionAgents.GetAgentMaxCount(agent_id);
136
137 if (!m_VirusPool.Contains(agent_id) && count > 0) //if it contains, maybe add count only ?
138 {
139 //m_VirusPool.Insert( agent_id, Math.Clamp(count,0,max_count) );
141 }
142 else
143 {
144 float new_value = m_VirusPool.Get(agent_id) + count;
145 //Print(new_value);
147 }
148 }
ref map< int, float > m_VirusPool
PluginTransmissionAgents m_PluginTransmissionAgents
void SetAgentCount(int agent_id, float count)

References m_PluginTransmissionAgents, m_VirusPool, and SetAgentCount().

Referenced by DigestAgent(), RemoteGrowRequestDebug(), and SpawnAgents().

◆ AntibioticsAttack()

void PlayerAgentPool::AntibioticsAttack ( float attack_value)
inlineprivate

Definition at line 239 of file PlayerAgentPool.c.

240 {
241 for (int i = 0; i < m_VirusPool.Count(); i++)
242 {
243 int agent_id = m_VirusPool.GetKey(i);
244 float antibiotics_resistance = 1 - m_PluginTransmissionAgents.GetAgentAntiboticsResistanceEx(agent_id, m_Player);
246 float old_count = m_VirusPool.Get(agent_id);
247 float new_count = old_count - delta;
248 //PrintString("delta:"+delta.ToString());
249 //PrintString("old_count:"+old_count.ToString());
250 //PrintString("new_count:"+new_count.ToString());
252 }
253 }

References m_Player, m_PluginTransmissionAgents, m_VirusPool, and SetAgentCount().

◆ DigestAgent()

void PlayerAgentPool::DigestAgent ( int agent_id,
float count )
inlineprivate

Definition at line 128 of file PlayerAgentPool.c.

129 {
130 AddAgent(agent_id, m_PluginTransmissionAgents.GetAgentDigestibility(agent_id) * count);
131 }
void AddAgent(int agent_id, float count)

References AddAgent(), and m_PluginTransmissionAgents.

◆ GetAgents()

int PlayerAgentPool::GetAgents ( )
inlineprivate

Definition at line 184 of file PlayerAgentPool.c.

185 {
186 return m_AgentMask;
187 }

References m_AgentMask.

◆ GetDebugObject()

void PlayerAgentPool::GetDebugObject ( array< ref Param > object_out)
inlineprivate

Definition at line 268 of file PlayerAgentPool.c.

269 {
270 int count = m_PluginTransmissionAgents.GetAgentList().Count();
271 for (int i = 0; i < count; i++)
272 {
273 AgentBase agent = m_PluginTransmissionAgents.GetAgentList().GetElement(i);
274 string agent_name = agent.GetName();
275 int agent_id = agent.GetAgentType();
276 int max_agents = m_PluginTransmissionAgents.GetAgentMaxCount(agent_id);
277 string amount = GetSingleAgentCount(agent_id).ToString() + "/" + max_agents.ToString();
279 }
280 object_out.InsertAt(new Param1<int>(count), 0);
281 }
int GetSingleAgentCount(int agent_id)

References GetSingleAgentCount(), and m_PluginTransmissionAgents.

◆ GetSingleAgentCount()

int PlayerAgentPool::GetSingleAgentCount ( int agent_id)
inlineprivate

Definition at line 189 of file PlayerAgentPool.c.

190 {
191 if (m_VirusPool.Contains(agent_id))
192 return m_VirusPool.Get(agent_id);
193 else return 0;
194 }

References m_VirusPool.

Referenced by GetDebugObject(), and SpawnAgents().

◆ GetStorageVersion()

int PlayerAgentPool::GetStorageVersion ( )
inlineprivate

Definition at line 24 of file PlayerAgentPool.c.

25 {
26 return STORAGE_VERSION;
27 }
const int STORAGE_VERSION

References STORAGE_VERSION.

◆ GetTotalAgentCount()

float PlayerAgentPool::GetTotalAgentCount ( )
inlineprivate

Definition at line 196 of file PlayerAgentPool.c.

197 {
198 float agent_count;
199 for (int i = 0; i < m_VirusPool.Count(); i++)
200 agent_count += m_VirusPool.GetElement(i);
201 return agent_count;
202 }

References m_VirusPool.

◆ GrowAgents()

void PlayerAgentPool::GrowAgents ( float deltaT)
inlineprivate

Definition at line 48 of file PlayerAgentPool.c.

49 {
50 if (!IsPluginManagerExists()) //check if modules are running
51 return;
52
53 EStatLevels immunity_level = m_Player.GetImmunityLevel();
54
56 for (int i = 0; i < m_VirusPool.Count(); i++)
57 {
58 int agent_id = m_VirusPool.GetKey(i);
59 int max_count = m_PluginTransmissionAgents.GetAgentMaxCount(agent_id);
60
62
63 float grow_delta;
64
66 {
67 bool grow_during_antibiotics = m_PluginTransmissionAgents.GrowDuringAntibioticsAttack(agent_id, m_Player);
68 if (m_Player.IsAntibioticsActive() && !grow_during_antibiotics)
69 continue;
70 float invasibility = m_PluginTransmissionAgents.GetAgentInvasibilityEx(agent_id, m_Player);
72 }
73 else
74 {
75 float dieoff_speed = m_PluginTransmissionAgents.GetAgentDieOffSpeedEx(agent_id, m_Player);
77 }
78
79 //Print( agent_id );
80 //Print( grow_delta );
81
82 float old_count = m_VirusPool.Get(agent_id);
85
88 }
89 }
EStatLevels
Definition EStatLevels.c:2
bool IsPluginManagerExists()
Definition EnMath.c:7
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References Math::Clamp(), IsPluginManagerExists(), m_Player, m_PluginTransmissionAgents, m_TotalAgentCount, m_VirusPool, and SetAgentCount().

Referenced by ImmuneSystemTick().

◆ ImmuneSystemTick()

void PlayerAgentPool::ImmuneSystemTick ( float value,
float deltaT )
inlineprivate

Definition at line 42 of file PlayerAgentPool.c.

43 {
46 }
void SpawnAgents(float deltaT)
void GrowAgents(float deltaT)

References GrowAgents(), and SpawnAgents().

◆ OnStoreLoad()

bool PlayerAgentPool::OnStoreLoad ( ParamsReadContext ctx,
int version )
inlineprivate

Definition at line 105 of file PlayerAgentPool.c.

106 {
107 //Debug.Log("PlayerAgentPool OnStoreLoad called", "Agents");
108 int count;
109
110 if (!ctx.Read(count))
111 return false;
112
113 for (int i = 0; i < count; i++)
114 {
115 int key;
116 int value;
117 if (!ctx.Read(key))
118 return false;
119
120 if (!ctx.Read(value))
121 return false;
122
124 }
125
126 return true;
127 }

References SetAgentCount().

◆ OnStoreSave()

void PlayerAgentPool::OnStoreSave ( ParamsWriteContext ctx)
inlineprivate

Definition at line 91 of file PlayerAgentPool.c.

92 {
93 //Debug.Log("PlayerAgentPool OnStoreSave called", "Agents");
94
95 ctx.Write(m_VirusPool.Count());
96 for (int i = 0; i < m_VirusPool.Count(); i++)
97 {
98 int key = m_VirusPool.GetKey(i);
99 int value = m_VirusPool.GetElement(i);
100 ctx.Write(key);
101 ctx.Write(value);
102 }
103 }

References m_VirusPool.

◆ PrintAgents()

void PlayerAgentPool::PrintAgents ( )
inlineprivate

Definition at line 29 of file PlayerAgentPool.c.

30 {
31 if (m_VirusPool)
32 {
33 for (int i = 0; i < m_VirusPool.Count(); i++)
34 {
35 Debug.Log("Agent: " + m_VirusPool.GetKey(i).ToString(), "Agents");
36 Debug.Log("Count: " + m_VirusPool.GetElement(i).ToString(), "Agents");
37 }
38
39 }
40 }
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133

References Debug::Log(), and m_VirusPool.

◆ RemoteGrowRequestDebug()

void PlayerAgentPool::RemoteGrowRequestDebug ( ParamsReadContext ctx)
inlineprivate

Definition at line 256 of file PlayerAgentPool.c.

257 {
259 int id = CachedObjectsParams.PARAM1_INT.param1;
260 int max = m_PluginTransmissionAgents.GetAgentMaxCount(Math.AbsInt(id));
261 int grow = max / 10;
262 if (id > 0)
263 AddAgent(id, grow);
264 else if (id < 0)
265 AddAgent(-id, -grow);
266 }
static ref Param1< int > PARAM1_INT
static proto int AbsInt(int i)
Returns absolute value.

References Math::AbsInt(), AddAgent(), m_PluginTransmissionAgents, and CachedObjectsParams::PARAM1_INT.

◆ RemoveAgent()

void PlayerAgentPool::RemoveAgent ( int agent_id)
inlineprivate

Definition at line 159 of file PlayerAgentPool.c.

160 {
162 }

References SetAgentCount().

◆ RemoveAllAgents()

void PlayerAgentPool::RemoveAllAgents ( )
inlineprivate

Definition at line 164 of file PlayerAgentPool.c.

165 {
166 m_AgentMask = 0;
167 m_VirusPool.Clear();
168 }

References m_AgentMask, and m_VirusPool.

◆ SetAgentCount()

void PlayerAgentPool::SetAgentCount ( int agent_id,
float count )
inlineprivate

Definition at line 218 of file PlayerAgentPool.c.

219 {
220 if (count > 0)
221 {
222 //Debug.Log("+ growing agent"+ agent_id.ToString() +"to count: "+count.ToString(), "Agents");
225 }
226 else
227 {
228 //Debug.Log("- REMOVING agent"+ agent_id.ToString(), "Agents");
229 m_VirusPool.Remove(agent_id);
231 }
232 if (m_Player.m_Agents != m_AgentMask)
233 {
234 m_Player.m_Agents = m_AgentMask;
235 m_Player.SetSynchDirty();
236 }
237 }

References m_AgentMask, m_Player, and m_VirusPool.

Referenced by AddAgent(), AntibioticsAttack(), GrowAgents(), OnStoreLoad(), and RemoveAgent().

◆ SpawnAgents()

void PlayerAgentPool::SpawnAgents ( float deltaT)
inlineprivate

Definition at line 204 of file PlayerAgentPool.c.

205 {
206 int count = m_PluginTransmissionAgents.GetAgentList().Count();
207 for (int i = 0; i < count; i++)
208 {
209 AgentBase agent = m_PluginTransmissionAgents.GetAgentList().GetElement(i);
210 int agent_id = agent.GetAgentType();
211
212 if (GetSingleAgentCount(agent_id) == 0 && agent.AutoinfectCheck(deltaT, m_Player))
213 AddAgent(agent_id, 100);
214 }
215 }

References AddAgent(), GetSingleAgentCount(), m_Player, and m_PluginTransmissionAgents.

Referenced by ImmuneSystemTick().

Member Data Documentation

◆ m_AgentMask

int PlayerAgentPool::m_AgentMask
private

Definition at line 8 of file PlayerAgentPool.c.

Referenced by GetAgents(), RemoveAllAgents(), and SetAgentCount().

◆ m_LastTicked

float PlayerAgentPool::m_LastTicked = 0
private

Definition at line 5 of file PlayerAgentPool.c.

◆ m_Player

PlayerBase PlayerAgentPool::m_Player
private

◆ m_PluginTransmissionAgents

PluginTransmissionAgents PlayerAgentPool::m_PluginTransmissionAgents = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents))
private

◆ m_TotalAgentCount

float PlayerAgentPool::m_TotalAgentCount
private

Definition at line 6 of file PlayerAgentPool.c.

Referenced by GrowAgents().

◆ m_VirusPool

◆ m_VirusPoolArray

ref array<int> PlayerAgentPool::m_VirusPoolArray = new array<int>
private

Definition at line 4 of file PlayerAgentPool.c.

◆ STORAGE_VERSION

const int PlayerAgentPool::STORAGE_VERSION = 100
private

Definition at line 10 of file PlayerAgentPool.c.

Referenced by GetStorageVersion().


The documentation for this class was generated from the following file: