WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
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 }
void TriggerTargetEffect(TableElementData TriggerData)
Triggers the target effect. The method will deactivate the target effect if it throws a exception...
override void Finish()
Finishes the EffectEffect. Releases the references to the target effect and to the table object...
void Finish()
Finishes the table and the contained objects (Effects, TableElements)
Definition: Table.cs:276
override void Init(Table.Table Table)
Initializes the EffectEffect. Resolves the name of the TargetEffect.
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
Abstract base class for IEffect objects. This class inherits NamedItemBase and implements IEffect...
Definition: EffectBase.cs:15
Common interface for all effects. If a new effect is implemented it is best to inherit from the abst...
Definition: IEffect.cs:13
Data representing the state of a table emlement
EffectList Effects
List of table specific effects.
Definition: Table.cs:187
Base class for effects targeting another effect.
The Table namespace contains all table specific classes like the Table class itself, TableElement and effect assigment classes.
Definition: Table.cs:14
Holds all table specific information and handles all TableElements
Definition: Table.cs:20
Table()
Initializes a new instance of the Table class.
Definition: Table.cs:388
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
Definition: Log.cs:144