DirectOutputR1
DirectOutput framework R1 for virtual pinball cabinets.
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
ExtendDurationEffect.cs
Go to the documentation of this file.
1 using System;
2 using DirectOutput.Table;
3 
4 namespace DirectOutput.FX.TimmedFX
5 {
12  {
13  private int _DurationMs = 500;
14 
21  public int DurationMs
22  {
23  get { return _DurationMs; }
24  set { _DurationMs = value.Limit(0, 500); }
25  }
26 
27 
28 
35  public override void Trigger(Table.TableElementData TableElementData)
36  {
37  if (TargetEffect != null)
38  {
39  if (TableElementData.Value != 0)
40  {
41  TargetEffect.Trigger(TableElementData);
42  }
43  else
44  {
45  if (DurationMs > 0)
46  {
47  Table.Pinball.Alarms.RegisterAlarm(DurationMs, TriggerTargetEffect, TableElementData, true);
48  }
49  else
50  {
51  TargetEffect.Trigger(TableElementData);
52  }
53  }
54 
55  }
56  }
57 
58 
59  private void TriggerTargetEffect(object AlarmParameter)
60  {
61  if (TargetEffect != null)
62  {
63  try
64  {
65  TargetEffect.Trigger((TableElementData)AlarmParameter);
66  }
67  catch (Exception E)
68  {
69  Log.Exception("The target effect {0} of the ExtendDurationEffect {1} has trown a exception.".Build(TargetEffectName, Name), E);
70  TargetEffect = null;
71  }
72  }
73 
74  }
75 
76 
81  public override void Init(Table.Table Table)
82  {
83  base.Init(Table);
84  }
85 
90  public override void Finish()
91  {
92  try
93  {
94  Table.Pinball.Alarms.UnregisterAlarm(TriggerTargetEffect);
95  }
96  catch { }
97  base.Finish();
98  }
99 
100  }
101 }