DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AlarmClock.c
См. документацию.
2{
3 const string RINGING_SOUND = "AlarmClock_Ring_Loop_SoundSet";
4 const string TURN_TOGGLE_SOUND = "AlarmClock_Turn_Off_SoundSet";
5 const string DESTROYED_SOUND = "AlarmClock_Destroyed_SoundSet";
6 const string HIT_SOUND = "AlarmClock_Hit_SoundSet";
7
8
11
12 override void Init()
13 {
14 super.Init();
15 if ( g_Game.IsServer() )
16 {
17 m_NoiseSystem = g_Game.GetNoiseSystem();
18 if ( m_NoiseSystem && !m_NoisePar )
19 {
20 // Create and load noise parameters
22 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseAlarmClock");
23 }
24 }
25 }
26
28 {
29 #ifndef SERVER
30 #ifndef NO_GUI
32 #endif
33 #endif
34 }
35
36
37 override void SetActions()
38 {
39 super.SetActions();
40
44 }
45
46 override string GetToggleSound()
47 {
48 return TURN_TOGGLE_SOUND;
49 }
50
51 override string GetRingingSound()
52 {
53 return RINGING_SOUND;
54 }
55
56 override string GetDestroyedSound()
57 {
58 return DESTROYED_SOUND;
59 }
60
61 override string GetHitSound()
62 {
63 return HIT_SOUND;
64 }
65
67 {
68 return "TriggerAlarmClock";
69 }
70
71 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
72 {
73 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "SetAlarmAhead1Min", FadeColors.LIGHT_GREY));
74 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
75
76 super.GetDebugActions(outputList);
77 }
78
79 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
80 {
81 if (super.OnAction(action_id, player, ctx))
82 return true;
83 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
84 {
85 if (action_id == EActions.ACTIVATE_ENTITY)
86 {
88 }
89
90 }
91 return false;
92 }
93
94 override string GetDebugText()
95 {
96 string debug_output;
97
98 if( g_Game.IsDedicatedServer())
99 {
100 debug_output = "alarm in: " + GetAlarmInMin().ToString() + " mins" + "\n";
101 debug_output += "current state: " + typename.EnumToString(EAlarmClockState, m_State) + "\n";;
102 debug_output += "ringing for " + m_RingingDuration.ToString()+ " secs" + "\n";
103 debug_output += "ringing max " + GetRingingDurationMax().ToString()+ " secs" + "\n";
104 }
105 else
106 {
107 debug_output = "this is client";
108 }
109 return debug_output;
110 }
111
112 void OnUpdate()
113 {
114 if ( IsAlarmOn() )
115 {
116 //due to variable server time flow(day-night time accel), it's not possible to simply set a timer for X secs without some convoluted math/code, so we need to check at regular intervals
117 int alarm_hand_in_minutes = ConvertAlarmHand01ToMins12h(m_AlarmTime01);
118
119 int pass, hour, minute;
120 g_Game.GetWorld().GetDate(pass, pass, pass, hour, minute);
121
122 int curr_time_in_minutes = ConvertTimeToMins12h(hour, minute);
123
124 //Print(GetAlarmInMin());
125
126 if ( alarm_hand_in_minutes == curr_time_in_minutes )
127 {
129 }
130 }
131
132 if ( IsRinging())
133 {
135
137 {
138 TurnOff();
139 }
140 else if ( m_NoiseSystem )
141 {
143 }
144 }
145 }
146
147 protected void AnimateAlarmHand(float value)
148 {
149 SetAnimationPhaseNow("ClockAlarm", value);
150 }
151
152
153 override bool OnStoreLoad( ParamsReadContext ctx, int version )
154 {
155 if (!super.OnStoreLoad(ctx, version))
156 return false;
157
158 if (version < 126)
159 {
160 return true;
161 }
162
163 EAlarmClockState state;
164
165 if ( !ctx.Read( state ) )
166 {
167 return false;
168 }
169
170 float time;
171
172 if ( !ctx.Read( time ) )
173 {
174 return false;
175 }
176
177 SetAlarmTimeServer(time);
178 SetState(state);
179 if ( state == EAlarmClockState.SET )
180 {
181 TurnOn();
182 }
183 else if (state == EAlarmClockState.RINGING )
184 {
186 }
187
188 return true;
189 }
190
192 {
193 super.OnStoreSave(ctx);
194
195 ctx.Write(m_State);
196 ctx.Write(m_AlarmTime01);
197 }
198
199 override void OnDebugSpawn()
200 {
201 TurnOn();
203 }
204
205};
206
Param4< int, int, string, int > TSelectableActionInfoWithColor
eBleedingSourceType GetType()
ActionTurnOffAlarmClockCB ActionSingleUseBaseCB ActionTurnOffAlarmClock()
Определения ActionTurnOffAlarmClock.c:11
ActionTurnOnAlarmClockCB ActionSingleUseBaseCB ActionTurnOnAlarmClock()
Определения ActionTurnOnAlarmClock.c:11
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
enum EAlarmClockState m_AlarmTime01
void TurnOff()
Определения ClockBase.c:306
bool IsRinging()
Определения ClockBase.c:291
void OnRingingStopClient()
Определения ClockBase.c:166
void ClockBase()
Определения ClockBase.c:27
bool IsAlarmOn()
Определения ClockBase.c:296
void SetAlarmInXMins(int in_mins)
Определения ClockBase.c:171
float m_RingingDuration
Определения ClockBase.c:16
void TurnOn()
Определения ClockBase.c:301
int GetAlarmInMin()
Определения ClockBase.c:53
EAlarmClockState
Определения ClockBase.c:2
static int ConvertAlarmHand01ToMins12h(float time01)
Определения ClockBase.c:65
float GetRingingDurationMax()
Определения ClockBase.c:181
static const float UPDATE_TICK_RATE
Определения ClockBase.c:14
void MakeRingingStart()
Определения ClockBase.c:223
void SetAlarmTimeServer(float time01)
Определения ClockBase.c:320
static int ConvertTimeToMins12h(int hour, int minute)
Определения ClockBase.c:81
DayZGame g_Game
Определения DayZGame.c:4074
EActions
Определения EActions.c:2
class NoiseSystem NoiseParams()
Определения Noise.c:18
enum EObjectTemperatureState m_State
void SetState(bool state)
Определения StaminaHandler.c:32
Определения AlarmClock.c:208
void AnimateAlarmHand(float value)
Определения AlarmClock.c:147
const string RINGING_SOUND
Определения AlarmClock.c:3
override string GetHitSound()
Определения AlarmClock.c:61
override void OnStoreSave(ParamsWriteContext ctx)
Определения AlarmClock.c:191
const string TURN_TOGGLE_SOUND
Определения AlarmClock.c:4
override string GetDestroyedSound()
Определения AlarmClock.c:56
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения AlarmClock.c:153
override string GetDebugText()
Определения AlarmClock.c:94
override void OnDebugSpawn()
Определения AlarmClock.c:199
const string DESTROYED_SOUND
Определения AlarmClock.c:5
void OnUpdate()
Определения AlarmClock.c:112
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения AlarmClock.c:79
static ref NoiseParams m_NoisePar
Определения AlarmClock.c:9
override string GetToggleSound()
Определения AlarmClock.c:46
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения AlarmClock.c:71
override string GetRingingSound()
Определения AlarmClock.c:51
void ~AlarmClock_ColorBase()
Определения AlarmClock.c:27
override string GetExplosiveTriggerSlotName()
Определения AlarmClock.c:66
static NoiseSystem m_NoiseSystem
Определения AlarmClock.c:10
override void SetActions()
Определения AlarmClock.c:37
const string HIT_SOUND
Определения AlarmClock.c:6
override void Init()
Определения AlarmClock.c:12
Определения AlarmClock.c:2
Определения AlarmClock.c:209
Определения AlarmClock.c:207
Определения Noise.c:2
proto bool Write(void value_out)
proto bool Read(void value_in)
proto string ToString(bool simple=true)
Serializer ParamsReadContext
Определения gameplay.c:15
Serializer ParamsWriteContext
Определения gameplay.c:16
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.