You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
3 years ago
|
using System;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public class SyncTimeComponentAwakeSystem: AwakeSystem<SyncTimeComponent>
|
||
|
{
|
||
|
public override void Awake(SyncTimeComponent self)
|
||
|
{
|
||
|
self.Timer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerType.SyncTime, self);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public class SyncTimeComponentDestroySystem: DestroySystem<SyncTimeComponent>
|
||
|
{
|
||
|
public override void Destroy(SyncTimeComponent self)
|
||
|
{
|
||
|
if (self.Parent == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
TimerComponent.Instance?.Remove(ref self.Timer);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[Timer(TimerType.SyncTime)]
|
||
|
public class SyncTimeComponentTimer : ATimer<SyncTimeComponent>
|
||
|
{
|
||
|
public override void Run(SyncTimeComponent self)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (self.IsDisposed || self.Parent == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (self.DomainScene() == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
self.SyncTime().Coroutine();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Log.Error(e.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static class SyncTimeComponentSystem
|
||
|
{
|
||
|
public static async ETTask SyncTime(this SyncTimeComponent self)
|
||
|
{
|
||
|
var unit = UnitHelper.GetMyUnitFromZoneScene(self.ZoneScene());
|
||
|
int result = await UnitHelper.GetUnitGameTime(unit);
|
||
|
}
|
||
|
}
|
||
|
}
|