DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PowerGeneratorStatic.c
См. документацию.
1class PowerGeneratorStatic : PowerGeneratorBase
2{
3 const int SWITCH_COUNT = 6;
4 const int LOW_ENERGY_PERCENT = 5;
5
6 protected static ref set<PowerGeneratorStatic> m_PowerGenerators = new set<PowerGeneratorStatic>();
8
9 protected int m_ParentID1;
10 protected int m_ParentID2;
11 protected int m_ParentID3;
12 protected int m_ParentID4;
13
14 protected int m_LeverStatesBits;
15
20
25
27 {
28 m_PowerGenerators.Insert(obj);
29 }
30
32 {
34 return;
35 int index = m_PowerGenerators.Find(obj);
36 if (index != -1)
37 {
38 m_PowerGenerators.Remove(index);
39 }
40 }
41
42 static PowerGeneratorStatic GetClosestGenerator(vector position, float tolerance)
43 {
44 float toleranceSq = tolerance * tolerance;
45 float smallestDist = float.MAX;
47
49 {
50 float distSq = vector.DistanceSq(position,obj.GetPosition());
51 if (distSq < toleranceSq)
52 {
53 return obj;
54 }
55 }
56 return null;
57 }
58
60 {
61 m_Parent = parent;
62 }
63
64 // States saved thorugh the generator entity since it doesnt work when done building side
65 void StoreLeverStates(int leverStateBits)
66 {
67 m_LeverStatesBits = leverStateBits;
68 }
69
71 {
72 return m_LeverStatesBits;
73 }
74
75 // Generator is working
76 override void OnWorkStart()
77 {
78 super.OnWorkStart();
79 if (m_Parent)
80 {
81 m_Parent.OnGeneratorStart();
82 }
83
84 if (!GetGame().IsServer())
85 return;
86
87 for (int i = 1; i <= SWITCH_COUNT; i++)
88 {
89 SetAnimationPhase("Switch" + i.ToString(), 1);
90 }
91 }
92
93 // Turn off when this runs out of fuel
94 override void OnWorkStop()
95 {
96 super.OnWorkStop();
97 if (m_Parent)
98 {
99 m_Parent.OnGeneratorStop();
100 }
101
102 if (!GetGame().IsServer())
103 return;
104
105 for (int i = 1; i <= SWITCH_COUNT; i++)
106 {
107 SetAnimationPhase("Switch" + i.ToString(), 0);
108 }
109 }
110
111 override void SetLowEnergyState(bool state)
112 {
113 super.SetLowEnergyState(state);
114
115 if (GetGame().IsServer())
116 {
117 Land_WarheadStorage_Main bunker = m_Parent.GetClosestBunker();
118 if (bunker)
119 bunker.SetLowEnergyStateServer(state);
120 }
121 }
122
124 {
125 return "1.1 1.1 -1.1";
126 }
127
129 {
130 return "90 0 23";
131 }
132
133 // Checks sparkplug
134 override bool HasSparkplug()
135 {
136 int slot = InventorySlots.GetSlotIdFromString("GlowPlug");
137 EntityAI ent = GetInventory().FindAttachment(slot);
138
139 return ent && !ent.IsRuined();
140 }
141
142 // Taking item into inventory
143 override bool CanPutInCargo( EntityAI parent )
144 {
145 return false;
146 }
147
148 // Taking item into inventory
149 override bool CanPutIntoHands(EntityAI parent)
150 {
151 return false;
152 }
153
155 {
156 super.OnStoreSave(ctx);
157
158 if (m_Parent)
160
161 ctx.Write(m_ParentID1);
162 ctx.Write(m_ParentID2);
163 ctx.Write(m_ParentID3);
164 ctx.Write(m_ParentID4);
165
167 }
168
169 override bool OnStoreLoad( ParamsReadContext ctx, int version )
170 {
171 if ( !super.OnStoreLoad( ctx, version ) )
172 return false;
173
174 if ( !ctx.Read(m_ParentID1))
175 {
176 return false;
177 }
178 if ( !ctx.Read(m_ParentID2))
179 {
180 return false;
181 }
182 if ( !ctx.Read(m_ParentID3))
183 {
184 return false;
185 }
186 if ( !ctx.Read( m_ParentID4))
187 {
188 return false;
189 }
190
191 if (version >= 141 && !ctx.Read(m_LeverStatesBits) )
192 return false;
193
194 return true;
195 }
196
197 override void EEOnAfterLoad()
198 {
199 // Does this part actually do anything?
201 if (powerStation)
202 {
203 PowerGeneratorStatic otherGenerator = powerStation.GetPowerGenerator();
204 if (otherGenerator)
205 {
206 otherGenerator.SetFuel(GetFuel());
207 Delete();
208 }
209 }
210 }
211
212 override bool CanReleaseAttachment(EntityAI attachment)
213 {
214 if (!super.CanReleaseAttachment(attachment))
215 return false;
216 return !GetCompEM().IsWorking();
217 }
218
219 override bool IsTakeable()
220 {
221 return false;
222 }
223
224 override bool IsActionTargetVisible()
225 {
226 return true;
227 }
228
229 override bool DisableVicinityIcon()
230 {
231 return true;
232 }
233
234 // DEPRECATED
235
236 void SetLowEnergyStateServer(bool state);
237}
Определения Building.c:6
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
provides access to slot configuration
Определения InventorySlots.c:6
void SetLowEnergyStateServer(bool state)
Определения Land_WarheadStorage_Main.c:90
PowerGeneratorStatic GetPowerGenerator()
Land_WarheadStorage_PowerStation m_Parent
Определения PowerGeneratorStatic.c:7
void SetLowEnergyStateServer(bool state)
override bool CanPutIntoHands(EntityAI parent)
Определения PowerGeneratorStatic.c:149
override bool DisableVicinityIcon()
Определения PowerGeneratorStatic.c:229
static void RegisterPersistentObject(PowerGeneratorStatic obj)
Определения PowerGeneratorStatic.c:26
void SetParent(Land_WarheadStorage_PowerStation parent)
Определения PowerGeneratorStatic.c:59
static void UnregisterPersistentObject(PowerGeneratorStatic obj)
Определения PowerGeneratorStatic.c:31
override bool HasSparkplug()
Определения PowerGeneratorStatic.c:134
const int SWITCH_COUNT
Определения PowerGeneratorStatic.c:3
void ~PowerGeneratorStatic()
Определения PowerGeneratorStatic.c:21
override void EEOnAfterLoad()
Определения PowerGeneratorStatic.c:197
override vector GetSmokeParticleOrientation()
Определения PowerGeneratorStatic.c:128
void PowerGeneratorStatic()
Определения PowerGeneratorStatic.c:16
override void OnStoreSave(ParamsWriteContext ctx)
Определения PowerGeneratorStatic.c:154
int m_LeverStatesBits
Определения PowerGeneratorStatic.c:14
override void OnWorkStart()
Определения PowerGeneratorStatic.c:76
static ref set< PowerGeneratorStatic > m_PowerGenerators
Определения PowerGeneratorStatic.c:6
override bool CanPutInCargo(EntityAI parent)
Определения PowerGeneratorStatic.c:143
override bool IsTakeable()
Определения PowerGeneratorStatic.c:219
static PowerGeneratorStatic GetClosestGenerator(vector position, float tolerance)
Определения PowerGeneratorStatic.c:42
void StoreLeverStates(int leverStateBits)
Определения PowerGeneratorStatic.c:65
override bool IsActionTargetVisible()
Определения PowerGeneratorStatic.c:224
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения PowerGeneratorStatic.c:169
override bool CanReleaseAttachment(EntityAI attachment)
Определения PowerGeneratorStatic.c:212
int GetStoredLeverBits()
Определения PowerGeneratorStatic.c:70
const int LOW_ENERGY_PERCENT
Определения PowerGeneratorStatic.c:4
override vector GetSmokeParticlePosition()
Определения PowerGeneratorStatic.c:123
int m_ParentID1
Определения PowerGeneratorStatic.c:9
override void OnWorkStop()
Определения PowerGeneratorStatic.c:94
override void SetLowEnergyState(bool state)
Определения PowerGeneratorStatic.c:111
proto bool Write(void value_out)
proto bool Read(void value_in)
const float MAX
Определения EnConvert.c:99
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16