WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
MinDurationEffect.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 using DirectOutput.Table;
7 
8 namespace DirectOutput.FX.TimmedFX
9 {
17  {
18  private RetriggerBehaviourEnum _RetriggerBehaviour = RetriggerBehaviourEnum.Restart;
19 
28  public RetriggerBehaviourEnum RetriggerBehaviour
29  {
30  get { return _RetriggerBehaviour; }
31  set { _RetriggerBehaviour = value; }
32  }
33 
34  private int _DurationMs = 500;
35 
42  public int MinDurationMs
43  {
44  get { return _DurationMs; }
45  set { _DurationMs = value; }
46  }
47 
48 
49 
56  [XmlIgnoreAttribute]
57  public bool Active { get; private set; }
58 
59  private TableElementData UntriggerData;
60  private DateTime DurationStart = DateTime.MinValue;
61 
68  {
69  if (TargetEffect != null)
70  {
71  if (TableElementData.Value != 0)
72  {
73  if (!Active || RetriggerBehaviour == RetriggerBehaviourEnum.Restart)
74  {
75  DurationStart = DateTime.Now;
76  UntriggerData = TableElementData;
77  TriggerTargetEffect(TableElementData);
78  Active = true;
79  }
80  }
81  else
82  {
83  if (Active && UntriggerData.TableElementType==TableElementData.TableElementType && UntriggerData.Number==TableElementData.Number)
84  {
85  if ((DateTime.Now - DurationStart).TotalMilliseconds >= MinDurationMs)
86  {
87  MinDurationEnd();
88  }
89  else
90  {
91  Table.Pinball.Alarms.RegisterAlarm(MinDurationMs - (int)(DateTime.Now - DurationStart).TotalMilliseconds, MinDurationEnd);
92  }
93  }
94 
95  }
96 
97  }
98  }
99 
100 
101 
102  private void MinDurationEnd()
103  {
104  if (Active)
105  {
106  TableElementData D = UntriggerData;
107  D.Value = 0;
108  TriggerTargetEffect(D);
109  }
110  Active = false;
111  }
112 
113 
114 
118  public override void Finish()
119  {
120 
121  try
122  {
123  Table.Pinball.Alarms.UnregisterAlarm(MinDurationEnd);
124  }
125  catch { }
126  //MinDurationEnd();
127  Active = false;
128  base.Finish();
129  }
130 
131 
132 
133  }
134 }
Pinball Pinball
Gets the pinball object to which the Table object belongs.
Definition: Table.cs:36
TableElementTypeEnum TableElementType
The type of the table element.
int Number
The number of the table element.
int Value
The value of the table element.
AlarmHandler Alarms
Gets the AlarmHandler object for the Pinball object.
Definition: Pinball.cs:71
RetriggerBehaviourEnum
This enum describes the different retrigger behaviours for the effects. Retriggering means that a ef...
Data representing the state of a table emlement
Base class for effects targeting another effect.
override void Finish()
Finishes the DurationEffect.
The Table namespace contains all table specific classes like the Table class itself, TableElement and effect assigment classes.
Definition: Table.cs:14
This effect enforces a minimum duration on the effect calls. Calls which are setting a effect to act...
Holds all table specific information and handles all TableElements
Definition: Table.cs:20
override void Trigger(TableElementData TableElementData)
Triggers the MinDurationEffect with the given TableElementData. The minimal duration is started...