SharpLibEar/Event.cs
author StephaneLenclud
Wed, 27 Jul 2016 17:09:10 +0200
changeset 224 471cb4c8a09a
parent 210 83dd86e73448
child 229 7c631055b94b
permissions -rw-r--r--
Make sure action edit combo box for enums is long enough.
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@210
    32
            Console.WriteLine("Event '" + Name + "' triggered.");
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
}