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
EffectEffectBase.cs
Go to the documentation of this file.
1 using System.Xml.Serialization;
2 using DirectOutput.Table;
3 using System;
4 
5 namespace DirectOutput.FX
6 {
10  public abstract class EffectEffectBase : EffectBase
11  {
12  #region EffectName
13  private string _TargetEffectName;
18  public string TargetEffectName
19  {
20  get { return _TargetEffectName; }
21  set
22  {
23  if (_TargetEffectName != value)
24  {
25  _TargetEffectName = value;
26  TargetEffect = null;
27 
28  }
29  }
30  }
31 
32 
33 
34 
35  #endregion
36 
37 
38 
39  #region Effect
40  private IEffect _TargetEffect;
45  [XmlIgnoreAttribute]
46  protected IEffect TargetEffect
47  {
48  get
49  {
50  return _TargetEffect;
51  }
52  private set
53  {
54  _TargetEffect = value;
55  }
56  }
57 
63  protected void TriggerTargetEffect(TableElementData TriggerData)
64  {
65  if (TargetEffect != null)
66  {
67  try
68  {
69  TargetEffect.Trigger(TriggerData);
70  }
71  catch (Exception E)
72  {
73  Log.Exception("The target effect {0} of the {1} {2} has thrown a exception. Disabling further calls of the target effect.".Build(TargetEffectName, GetType().Name, Name), E);
74  TargetEffect = null;
75  }
76  }
77 
78  }
79 
80 
81  private void ResolveEffectName(Table.Table Table)
82  {
83  if (!TargetEffectName.IsNullOrWhiteSpace() && Table.Effects.Contains(TargetEffectName))
84  {
85  TargetEffect = Table.Effects[TargetEffectName];
86  };
87 
88  }
89 
90  #endregion
91 
98  protected Table.Table Table { get; private set; }
99 
105  public override void Init(Table.Table Table)
106  {
107  this.Table = Table;
108  ResolveEffectName(Table);
109  }
110 
115  public override void Finish()
116  {
117  TargetEffect = null;
118  Table = null;
119  base.Finish();
120  }
121 
122  }
123 }