DirectOuput Framework R2
DirectOutput framework R2 for virtual pinball cabinets
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
MaxDurationEffect.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 {
14  {
15  private RetriggerBehaviourEnum _RetriggerBehaviour = RetriggerBehaviourEnum.Restart;
16 
25  public RetriggerBehaviourEnum RetriggerBehaviour
26  {
27  get { return _RetriggerBehaviour; }
28  set { _RetriggerBehaviour = value; }
29  }
30 
31  private int _DurationMs = 500;
32 
39  public int MaxDurationMs
40  {
41  get { return _DurationMs; }
42  set { _DurationMs = value.Limit(1,int.MaxValue); }
43  }
44 
45 
46 
53  [XmlIgnoreAttribute]
54  public bool Active { get; private set; }
55 
56  private TableElementData UntriggerData;
57  private DateTime DurationStart = DateTime.MinValue;
58 
59 
64  public override void Trigger(Table.TableElementData TableElementData)
65  {
66  if (TableElementData.Value != 0)
67  {
68 
69  if (!Active || RetriggerBehaviour == RetriggerBehaviourEnum.Restart)
70  {
71  TriggerTargetEffect(TableElementData);
72  UntriggerData=TableElementData;
73  UntriggerData.Value = 0;
74  Table.Pinball.Alarms.RegisterAlarm(MaxDurationMs, DurationEnd);
75  Active = true;
76  }
77 
78  }
79  else
80  {
81  if (Active && UntriggerData.TableElementType == TableElementData.TableElementType && UntriggerData.Number == TableElementData.Number)
82  {
83  TriggerTargetEffect(TableElementData);
84  Table.Pinball.Alarms.UnregisterAlarm(DurationEnd);
85  Active = false;
86  }
87 
88  }
89 
90  }
91 
92 
93  private void DurationEnd()
94  {
95  TriggerTargetEffect(UntriggerData);
96  Active = false;
97 
98  }
99  }
100 }