<?xml version="1.0" encoding="utf-8" ?>
<c2eventsheet>
    <!--All the 'name' attributes are ignored by Construct 2 - they are there for readability only.-->
    <name>loop es</name>
    <events>
        <event-group description="" sid="297739293308256" title="game loop">
            <sub-events>
                <event-block sid="609134117659195">
                    <conditions>
                        <condition id="-2" name="On start of layout" sid="415401497765033" type="System" />
                    </conditions>
                    <actions>
                        <action id="1" name="Set size" sid="151484114332324" type="arrLoopTimerCount">
                            <param id="0" name="Width">0</param>
                            <param id="1" name="Height">4</param>
                            <param id="2" name="Depth">1</param>
                        </action>
                        <action id="1" name="Set size" sid="322782163300805" type="repeat">
                            <param id="0" name="Width">0</param>
                            <param id="1" name="Height">1</param>
                            <param id="2" name="Depth">1</param>
                        </action>
                        <action id="-9" name="Destroy" sid="534723759428219" type="param" />
                    </actions>
                </event-block>
                <comment>loop for something need to update emergency</comment>
                <comment>non stop repeat</comment>
                <event-group description="" sid="316514301404713" title="game loop every tick">
                    <sub-events>
                        <event-block sid="495806989672790">
                            <conditions>
                                <condition id="-1" name="Every tick" sid="132345942283965" type="System" />
                            </conditions>
                            <actions />
                            <sub-events>
                                <event-block sid="645314890213354">
                                    <conditions>
                                        <condition id="3" name="For each element" sid="390636540839414" type="repeat">
                                            <param id="0" name="Axes">2</param>
                                        </condition>
                                    </conditions>
                                    <actions />
                                    <sub-events>
                                        <event-block sid="697768775943074">
                                            <conditions />
                                            <actions>
                                                <action id="0" name="Call function" sid="522196112958523" type="Function">
                                                    <param id="0" name="Name">repeat.At(repeat.CurX)</param>
                                                    <param id="1" name="Parameter {n}"></param>
                                                </action>
                                            </actions>
                                        </event-block>
                                    </sub-events>
                                </event-block>
                                <event-block sid="158700230967809">
                                    <conditions>
                                        <condition id="-14" name="Compare variable" sid="121611838054860" type="System">
                                            <param id="0" name="Variable">gameStatus</param>
                                            <param id="1" name="Comparison">0</param>
                                            <param id="2" name="Value">STATUS_PLAYING</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="0" name="Call function" sid="176475866533748" type="Function">
                                            <param id="0" name="Name">&quot;time update&quot;</param>
                                            <param id="1" name="Parameter {n}"></param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <event-block sid="200042726220492">
                            <conditions>
                                <condition id="0" name="On function" sid="471568821219629" type="Function">
                                    <param id="0" name="Name">&quot;add to repeat&quot;</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <event-block sid="583399594624884">
                                    <conditions />
                                    <actions>
                                        <action id="5" name="Push" sid="551939522123137" type="repeat">
                                            <param id="0" name="Where">0</param>
                                            <param id="1" name="Value">Function.Param(0)</param>
                                            <param id="2" name="Axis">0</param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <event-block sid="354442986136648">
                            <conditions>
                                <condition id="0" name="On function" sid="280450763858492" type="Function">
                                    <param id="0" name="Name">&quot;remove from repeat&quot;</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <variable constant="0" name="index" sid="863135525995548" static="0" type="number">-1</variable>
                                <variable constant="0" name="functionName" sid="710738713870824" static="0" type="text"></variable>
                                <event-block sid="780733900932533">
                                    <conditions />
                                    <actions>
                                        <action id="-9" name="Set value" sid="246503524687637" type="System">
                                            <param id="0" name="Variable">functionName</param>
                                            <param id="1" name="Value">Function.Param(0)</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="868773755600675">
                                    <conditions>
                                        <condition id="3" name="For each element" sid="105683143311736" type="repeat">
                                            <param id="0" name="Axes">2</param>
                                        </condition>
                                    </conditions>
                                    <actions />
                                    <sub-events>
                                        <event-block sid="719885456760167">
                                            <conditions>
                                                <condition id="0" name="Compare at X" sid="365041131403981" type="repeat">
                                                    <param id="0" name="X">repeat.CurX</param>
                                                    <param id="1" name="Comparison">0</param>
                                                    <param id="2" name="Value">functionName</param>
                                                </condition>
                                            </conditions>
                                            <actions>
                                                <action id="-9" name="Set value" sid="186604817727290" type="System">
                                                    <param id="0" name="Variable">index</param>
                                                    <param id="1" name="Value">repeat.CurX</param>
                                                </action>
                                            </actions>
                                        </event-block>
                                    </sub-events>
                                </event-block>
                                <event-block sid="707333055306546">
                                    <conditions>
                                        <condition id="-14" name="Compare variable" sid="416368433374492" type="System">
                                            <param id="0" name="Variable">index</param>
                                            <param id="1" name="Comparison">4</param>
                                            <param id="2" name="Value">-1</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="9" name="Delete" sid="496587470605090" type="repeat">
                                            <param id="0" name="Index">index</param>
                                            <param id="1" name="Axis">0</param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                    </sub-events>
                </event-group>
                <comment>loop once when state not pause</comment>
                <comment>count time also can pass param</comment>
                <event-group description="" sid="579096513924853" title="game loop interval">
                    <sub-events>
                        <event-block sid="152254447579677">
                            <conditions>
                                <condition id="-6" name="Every X seconds" sid="815316115230951" type="System">
                                    <param id="0" name="Interval (seconds)">loopInterval</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <event-block sid="474936085249895">
                                    <conditions>
                                        <condition id="-14" name="Compare variable" sid="535528665583037" type="System">
                                            <param id="0" name="Variable">gameStatus</param>
                                            <param id="1" name="Comparison">1</param>
                                            <param id="2" name="Value">STATUS_PAUSE</param>
                                        </condition>
                                    </conditions>
                                    <actions />
                                    <sub-events>
                                        <event-block sid="376899735612270">
                                            <conditions>
                                                <condition id="6" inverted="1" name="Is empty" sid="809259897937383" type="arrLoopTimerCount" />
                                            </conditions>
                                            <actions />
                                            <sub-events>
                                                <variable constant="0" name="callback" sid="225818576203743" static="0" type="text"></variable>
                                                <variable constant="0" name="paramUid" sid="332613465656590" static="0" type="number">0</variable>
                                                <event-block sid="874719777091083">
                                                    <conditions>
                                                        <condition id="3" name="For each element" sid="208188490002768" type="arrLoopTimerCount">
                                                            <param id="0" name="Axes">2</param>
                                                        </condition>
                                                    </conditions>
                                                    <actions />
                                                    <sub-events>
                                                        <event-block sid="620855819458216">
                                                            <conditions>
                                                                <condition id="4" name="Compare current value" sid="612577623498796" type="arrLoopTimerCount">
                                                                    <param id="0" name="Comparison">4</param>
                                                                    <param id="1" name="Value">0</param>
                                                                </condition>
                                                            </conditions>
                                                            <actions>
                                                                <action id="2" name="Set at X" sid="692175423649751" type="arrLoopTimerCount">
                                                                    <param id="0" name="X">arrLoopTimerCount.CurX</param>
                                                                    <param id="1" name="Value">arrLoopTimerCount.CurValue - loopInterval</param>
                                                                </action>
                                                            </actions>
                                                        </event-block>
                                                        <event-block sid="441978426462165">
                                                            <conditions>
                                                                <condition id="4" name="Compare current value" sid="727092619798789" type="arrLoopTimerCount">
                                                                    <param id="0" name="Comparison">3</param>
                                                                    <param id="1" name="Value">0</param>
                                                                </condition>
                                                            </conditions>
                                                            <actions>
                                                                <action id="-9" name="Set value" sid="682568973150534" type="System">
                                                                    <param id="0" name="Variable">callback</param>
                                                                    <param id="1" name="Value">arrLoopTimerCount.At(arrLoopTimerCount.CurX, 1)</param>
                                                                </action>
                                                                <action id="-9" name="Set value" sid="523059659620703" type="System">
                                                                    <param id="0" name="Variable">paramUid</param>
                                                                    <param id="1" name="Value">arrLoopTimerCount.At(arrLoopTimerCount.CurX, 2)</param>
                                                                </action>
                                                            </actions>
                                                            <sub-events>
                                                                <event-block sid="712268158996410">
                                                                    <conditions>
                                                                        <condition id="1" name="Compare at XY" sid="413844756606887" type="arrLoopTimerCount">
                                                                            <param id="0" name="X">arrLoopTimerCount.CurX</param>
                                                                            <param id="1" name="Y">3</param>
                                                                            <param id="2" name="Comparison">0</param>
                                                                            <param id="3" name="Value">-1</param>
                                                                        </condition>
                                                                    </conditions>
                                                                    <actions>
                                                                        <action id="9" name="Delete" sid="684030969934635" type="arrLoopTimerCount">
                                                                            <param id="0" name="Index">arrLoopTimerCount.CurX</param>
                                                                            <param id="1" name="Axis">0</param>
                                                                        </action>
                                                                    </actions>
                                                                </event-block>
                                                                <event-block sid="618681698205317">
                                                                    <conditions>
                                                                        <condition id="-22" name="Else" sid="496733635148065" type="System" />
                                                                    </conditions>
                                                                    <actions>
                                                                        <action id="2" name="Set at X" sid="293523790092732" type="arrLoopTimerCount">
                                                                            <param id="0" name="X">arrLoopTimerCount.CurX</param>
                                                                            <param id="1" name="Value">arrLoopTimerCount.At(arrLoopTimerCount.CurX, 3)</param>
                                                                        </action>
                                                                    </actions>
                                                                </event-block>
                                                                <event-block sid="275484064523863">
                                                                    <conditions>
                                                                        <condition id="-14" name="Compare variable" sid="176409133838527" type="System">
                                                                            <param id="0" name="Variable">paramUid</param>
                                                                            <param id="1" name="Comparison">1</param>
                                                                            <param id="2" name="Value">-1</param>
                                                                        </condition>
                                                                    </conditions>
                                                                    <actions />
                                                                    <sub-events>
                                                                        <event-block sid="537656814260245">
                                                                            <conditions>
                                                                                <condition id="-14" name="Pick by unique ID" sid="741421714944279" type="param">
                                                                                    <param id="0" name="Unique ID">paramUid</param>
                                                                                </condition>
                                                                            </conditions>
                                                                            <actions>
                                                                                <action id="0" name="Call function" sid="287480094060319" type="Function">
                                                                                    <param id="0" name="Name">callback</param>
                                                                                    <param id="1" name="Parameter {n}">paramUid</param>
                                                                                </action>
                                                                            </actions>
                                                                        </event-block>
                                                                    </sub-events>
                                                                </event-block>
                                                                <event-block sid="767424716043908">
                                                                    <conditions>
                                                                        <condition id="-22" name="Else" sid="897364935750964" type="System" />
                                                                    </conditions>
                                                                    <actions>
                                                                        <action id="0" name="Call function" sid="133918762918534" type="Function">
                                                                            <param id="0" name="Name">callback</param>
                                                                            <param id="1" name="Parameter {n}"></param>
                                                                        </action>
                                                                    </actions>
                                                                </event-block>
                                                            </sub-events>
                                                        </event-block>
                                                    </sub-events>
                                                </event-block>
                                            </sub-events>
                                        </event-block>
                                    </sub-events>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <comment>add Function To Wait Queue</comment>
                        <comment>param 1 = time</comment>
                        <comment>param 2 = callback function name</comment>
                        <comment>param 3 = param array uid, if nothing insert -1</comment>
                        <comment>param 4 = delete after callback, if val is -1 delete it else reset time to param 4 value</comment>
                        <event-block sid="688889902764768">
                            <conditions>
                                <condition id="0" name="On function" sid="643165870565956" type="Function">
                                    <param id="0" name="Name">&quot;loop.addFuncToWaitQueue&quot;</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <event-block sid="586646978367048">
                                    <conditions />
                                    <actions>
                                        <action id="5" name="Push" sid="281023704293284" type="arrLoopTimerCount">
                                            <param id="0" name="Where">0</param>
                                            <param id="1" name="Value">Function.Param(0)</param>
                                            <param id="2" name="Axis">0</param>
                                        </action>
                                        <action id="3" name="Set at XY" sid="744561796923398" type="arrLoopTimerCount">
                                            <param id="0" name="X">arrLoopTimerCount.Width - 1</param>
                                            <param id="1" name="Y">1</param>
                                            <param id="2" name="Value">Function.Param(1)</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="334711284320720">
                                    <conditions>
                                        <condition id="1" name="Compare parameter" sid="245453227031910" type="Function">
                                            <param id="0" name="Index">2</param>
                                            <param id="1" name="Comparison">4</param>
                                            <param id="2" name="Value">0</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="3" name="Set at XY" sid="445577421254170" type="arrLoopTimerCount">
                                            <param id="0" name="X">arrLoopTimerCount.Width - 1</param>
                                            <param id="1" name="Y">2</param>
                                            <param id="2" name="Value">Function.Param(2)</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="261104028953076">
                                    <conditions>
                                        <condition id="-22" name="Else" sid="979926140205284" type="System" />
                                    </conditions>
                                    <actions>
                                        <action id="3" name="Set at XY" sid="346281852301025" type="arrLoopTimerCount">
                                            <param id="0" name="X">arrLoopTimerCount.Width - 1</param>
                                            <param id="1" name="Y">2</param>
                                            <param id="2" name="Value">-1</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="488064092883953">
                                    <conditions>
                                        <condition id="1" name="Compare parameter" sid="802486404476895" type="Function">
                                            <param id="0" name="Index">3</param>
                                            <param id="1" name="Comparison">4</param>
                                            <param id="2" name="Value">-1</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="3" name="Set at XY" sid="576664067380969" type="arrLoopTimerCount">
                                            <param id="0" name="X">arrLoopTimerCount.Width - 1</param>
                                            <param id="1" name="Y">3</param>
                                            <param id="2" name="Value">Function.Param(3)</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="657910616599298">
                                    <conditions>
                                        <condition id="-22" name="Else" sid="216672208968561" type="System" />
                                    </conditions>
                                    <actions>
                                        <action id="3" name="Set at XY" sid="716265891060014" type="arrLoopTimerCount">
                                            <param id="0" name="X">arrLoopTimerCount.Width - 1</param>
                                            <param id="1" name="Y">3</param>
                                            <param id="2" name="Value">-1</param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <comment>remove all functions in count array</comment>
                        <event-block sid="765580496912978">
                            <conditions>
                                <condition id="0" name="On function" sid="550424056445929" type="Function">
                                    <param id="0" name="Name">&quot;loop.removeAllWaitFuncs&quot;</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <event-block sid="214934346791247">
                                    <conditions />
                                    <actions>
                                        <action id="1" name="Set size" sid="898467884650278" type="arrLoopTimerCount">
                                            <param id="0" name="Width">0</param>
                                            <param id="1" name="Height">1</param>
                                            <param id="2" name="Depth">1</param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <comment>remove all same callback function</comment>
                        <event-block sid="125078427778280">
                            <conditions>
                                <condition id="0" name="On function" sid="509823387560126" type="Function">
                                    <param id="0" name="Name">&quot;loop.removeWaitFuncByName&quot;</param>
                                </condition>
                            </conditions>
                            <actions />
                            <sub-events>
                                <variable constant="0" name="index" sid="344407396352402" static="0" type="number">0</variable>
                                <variable constant="0" name="functionName" sid="355355214156402" static="0" type="text"></variable>
                                <event-block sid="119631689314468">
                                    <conditions />
                                    <actions>
                                        <action id="-9" name="Set value" sid="508124602402826" type="System">
                                            <param id="0" name="Variable">functionName</param>
                                            <param id="1" name="Value">Function.Param(0)</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="978932278374691">
                                    <conditions>
                                        <condition id="-23" name="While" sid="916021347256815" type="System" />
                                        <condition id="-14" name="Compare variable" sid="637314410033974" type="System">
                                            <param id="0" name="Variable">index</param>
                                            <param id="1" name="Comparison">4</param>
                                            <param id="2" name="Value">-1</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="-9" name="Set value" sid="363520241318947" type="System">
                                            <param id="0" name="Variable">index</param>
                                            <param id="1" name="Value">-1</param>
                                        </action>
                                    </actions>
                                    <sub-events>
                                        <event-block sid="384214217293338">
                                            <conditions>
                                                <condition id="3" name="For each element" sid="768745234709576" type="arrLoopTimerCount">
                                                    <param id="0" name="Axes">2</param>
                                                </condition>
                                            </conditions>
                                            <actions />
                                            <sub-events>
                                                <event-block sid="839820007989960">
                                                    <conditions>
                                                        <condition id="1" name="Compare at XY" sid="646195968988666" type="arrLoopTimerCount">
                                                            <param id="0" name="X">arrLoopTimerCount.CurX</param>
                                                            <param id="1" name="Y">1</param>
                                                            <param id="2" name="Comparison">0</param>
                                                            <param id="3" name="Value">functionName</param>
                                                        </condition>
                                                    </conditions>
                                                    <actions>
                                                        <action id="-9" name="Set value" sid="456260077136914" type="System">
                                                            <param id="0" name="Variable">index</param>
                                                            <param id="1" name="Value">arrLoopTimerCount.CurX</param>
                                                        </action>
                                                    </actions>
                                                </event-block>
                                            </sub-events>
                                        </event-block>
                                        <event-block sid="193816707588336">
                                            <conditions>
                                                <condition id="-14" name="Compare variable" sid="683367745659335" type="System">
                                                    <param id="0" name="Variable">index</param>
                                                    <param id="1" name="Comparison">4</param>
                                                    <param id="2" name="Value">-1</param>
                                                </condition>
                                            </conditions>
                                            <actions>
                                                <action id="9" name="Delete" sid="437049512290928" type="arrLoopTimerCount">
                                                    <param id="0" name="Index">index</param>
                                                    <param id="1" name="Axis">0</param>
                                                </action>
                                            </actions>
                                        </event-block>
                                    </sub-events>
                                </event-block>
                            </sub-events>
                        </event-block>
                        <comment>put param to single col array</comment>
                        <event-block sid="100349649582616">
                            <conditions>
                                <condition id="0" name="On function" sid="182544659123425" type="Function">
                                    <param id="0" name="Name">&quot;loop.func.createParam&quot;</param>
                                </condition>
                            </conditions>
                            <actions>
                                <action id="-3" name="Create object" sid="788728739715034" type="System">
                                    <param id="0" name="Object to create">param</param>
                                    <param id="1" name="Layer">0</param>
                                    <param id="2" name="X">0</param>
                                    <param id="3" name="Y">0</param>
                                </action>
                            </actions>
                            <sub-events>
                                <event-block sid="919287324903541">
                                    <conditions>
                                        <condition id="-10" name="For" sid="915917862165075" type="System">
                                            <param id="0" name="Name">&quot;all param&quot;</param>
                                            <param id="1" name="Start index">0</param>
                                            <param id="2" name="End index">Function.ParamCount - 1</param>
                                        </condition>
                                    </conditions>
                                    <actions>
                                        <action id="5" name="Push" sid="234420234308024" type="param">
                                            <param id="0" name="Where">0</param>
                                            <param id="1" name="Value">Function.Param(loopindex)</param>
                                            <param id="2" name="Axis">0</param>
                                        </action>
                                    </actions>
                                </event-block>
                                <event-block sid="918678742465822">
                                    <conditions />
                                    <actions>
                                        <action id="1" name="Set return value" sid="826981227367365" type="Function">
                                            <param id="0" name="Value">param.UID</param>
                                        </action>
                                    </actions>
                                </event-block>
                            </sub-events>
                        </event-block>
                    </sub-events>
                </event-group>
            </sub-events>
        </event-group>
    </events>
</c2eventsheet>
