mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 03:59:35 +08:00
Add Events template
This commit is contained in:
parent
0c05e2fb5c
commit
626a17b1e8
57
FunGame.Core/Entity/Event/ConnectEvent.cs
Normal file
57
FunGame.Core/Entity/Event/ConnectEvent.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Milimoe.FunGame.Core.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Entity.Event
|
||||||
|
{
|
||||||
|
public class ConnectEvent : IConnectEvent
|
||||||
|
{
|
||||||
|
public event IEvent.BeforeEvent? BeforeConnectEvent;
|
||||||
|
public event IEvent.AfterEvent? AfterConnectEvent;
|
||||||
|
public event IEvent.SucceedEvent? SucceedConnectEvent;
|
||||||
|
public event IEvent.FailedEvent? FailedConnectEvent;
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnBeforeConnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (BeforeConnectEvent != null)
|
||||||
|
{
|
||||||
|
return BeforeConnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnAfterConnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (AfterConnectEvent != null)
|
||||||
|
{
|
||||||
|
return AfterConnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnSucceedConnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (SucceedConnectEvent != null)
|
||||||
|
{
|
||||||
|
return SucceedConnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnFailedConnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (FailedConnectEvent != null)
|
||||||
|
{
|
||||||
|
return FailedConnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
FunGame.Core/Entity/Event/DisconnectEvent.cs
Normal file
57
FunGame.Core/Entity/Event/DisconnectEvent.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Milimoe.FunGame.Core.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Entity.Event
|
||||||
|
{
|
||||||
|
public class DisconnectEvent : IDisconnectEvent
|
||||||
|
{
|
||||||
|
public event IEvent.BeforeEvent? BeforeDisconnectEvent;
|
||||||
|
public event IEvent.AfterEvent? AfterDisconnectEvent;
|
||||||
|
public event IEvent.SucceedEvent? SucceedDisconnectEvent;
|
||||||
|
public event IEvent.FailedEvent? FailedDisconnectEvent;
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnBeforeDisconnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (BeforeDisconnectEvent != null)
|
||||||
|
{
|
||||||
|
return BeforeDisconnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnAfterDisconnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (AfterDisconnectEvent != null)
|
||||||
|
{
|
||||||
|
return AfterDisconnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnSucceedDisconnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (SucceedDisconnectEvent != null)
|
||||||
|
{
|
||||||
|
return SucceedDisconnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Enum.EventResult OnFailedDisconnectEvent(GeneralEventArgs e)
|
||||||
|
{
|
||||||
|
if (FailedDisconnectEvent != null)
|
||||||
|
{
|
||||||
|
return FailedDisconnectEvent(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Enum.EventResult.Fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,12 @@ namespace Milimoe.FunGame.Core.Entity.Event
|
|||||||
{
|
{
|
||||||
public string EventMsg { get; set; } = "";
|
public string EventMsg { get; set; } = "";
|
||||||
public object[]? Parameters { get; set; } = null;
|
public object[]? Parameters { get; set; } = null;
|
||||||
|
|
||||||
|
public GeneralEventArgs(string EventMsg, object[]? Parameters = null)
|
||||||
|
{
|
||||||
|
this.EventMsg = EventMsg;
|
||||||
|
this.Parameters = Parameters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GeneralEvent<T>
|
public class GeneralEvent<T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user