WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
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 = RetriggerBehaviourEnum.Restart;
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 && TableElementData.Value != 0)
65  {
66  if (!Active)
67  {
68  TriggerTargetEffect(TableElementData);
69  Table.Pinball.Alarms.RegisterAlarm(DurationMs, DurationEnd, TableElementData);
70  Active = true;
71  } else if(RetriggerBehaviour==RetriggerBehaviourEnum.Restart) {
72  Table.Pinball.Alarms.RegisterAlarm(DurationMs, DurationEnd, TableElementData);
73  }
74  }
75  }
76 
77 
78  private void DurationEnd(object TableElementData)
79  {
80 
81  Table.TableElementData TED = (Table.TableElementData)TableElementData;
82  TED.Value = 0;
83  TriggerTargetEffect(TED);
84  Active = false;
85  }
86 
90  public override void Finish()
91  {
92  try
93  {
94  Table.Pinball.Alarms.UnregisterAlarm(DurationEnd);
95 
96  }
97  catch { }
98  Active = false;
99  base.Finish();
100  }
101 
102  }
103 }
Duration effect which triggers a specified target effect for a specified duration. When this effect is triggered it triggers the target effect immediately with the same data it has received. After the specified duration it calls trigger on the target effect again with data for the same table elmenet, but with the value changed to 0.
override void Trigger(Table.TableElementData TableElementData)
Triggers the DurationEffect with the given TableElementData. The duration is started, if the value portion of the TableElementData parameter is !=0. Trigger calls with a TableElement value=0 have no effect.
RetriggerBehaviourEnum
This enum describes the different retrigger behaviours for the effects. Retriggering means that a ef...
Base class for effects targeting another effect.
override void Finish()
Finishes the DurationEffect.