50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using UniRx;
|
|
using asap.core;
|
|
using EventPartnerGatherRequests;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace EventPartner
|
|
{
|
|
public class RtSystem
|
|
{
|
|
private CompositeDisposable _disposable;
|
|
private readonly IRTService _rtService;
|
|
private Action<EventPartnerGatherScoreEvt> _onScore;
|
|
private Action<EventPartnerGatherPartnerEvt> _onPartnerChange;
|
|
|
|
public RtSystem()
|
|
{
|
|
// Debug.Log($"[EventPartnerStatue] New rt system: {GetHashCode()}");
|
|
_rtService = GContext.container.Resolve<IRTService>();
|
|
}
|
|
|
|
public void Subscribe(Action<EventPartnerGatherScoreEvt> onScore, Action<EventPartnerGatherPartnerEvt> onPartnerChange)
|
|
{
|
|
// Debug.Log($"[EventPartnerStatue] Rt subscribe: {GetHashCode()}");
|
|
_disposable?.Dispose();
|
|
_disposable = new CompositeDisposable
|
|
{
|
|
_rtService.OnEvent(onScore),
|
|
_rtService.OnEvent(onPartnerChange),
|
|
};
|
|
_onScore = onScore;
|
|
_onPartnerChange = onPartnerChange;
|
|
}
|
|
|
|
public void Unsubscribe()
|
|
{
|
|
// Debug.Log($"[EventPartnerStatue] Rt unsubscribe: {GetHashCode()}");
|
|
_disposable?.Dispose();
|
|
}
|
|
|
|
public void TestRt(EventPartnerGatherScoreEvt se, EventPartnerGatherPartnerEvt pe)
|
|
{
|
|
#if UNITY_EDITOR
|
|
_onScore?.Invoke(se);
|
|
_onPartnerChange?.Invoke(pe);
|
|
#endif
|
|
}
|
|
}
|
|
}
|