IW4M-Admin/SharedLibraryCore/Event.cs

92 lines
2.2 KiB
C#
Raw Normal View History

2015-03-08 17:20:10 -04:00
using System;
using System.Linq;
2015-03-08 17:20:10 -04:00
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
2018-04-08 02:44:42 -04:00
using SharedLibraryCore.Objects;
2018-04-08 02:44:42 -04:00
namespace SharedLibraryCore
2015-03-08 17:20:10 -04:00
{
public class GameEvent
2015-03-08 17:20:10 -04:00
{
public enum EventType
2015-03-08 17:20:10 -04:00
{
//FROM SERVER
Start,
Stop,
2015-03-08 17:20:10 -04:00
Connect,
// this is for IW5 compatibility
Join,
2015-03-08 17:20:10 -04:00
Disconnect,
Say,
MapChange,
MapEnd,
2015-03-08 17:20:10 -04:00
//FROM ADMIN
Broadcast,
Tell,
Kick,
Ban,
Remote,
2015-03-08 17:20:10 -04:00
Unknown,
//FROM PLAYER
Report,
Flag,
2018-04-14 00:51:38 -04:00
Command,
// FROM GAME
Script,
Kill,
Damage,
Death,
2015-03-08 17:20:10 -04:00
}
public GameEvent(EventType t, string d, Player O, Player T, Server S)
2015-03-08 17:20:10 -04:00
{
Type = t;
Data = d?.Trim();
2015-03-08 17:20:10 -04:00
Origin = O;
Target = T;
Owner = S;
OnProcessed = new ManualResetEventSlim();
2015-03-08 17:20:10 -04:00
}
public GameEvent()
{
OnProcessed = new ManualResetEventSlim();
}
2015-03-08 17:20:10 -04:00
public static GameEvent TranferWaiter(EventType newType, GameEvent e)
{
var newEvent = new GameEvent()
{
Data = e.Data,
Extra = e.Extra,
Message = e.Message,
OnProcessed = e.OnProcessed,
Origin = e.Origin,
Owner = e.Owner,
Remote = e.Remote,
Target = e.Target,
Type = newType
};
// hack: prevent the previous event from completing until this one is done
e.OnProcessed = new ManualResetEventSlim();
return newEvent;
}
public EventType Type;
2015-03-08 17:20:10 -04:00
public string Data; // Data is usually the message sent by player
public string Message;
2015-03-08 17:20:10 -04:00
public Player Origin;
public Player Target;
public Server Owner;
public Boolean Remote = false;
2018-04-14 00:51:38 -04:00
public object Extra { get; set; }
public ManualResetEventSlim OnProcessed { get; set; }
2015-03-08 17:20:10 -04:00
}
}