39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace DDD.Restaurant
|
|
{
|
|
public abstract class RestaurantEventBase<T> : IEvent where T : Enum
|
|
{
|
|
protected GameObject Causer;
|
|
protected GameObject Target;
|
|
protected T EventType;
|
|
protected ScriptableObject Payload;
|
|
protected bool EventResult = false;
|
|
|
|
protected RestaurantEventBase<T> MakeInteractionEvent(GameObject causer, GameObject target,
|
|
T eventType,
|
|
ScriptableObject payload = null)
|
|
{
|
|
Causer = causer;
|
|
Target = target;
|
|
EventType = eventType;
|
|
Payload = payload;
|
|
return this;
|
|
}
|
|
|
|
public bool RequestEvent(GameObject causer, GameObject target, T eventType,
|
|
ScriptableObject payload = null)
|
|
{
|
|
var evt = MakeInteractionEvent(causer, target, eventType, payload);
|
|
// Solve event directly. 이벤트 처리는 여기서 하고, 이벤트 호출로는 이런 이벤트가 호출되었고 결과가 어떻다는 거 전파하는 식으로.
|
|
evt.EventResult = EventSolve(causer, target, eventType, payload);
|
|
|
|
EventBus.Broadcast(evt); // 이벤트 결과를 이거 받아서 처리하면 될듯.
|
|
return evt.EventResult;
|
|
}
|
|
|
|
protected abstract bool EventSolve(GameObject causer, GameObject target, T eventType,
|
|
ScriptableObject payload);
|
|
}
|
|
} |