Adjust the test based on the time range of the room injector.
调整测试基于时间范围的房间注入器。
This commit is contained in:
parent
a957c91ffe
commit
91cffd4866
|
@ -46,7 +46,7 @@
|
|||
"res://prefab/roomTemplates/dungeon/"
|
||||
],
|
||||
"Tags": null,
|
||||
"RoomInjectionProcessorData": "[\n {\n \"Id\": \"Chance\",\n \"Config\": \"{\\\"Chance\\\":35.5}\"\n }\n]"
|
||||
"RoomInjectionProcessorData": "[\n {\n \"Id\": \"TimeInterval\",\n \"Config\": \"{\\\"DateSpecifiesLevel\\\":0,\\\"StartTime\\\":\\\"2024/1/1 20:34:23\\\",\\\"EndTime\\\":\\\"2025/1/1 20:34:23\\\"}\"\n }\n]"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -16,4 +16,5 @@ failed_to_calculate_the_room_location,计算房间{0}位置时失败。,Failed t
|
|||
place_existing_rooms,放置已存在的房间{0}。,Place existing rooms {0}.,既存の部屋を置きます{0}。
|
||||
room_placement_failed,房间{0}放置失败。,Room {0} placement failed.,部屋{0}の放置に失敗します。
|
||||
room_placement_information,房间{0}已被成功放置在{1}。,Room {0} has been successfully placed in {1}.,部屋{0}を{1}に配置しました。
|
||||
room_injection_processor_does_not_exist,找不到房间注入处理器{0},请检测是否在MapGenerator内注册。,"Room injection processor {0} not found, check to see if it is registered in MapGenerator.",部屋注入プロセッサ{0}が見つかりません、MapGenerator内に登録されているかどうか検出してください。
|
||||
room_injection_processor_does_not_exist,找不到房间注入处理器{0},请检测是否在MapGenerator内注册。,"Room injection processor {0} not found, check to see if it is registered in MapGenerator.",部屋注入プロセッサ{0}が見つかりません、MapGenerator内に登録されているかどうか検出してください。
|
||||
time_range_debug,当前时间:{0}起始时间:{1},结束时间{2},是否在范围内{3},"Current time: {0} Start time: {1}, end time {2}, whether in range {3}",現在時間:{0}開始時間:{1}終了時間{2}範囲内かどうか{3}です
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -35,16 +35,47 @@ public class
|
|||
configData.EndTime = configData.StartTime;
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
if (!configData.SpecifiedYear)
|
||||
if (configData.DateSpecifiesLevel == null)
|
||||
{
|
||||
//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}";
|
||||
//If no date level is specified, the default is 0
|
||||
//若未指定日期等级,则默认为0
|
||||
configData.DateSpecifiesLevel = 0;
|
||||
}
|
||||
|
||||
var now = DateTime.Now;
|
||||
var nowYear = now.Year;
|
||||
var nowMonth = now.Month;
|
||||
switch (configData.DateSpecifiesLevel)
|
||||
{
|
||||
case 0:
|
||||
//The complete time is specified in the format yyyy/MM/dd hh:mm:ss
|
||||
//指定了完整的时间,格式如:yyyy/MM/dd hh:mm:ss
|
||||
break;
|
||||
case 1:
|
||||
//No year is specified. The format is mm/dd hh:mm:ss
|
||||
//未指定年份。格式如:MM/dd hh:mm:ss
|
||||
configData.StartTime = $"{nowYear}/{configData.StartTime}";
|
||||
configData.EndTime = $"{nowYear}/{configData.EndTime}";
|
||||
break;
|
||||
case 2:
|
||||
//No year and month are specified. The format is dd hh:mm:ss
|
||||
//未指定年份和月份。格式如:dd hh:mm:ss
|
||||
configData.StartTime = $"{nowYear}/{nowMonth}/{configData.StartTime}";
|
||||
configData.EndTime = $"{nowYear}/{nowMonth}/{configData.EndTime}";
|
||||
break;
|
||||
case 3:
|
||||
//No year, month, and day are specified. The format is hh:mm:ss
|
||||
//未指定年份、月份和日期。格式如:hh:mm:ss
|
||||
configData.StartTime = $"{nowYear}/{nowMonth}/{now.Day} {configData.StartTime}";
|
||||
configData.EndTime = $"{nowYear}/{nowMonth}/{now.Day} {configData.EndTime}";
|
||||
break;
|
||||
case 4:
|
||||
//No year, month, day, and hour are specified. The format is mm:ss
|
||||
//未指定年份、月份、日期和小时。格式如:mm:ss
|
||||
configData.StartTime = $"{nowYear}/{nowMonth}/{now.Day} {now.Hour}:{configData.StartTime}";
|
||||
configData.EndTime = $"{nowYear}/{nowMonth}/{now.Day} {now.Hour}:{configData.EndTime}";
|
||||
break;
|
||||
}
|
||||
return Task.FromResult(TimeUtils.IsBetweenTimeSpan(now, configData.StartTime, configData.EndTime));
|
||||
}
|
||||
|
||||
|
@ -52,33 +83,25 @@ public class
|
|||
public class ConfigData
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Whether to specify a year</para>
|
||||
/// <para>是否指定年份</para>
|
||||
/// <para>Date specifies the level</para>
|
||||
/// <para>日期指定的等级</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>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).</para>
|
||||
///<para>如果为true,那么可以在StartTime和EndTime内指定Year。指定年份被用于在特定的年份仅执行一次,而未指定年份的配置会自动补充为当前年份(每年执行)。</para>
|
||||
///<para>Level 0: Specify complete yyyy/MM/DD hh:mm:ss, level 1: yyyy (year automatically uses this year), Level 2: yyyy/MM (year and month automatically uses this month), Level 3: yyyy/MM/DD (automatically uses today), level 4: yyyy/MM/dd hh(The current hour is automatically used)</para>
|
||||
///<para>等级0:指定完整的yyyy/MM/dd hh:mm:ss,等级1:yyyy(年份自动采用今年),等级2:yyyy/MM(年份和月份自动采用本年本月),等级3:yyyy/MM/dd(自动采用今天),等级4:yyyy/MM/dd hh(自动采用当前小时)</para>
|
||||
/// </remarks>
|
||||
public bool SpecifiedYear { get; set; }
|
||||
public int? DateSpecifiesLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Start time</para>
|
||||
/// <para>起始时间</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>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.</para>
|
||||
///<para>若未指定年份,则可填入格式为MM-dd hh:mm:ss的数据,若指定了年份,那么请填入yyyy-MM-dd hh:mm:ss格式数据。</para>
|
||||
/// </remarks>
|
||||
public string? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>End time</para>
|
||||
/// <para>结束时间</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>See StartTime</para>
|
||||
///<para>同StartTime</para>
|
||||
/// </remarks>
|
||||
public string? EndTime { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using ColdMint.scripts.debug;
|
||||
|
||||
namespace ColdMint.scripts.utils;
|
||||
|
||||
|
@ -27,6 +28,8 @@ public static class TimeUtils
|
|||
var dtEndTime = Convert.ToDateTime(endTime);
|
||||
var compNum1 = DateTime.Compare(dateTime, dtStartTime);
|
||||
var compNum2 = DateTime.Compare(dateTime, dtEndTime);
|
||||
return compNum1 >= 0 && compNum2 <= 0;
|
||||
var result = compNum1 >= 0 && compNum2 <= 0;
|
||||
LogCat.LogWithFormat("time_range_debug", dateTime, dtStartTime, dtEndTime, result);
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user