Files
ft/Client/Assets/Scripts/Activity/Condition/TimeConditionChecker.cs
2026-06-29 21:18:33 +08:00

40 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using asap.core;
using cfg;
using game;
using GameCore;
namespace Activity.Condition
{
/// <summary>
/// 时间条件检查器
/// </summary>
public class TimeConditionChecker : IConditionChecker
{
public int Priority => 10;
public List<Type> CareDataChangeWithType => null;
public bool NeedContinueListenAfterSatisfied => true;
public bool CanOpen(FishingEvent fishingEvent)
{
var now = ZZTimeHelper.UtcNow();
return fishingEvent.TimeDefinition switch
{
LimitedTime limitedTime =>
GlobalUtils.TryParseDateTime(limitedTime.StartTime, now) <= now &&
now < GlobalUtils.TryParseDateTime(limitedTime.EndTime, now),
UserRegistration userReg =>
GContext.container.Resolve<IUserService>().CreateTotalSeconds() >= userReg.StartTime &&
GContext.container.Resolve<IUserService>().CreateTotalSeconds() < userReg.EndTime,
FixedTime =>
GContext.container.Resolve<FishingEventData>().FixedTimeEventExpired(fishingEvent.ID),
_ => true
};
}
}
}