46 lines
992 B
C#
Raw Normal View History

2022-02-26 00:26:31 -08:00
using Cysharp.Threading.Tasks;
using QSB.WorldSync;
using System;
using System.Threading;
namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects
2022-02-26 00:26:31 -08:00
{
// will be implemented when eote
internal class QSBLightSensor : WorldObject<SingleLightSensor>
{
internal bool _illuminatedByLocal;
2022-02-26 00:26:31 -08:00
public event Action OnDetectLocalLight;
public event Action OnDetectLocalDarkness;
2022-02-26 00:26:31 -08:00
public override async UniTask Init(CancellationToken ct)
{
AttachedObject.OnDetectLight += OnDetectLight;
AttachedObject.OnDetectDarkness += OnDetectDarkness;
}
2022-02-26 00:26:31 -08:00
public override void OnRemoval()
{
AttachedObject.OnDetectLight -= OnDetectLight;
AttachedObject.OnDetectDarkness -= OnDetectDarkness;
}
2022-02-26 00:26:31 -08:00
private void OnDetectLight()
2022-02-26 00:26:31 -08:00
{
if (_illuminatedByLocal)
{
OnDetectLocalLight?.Invoke();
}
2022-02-26 00:26:31 -08:00
}
private void OnDetectDarkness()
2022-02-26 00:26:31 -08:00
{
if (_illuminatedByLocal)
{
OnDetectLocalDarkness?.Invoke();
}
2022-02-26 00:26:31 -08:00
}
public override void SendInitialState(uint to) { }
}
2022-02-26 00:26:31 -08:00
}