Files
MinFt/Client/Assets/Scripts/TimeManager/TimeTickService.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

51 lines
1.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using UniRx;
namespace TimeManager
{
/// <summary>
/// 统一 Tick 服务实现 - 管理秒级和分钟级的定时器。
/// 构造时即启动 Interval须在业务启动链中显式 <c>Resolve&lt;TimeRefreshManager&gt;()</c>(如 ActivityManager.Init 开头),以挂上跨天/跨小时逻辑。
/// Stop 后需再调 Start() 恢复。
/// </summary>
public class TimeTickService : ITimeTickService, IDisposable
{
private IObservable<long> _secondTick;
private IObservable<long> _minuteTick;
private bool _isStarted;
public TimeTickService()
{
EnsureStarted();
}
public IObservable<long> SecondTick => _secondTick;
public IObservable<long> MinuteTick => _minuteTick;
public void Start() => EnsureStarted();
private void EnsureStarted()
{
if (_isStarted) return;
_secondTick = Observable.Interval(TimeSpan.FromSeconds(1f));
_minuteTick = Observable.Interval(TimeSpan.FromMinutes(1f));
_isStarted = true;
}
public void Stop()
{
_secondTick = null;
_minuteTick = null;
_isStarted = false;
}
public void Dispose()
{
Stop();
}
}
}