DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
DurationEffect.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Xml.Serialization;
6 
7 namespace DirectOutput.FX.TimmedFX
8 {
15  {
16  private RetriggerBehaviourEnum _RetriggerBehaviour;
17 
26  public RetriggerBehaviourEnum RetriggerBehaviour
27  {
28  get { return _RetriggerBehaviour; }
29  set { _RetriggerBehaviour = value; }
30  }
31 
32  private int _DurationMs = 500;
33 
40  public int DurationMs
41  {
42  get { return _DurationMs; }
43  set { _DurationMs = value; }
44  }
45 
46 
53  [XmlIgnoreAttribute]
54  public bool Active { get; private set; }
55 
62  public override void Trigger(Table.TableElementData TableElementData)
63  {
64  if (TargetEffect != null)
65  {
66  if (!Active || RetriggerBehaviour == RetriggerBehaviourEnum.RestartEffect)
67  {
68  if (TableElementData.Value != 0)
69  {
70  TargetEffect.Trigger(TableElementData);
71  Table.Pinball.Alarms.RegisterAlarm(DurationMs, DurationEnd, TableElementData.Clone());
72  }
73  Active = true;
74  }
75  }
76  }
77 
78 
79  private void DurationEnd(object TableElementData)
80  {
81 
82  Table.TableElementData TED = (Table.TableElementData)TableElementData;
83  TED.Value = 0;
84  TargetEffect.Trigger(TED);
85  Active = false;
86  }
87 
91  public override void Finish()
92  {
93  try
94  {
95  Table.Pinball.Alarms.UnregisterAlarm(DurationEnd);
96 
97  }
98  catch { }
99  Active = false;
100  base.Finish();
101  }
102 
103  }
104 }