using System; using System.Threading.Tasks; using ColdMint.scripts.utils; using Godot; namespace ColdMint.scripts.map.roomInjectionProcessor; /// /// Time interval for room injection processor /// 时间区间的房间注入处理器 /// /// ///This processor allows you to specify a time range and allows room generation within the specified time range. ///此处理器允许指定一个时间范围,并在指定的时间范围内允许生成房间。 /// public class TimeIntervalRoomInjectorProcessor : RoomInjectionProcessorTemplate { public override string GetId() { return Config.RoomInjectionProcessorId.TimeInterval; } protected override Task OnCreateConfigData(RandomNumberGenerator randomNumberGenerator, ConfigData configData) { if (configData.StartTime == null) { return Task.FromResult(false); } if (configData.EndTime == null) { //If no end time is specified, the default end time is the start time //如果未指定结束时间,则默认结束时间为开始时间 configData.EndTime = configData.StartTime; } var now = DateTime.Now; if (!configData.SpecifiedYear) { //If no year is specified, it is automatically added to the current year //若未指定年份,则自动补充为当前年份 var nowYear = now.Year; configData.StartTime = $"{nowYear}-{configData.StartTime}"; configData.EndTime = $"{nowYear}-{configData.EndTime}"; } return Task.FromResult(TimeUtils.IsBetweenTimeSpan(now, configData.StartTime, configData.EndTime)); } public class ConfigData { /// /// Whether to specify a year /// 是否指定年份 /// /// ///If true, then Year can be specified in StartTime and EndTime. The specified year is used to be executed only once in a given year, while configurations that do not specify a year are automatically replenished with the current year (performed annually). ///如果为true,那么可以在StartTime和EndTime内指定Year。指定年份被用于在特定的年份仅执行一次,而未指定年份的配置会自动补充为当前年份(每年执行)。 /// public bool SpecifiedYear { get; set; } /// /// Start time /// 起始时间 /// /// ///If the year is not specified, enter data in the format MM-DD hh:mm:ss. If the year is specified, enter data in the format yyyy-MM-dd hh:mm:ss. ///若未指定年份,则可填入格式为MM-dd hh:mm:ss的数据,若指定了年份,那么请填入yyyy-MM-dd hh:mm:ss格式数据。 /// public string? StartTime { get; set; } /// /// End time /// 结束时间 /// /// ///See StartTime ///同StartTime /// public string? EndTime { get; set; } } }