SharpLibEar/Event.cs
author Stephane Lenclud
Sun, 31 Jul 2016 12:03:52 +0200
changeset 230 8c5cf2228e9a
parent 212 1a0791daa243
child 231 4c706feaf706
permissions -rw-r--r--
Published v0.10.2.0.
StephaneLenclud@210
     1
//
StephaneLenclud@210
     2
StephaneLenclud@210
     3
StephaneLenclud@210
     4
using System;
StephaneLenclud@210
     5
using System.Collections.Generic;
StephaneLenclud@210
     6
using System.Runtime.Serialization;
StephaneLenclud@210
     7
StephaneLenclud@210
     8
namespace SharpLib.Ear
StephaneLenclud@210
     9
{
StephaneLenclud@210
    10
    [DataContract]
StephaneLenclud@210
    11
    public abstract class MEvent
StephaneLenclud@210
    12
    {
StephaneLenclud@210
    13
        public string Name { get; protected set; }
StephaneLenclud@210
    14
        public string Description { get; protected set; }
StephaneLenclud@210
    15
StephaneLenclud@210
    16
        public abstract void Trigger();
StephaneLenclud@210
    17
    };
StephaneLenclud@210
    18
StephaneLenclud@210
    19
    [DataContract]
StephaneLenclud@210
    20
    public abstract class Event : MEvent
StephaneLenclud@210
    21
    {
Stephane@212
    22
        [DataMember]
Stephane@212
    23
        public List<Action> Actions = new List<Action>();
StephaneLenclud@210
    24
StephaneLenclud@210
    25
        protected Event()
StephaneLenclud@210
    26
        {
Stephane@212
    27
           
StephaneLenclud@210
    28
        }
StephaneLenclud@210
    29
StephaneLenclud@210
    30
        public override void Trigger()
StephaneLenclud@210
    31
        {
StephaneLenclud@229
    32
            Console.WriteLine("Event triggered: " + Name);
StephaneLenclud@210
    33
            foreach (Action action in Actions)
StephaneLenclud@210
    34
            {
StephaneLenclud@210
    35
                action.Execute();
StephaneLenclud@210
    36
            }
StephaneLenclud@210
    37
        }
StephaneLenclud@210
    38
    }
StephaneLenclud@210
    39
StephaneLenclud@210
    40
}