Add probability-based and time-interval based room injection processors.
加入基于概率的和基于时间间隔的房间注入处理器。
This commit is contained in:
parent
959dcc3092
commit
a957c91ffe
|
@ -8,31 +8,7 @@
|
|||
},
|
||||
{
|
||||
"FromId": "4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03",
|
||||
"ToId": "9d764cca-5057-470a-976d-ba472a21e2cc",
|
||||
"FromPort": 0,
|
||||
"ToPort": 0
|
||||
},
|
||||
{
|
||||
"FromId": "4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03",
|
||||
"ToId": "cf04b0af-5940-4d8d-b081-d0b597583771",
|
||||
"FromPort": 0,
|
||||
"ToPort": 0
|
||||
},
|
||||
{
|
||||
"FromId": "9d764cca-5057-470a-976d-ba472a21e2cc",
|
||||
"ToId": "96f264c0-7169-4916-904f-e0384564e491",
|
||||
"FromPort": 0,
|
||||
"ToPort": 0
|
||||
},
|
||||
{
|
||||
"FromId": "96f264c0-7169-4916-904f-e0384564e491",
|
||||
"ToId": "197d7935-be4f-4808-9264-0848c8069309",
|
||||
"FromPort": 0,
|
||||
"ToPort": 0
|
||||
},
|
||||
{
|
||||
"FromId": "cf04b0af-5940-4d8d-b081-d0b597583771",
|
||||
"ToId": "26822086-6b19-482f-92b9-71fa8eb3f20c",
|
||||
"ToId": "ba32e05c-0c80-4a79-b5ce-5b8150400e05",
|
||||
"FromPort": 0,
|
||||
"ToPort": 0
|
||||
}
|
||||
|
@ -47,7 +23,9 @@
|
|||
],
|
||||
"Tags": [
|
||||
"StartingRoom"
|
||||
]
|
||||
],
|
||||
"RoomInjectionProcessorId": null,
|
||||
"RoomInjectionProcessorConfig": null
|
||||
},
|
||||
{
|
||||
"Id": "4ae948ea-82b7-4b2d-bec2-19ed8a9d4c03",
|
||||
|
@ -56,52 +34,19 @@
|
|||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon/utilityRoom.tscn"
|
||||
],
|
||||
"Tags": null
|
||||
"Tags": null,
|
||||
"RoomInjectionProcessorId": null,
|
||||
"RoomInjectionProcessorConfig": null
|
||||
},
|
||||
{
|
||||
"Id": "9d764cca-5057-470a-976d-ba472a21e2cc",
|
||||
"Id": "ba32e05c-0c80-4a79-b5ce-5b8150400e05",
|
||||
"Title": "房间3",
|
||||
"Description": "",
|
||||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon"
|
||||
],
|
||||
"Tags": null
|
||||
},
|
||||
{
|
||||
"Id": "cf04b0af-5940-4d8d-b081-d0b597583771",
|
||||
"Title": "房间8",
|
||||
"Description": "",
|
||||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon/"
|
||||
],
|
||||
"Tags": null
|
||||
},
|
||||
{
|
||||
"Id": "96f264c0-7169-4916-904f-e0384564e491",
|
||||
"Title": "房间5",
|
||||
"Description": "",
|
||||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon"
|
||||
],
|
||||
"Tags": null
|
||||
},
|
||||
{
|
||||
"Id": "197d7935-be4f-4808-9264-0848c8069309",
|
||||
"Title": "房间6",
|
||||
"Description": "",
|
||||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon"
|
||||
],
|
||||
"Tags": null
|
||||
},
|
||||
{
|
||||
"Id": "26822086-6b19-482f-92b9-71fa8eb3f20c",
|
||||
"Title": "房间7",
|
||||
"Description": "",
|
||||
"RoomTemplateSet": [
|
||||
"res://prefab/roomTemplates/dungeon"
|
||||
],
|
||||
"Tags": null
|
||||
"Tags": null,
|
||||
"RoomInjectionProcessorData": "[\n {\n \"Id\": \"Chance\",\n \"Config\": \"{\\\"Chance\\\":35.5}\"\n }\n]"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -16,4 +16,4 @@ 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}に配置しました。
|
||||
slogan_not_exist,找不到位于{0}的标语文件。,The tagline file at {0} could not be found.,{0}にある標語ファイルが見つかりません。
|
||||
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内に登録されているかどうか検出してください。
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -30,4 +30,5 @@ load,加载,Load,ろーど
|
|||
delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します
|
||||
re_create_map,重新创建地图,Re-create map,地図を再作成します
|
||||
seed_info,种子:{0},Seed: {0},シード:{0}
|
||||
tags,标签,Tags,と呼ぶ
|
||||
tags,标签,Tags,と呼ぶ
|
||||
room_injection_processor,房间注入处理器,Room injection processor,部屋注入処理器
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -73,10 +73,10 @@ text = "room_template_collection_prompt"
|
|||
|
||||
[node name="RoomTemplateTipsLabel" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 1
|
||||
offset_left = 18.0
|
||||
offset_top = 319.0
|
||||
offset_right = 265.0
|
||||
offset_bottom = 344.0
|
||||
offset_left = 16.0
|
||||
offset_top = 259.0
|
||||
offset_right = 263.0
|
||||
offset_bottom = 284.0
|
||||
text = "errorTip"
|
||||
|
||||
[node name="RoomNameLineEdit" type="LineEdit" parent="CreateOrEditorPanel"]
|
||||
|
@ -141,25 +141,43 @@ anchor_right = 1.0
|
|||
offset_left = 9.0
|
||||
offset_top = 184.0
|
||||
offset_right = -11.0
|
||||
offset_bottom = 298.0
|
||||
offset_bottom = 245.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="Label5" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 0
|
||||
offset_left = 21.0
|
||||
offset_top = 354.0
|
||||
offset_right = 61.0
|
||||
offset_bottom = 379.0
|
||||
offset_left = 16.0
|
||||
offset_top = 289.0
|
||||
offset_right = 56.0
|
||||
offset_bottom = 314.0
|
||||
text = "tags"
|
||||
|
||||
[node name="TagLineEdit" type="LineEdit" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = 388.0
|
||||
offset_right = -15.0
|
||||
offset_bottom = 421.0
|
||||
offset_left = 11.0
|
||||
offset_top = 324.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = 357.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="Label7" type="Label" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 1
|
||||
offset_left = 14.0
|
||||
offset_top = 368.0
|
||||
offset_right = 283.0
|
||||
offset_bottom = 393.0
|
||||
text = "room_injection_processor"
|
||||
|
||||
[node name="RoomInjectionProcessorDataTextEdit" type="TextEdit" parent="CreateOrEditorPanel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_left = 14.0
|
||||
offset_top = 404.0
|
||||
offset_right = -25.0
|
||||
offset_bottom = 493.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
|
|
|
@ -149,6 +149,20 @@ public static class Config
|
|||
return OS.HasFeature("editor");
|
||||
}
|
||||
|
||||
public class RoomInjectionProcessorId
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Chance</para>
|
||||
/// <para>概率的</para>
|
||||
/// </summary>
|
||||
public const string Chance = "Chance";
|
||||
/// <summary>
|
||||
/// <para>TimeInterval</para>
|
||||
/// <para>时间范围的</para>
|
||||
/// </summary>
|
||||
public const string TimeInterval = "TimeInterval";
|
||||
}
|
||||
|
||||
public enum OsEnum
|
||||
{
|
||||
//unknown
|
||||
|
|
20
scripts/levelGraphEditor/RoomInjectionProcessorData.cs
Normal file
20
scripts/levelGraphEditor/RoomInjectionProcessorData.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
namespace ColdMint.scripts.levelGraphEditor;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room injector data</para>
|
||||
/// <para>房间注入器数据</para>
|
||||
/// </summary>
|
||||
public class RoomInjectionProcessorData
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Room injection processor ID</para>
|
||||
/// <para>房间注入处理器ID</para>
|
||||
/// </summary>
|
||||
public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room injection processor configuration information</para>
|
||||
/// <para>房间注入处理器的配置信息</para>
|
||||
/// </summary>
|
||||
public string? Config { get; set; }
|
||||
}
|
|
@ -12,6 +12,11 @@ public class RoomNodeData
|
|||
|
||||
public string[]? Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room injector data</para>
|
||||
/// <para>房间注入器数据</para>
|
||||
/// </summary>
|
||||
public string? RoomInjectionProcessorData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Whether a tag is held</para>
|
||||
|
|
|
@ -260,7 +260,6 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
roomNode.QueueFree();
|
||||
_selectedNodes.Remove(node);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -356,7 +355,8 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate
|
|||
Title = _nodeBinding.RoomNameLineEdit.Text,
|
||||
Description = _nodeBinding.RoomDescriptionLineEdit.Text,
|
||||
RoomTemplateSet = roomTemplateArray,
|
||||
Tags = tagArray
|
||||
Tags = tagArray,
|
||||
RoomInjectionProcessorData = _nodeBinding.RoomInjectionProcessorDataTextEdit?.Text
|
||||
};
|
||||
if (!_hasStartNode && roomNodeData.HasTag(Config.RoomDataTag.StartingRoom))
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.IO;
|
|||
using System.Text;
|
||||
using ColdMint.scripts.camp;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.map;
|
||||
using ColdMint.scripts.map.roomInjectionProcessor;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.loader.uiLoader;
|
||||
|
@ -35,6 +37,9 @@ public partial class MainMenuLoader : UiLoaderTemplate
|
|||
//在发行版禁用所有日志。
|
||||
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
||||
}
|
||||
|
||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
||||
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
||||
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
namespace ColdMint.scripts.map;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room injection strategy</para>
|
||||
/// <para>房间注入策略</para>
|
||||
/// </summary>
|
||||
public interface IRoomInjectionStrategy
|
||||
{
|
||||
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ColdMint.scripts.debug;
|
||||
using ColdMint.scripts.levelGraphEditor;
|
||||
using ColdMint.scripts.map.dateBean;
|
||||
using ColdMint.scripts.map.events;
|
||||
using ColdMint.scripts.map.interfaces;
|
||||
using ColdMint.scripts.map.LayoutParsingStrategy;
|
||||
using ColdMint.scripts.map.layoutStrategy;
|
||||
using ColdMint.scripts.map.room;
|
||||
using ColdMint.scripts.serialization;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
|
@ -64,7 +66,7 @@ public static class MapGenerator
|
|||
|
||||
return _roomInjectionProcessorsDictionary.TryAdd(key, roomInjectionProcessor);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>Log out of the room injection processor</para>
|
||||
/// <para>注销房间注入处理器</para>
|
||||
|
@ -77,7 +79,7 @@ public static class MapGenerator
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return _roomInjectionProcessorsDictionary.Remove(id);
|
||||
}
|
||||
|
||||
|
@ -224,6 +226,46 @@ public static class MapGenerator
|
|||
continue;
|
||||
}
|
||||
|
||||
var roomInjectionProcessorData = roomNodeData.RoomInjectionProcessorData;
|
||||
//Whether room can be placed
|
||||
//是否可放置房间
|
||||
var canBePlaced = true;
|
||||
if (_roomInjectionProcessorsDictionary != null && !string.IsNullOrEmpty(roomInjectionProcessorData))
|
||||
{
|
||||
var roomInjectionProcessorDataArray =
|
||||
JsonSerialization.Deserialize<RoomInjectionProcessorData[]>(roomInjectionProcessorData);
|
||||
if (roomInjectionProcessorDataArray != null && roomInjectionProcessorDataArray.Length > 0)
|
||||
{
|
||||
foreach (var injectionProcessorData in roomInjectionProcessorDataArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(injectionProcessorData.Id) || string.IsNullOrEmpty(injectionProcessorData.Config))
|
||||
{
|
||||
//The data is incomplete, and the injectionProcessorData is ignored.
|
||||
//数据不全,忽略injectionProcessorData。
|
||||
continue;
|
||||
}
|
||||
if (!_roomInjectionProcessorsDictionary.TryGetValue(injectionProcessorData.Id,
|
||||
out var roomInjectionProcessor))
|
||||
{
|
||||
//If the room injection processor cannot be found, a print error occurs.
|
||||
//如果找不到房间注入处理器,那么打印错误。
|
||||
LogCat.LogErrorWithFormat("room_injection_processor_does_not_exist", injectionProcessorData.Id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (await roomInjectionProcessor.CanBePlaced(randomNumberGenerator,
|
||||
injectionProcessorData.Config)) continue;
|
||||
//If the room cannot be placed, then out of the loop.
|
||||
//如果此房间不能被放置,那么跳出循环。
|
||||
canBePlaced = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!canBePlaced)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var nextParentNodeId = await _layoutParsingStrategy.GetNextParentNodeId();
|
||||
Room? parentRoomNode = null;
|
||||
if (nextParentNodeId != null)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using ColdMint.scripts.map.dateBean;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.map.interfaces;
|
||||
|
||||
|
@ -15,11 +15,19 @@ public interface IRoomInjectionProcessor
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetId();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>The processing method should return to the room to place the data</para>
|
||||
/// <para>处理方法,应当返回房间放置数据</para>
|
||||
/// <para>Whether it can be placed on the map</para>
|
||||
/// <para>是否能够被放置到地图内</para>
|
||||
/// </summary>
|
||||
/// <param name="randomNumberGenerator">
|
||||
///<para>Random probability generator based on world seed</para>
|
||||
///<para>根据世界种子确定的随机概率生成器</para>
|
||||
/// </param>
|
||||
/// <param name="jsonConfigData">
|
||||
///<para>Inject data into the processor</para>
|
||||
///<para>注入处理器的数据</para>
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public Task<RoomPlacementData?> Processor();
|
||||
public Task<bool> CanBePlaced(RandomNumberGenerator randomNumberGenerator, string? jsonConfigData);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.map.roomInjectionProcessor;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Probabilistic room injection processor</para>
|
||||
/// <para>概率的房间注入处理器</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>This processor allows you to specify a probability and then decide whether to generate a room based on that probability.</para>
|
||||
///<para>此处理器允许指定一个概率,然后根据概率来决定是否生成房间。</para>
|
||||
/// </remarks>
|
||||
public class ChanceRoomInjectionProcessor : RoomInjectionProcessorTemplate<ChanceRoomInjectionProcessor.ConfigData>
|
||||
{
|
||||
public override string GetId()
|
||||
{
|
||||
return Config.RoomInjectionProcessorId.Chance;
|
||||
}
|
||||
|
||||
protected override Task<bool> OnCreateConfigData(RandomNumberGenerator randomNumberGenerator, ConfigData configData)
|
||||
{
|
||||
if (configData.Chance == null)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
//Generate a random number between 1 and 10000.
|
||||
//生成1-10000的随机数。
|
||||
var round = randomNumberGenerator.Randi() % 10000 + 1;
|
||||
//If the random number is less than or equal to the probability, the room is generated.
|
||||
//如果随机数小于等于概率,则生成房间。
|
||||
return Task.FromResult(round <= configData.Chance * 100);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>Configuration Data</para>
|
||||
/// <para>配置数据</para>
|
||||
/// </summary>
|
||||
public class ConfigData
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>The probability of generating this room</para>
|
||||
/// <para>生成此房间的概率</para>
|
||||
/// </summary>
|
||||
/// <para>
|
||||
///<para>The value ranges from 1 to 100. For example, if it is set to 1.5, it means that there is a 1.5% probability of generating this room.</para>
|
||||
///<para>支持小数,范围为1-100。例如,如果设置为1.5,则表示1.5%的概率生成此房间。</para>
|
||||
/// </para>
|
||||
public float? Chance { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
using System.Threading.Tasks;
|
||||
using ColdMint.scripts.map.interfaces;
|
||||
using ColdMint.scripts.serialization;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.map.roomInjectionProcessor;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Room injection processor template</para>
|
||||
/// <para>房间注入处理器模板</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="TConfig"></typeparam>
|
||||
public abstract class RoomInjectionProcessorTemplate<TConfig> : IRoomInjectionProcessor
|
||||
{
|
||||
public abstract string GetId();
|
||||
|
||||
public Task<bool> CanBePlaced(RandomNumberGenerator randomNumberGenerator, string? jsonConfigData)
|
||||
{
|
||||
if (jsonConfigData == null)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
var configData = JsonSerialization.Deserialize<TConfig>(jsonConfigData);
|
||||
if (configData == null)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
return OnCreateConfigData(randomNumberGenerator, configData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>When creating a configuration class</para>
|
||||
/// <para>当创建配置类时</para>
|
||||
/// </summary>
|
||||
/// <param name="randomNumberGenerator"></param>
|
||||
/// <param name="configData"></param>
|
||||
/// <returns></returns>
|
||||
protected abstract Task<bool> OnCreateConfigData(RandomNumberGenerator randomNumberGenerator, TConfig configData);
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ColdMint.scripts.utils;
|
||||
using Godot;
|
||||
|
||||
namespace ColdMint.scripts.map.roomInjectionProcessor;
|
||||
|
||||
/// <summary>
|
||||
/// <para>Time interval for room injection processor</para>
|
||||
/// <para>时间区间的房间注入处理器</para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///<para>This processor allows you to specify a time range and allows room generation within the specified time range.</para>
|
||||
///<para>此处理器允许指定一个时间范围,并在指定的时间范围内允许生成房间。</para>
|
||||
/// </remarks>
|
||||
public class
|
||||
TimeIntervalRoomInjectorProcessor : RoomInjectionProcessorTemplate<TimeIntervalRoomInjectorProcessor.ConfigData>
|
||||
{
|
||||
public override string GetId()
|
||||
{
|
||||
return Config.RoomInjectionProcessorId.TimeInterval;
|
||||
}
|
||||
|
||||
protected override Task<bool> 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
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Whether to specify a year</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>
|
||||
/// </remarks>
|
||||
public bool SpecifiedYear { 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; }
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ public class LevelGraphEditorBinding : INodeBinding
|
|||
public Button? ShowLoadPanelButton;
|
||||
public Button? DeleteSelectedNodeButton;
|
||||
public LineEdit? TagLineEdit;
|
||||
public TextEdit? RoomInjectionProcessorDataTextEdit;
|
||||
public void Binding(Node root)
|
||||
{
|
||||
RoomTemplateTipsLabel = root.GetNode<Label>("CreateOrEditorPanel/RoomTemplateTipsLabel");
|
||||
|
@ -54,5 +55,6 @@ public class LevelGraphEditorBinding : INodeBinding
|
|||
RoomDescriptionLineEdit = root.GetNode<LineEdit>("CreateOrEditorPanel/RoomDescriptionLineEdit");
|
||||
CreateRoomButton = root.GetNode<Button>("CreateOrEditorPanel/CreateRoomButton");
|
||||
TagLineEdit = root.GetNode<LineEdit>("CreateOrEditorPanel/TagLineEdit");
|
||||
RoomInjectionProcessorDataTextEdit = root.GetNode<TextEdit>("CreateOrEditorPanel/RoomInjectionProcessorDataTextEdit");
|
||||
}
|
||||
}
|
32
scripts/utils/TimeUtils.cs
Normal file
32
scripts/utils/TimeUtils.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
namespace ColdMint.scripts.utils;
|
||||
|
||||
public static class TimeUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Determines whether the specified time is within the specified range</para>
|
||||
/// <para>判断指定的时间是否在指定的范围</para>
|
||||
/// </summary>
|
||||
/// <param name="dateTime">
|
||||
/// <para>The value is a string in the format yyyy-MM-dd hh:mm:ss</para>
|
||||
/// <para>指定时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
||||
/// </param>
|
||||
/// <param name="startTime">
|
||||
///<para>The value is a string of characters in the format yyyy-MM-dd hh:mm:ss</para>
|
||||
/// <para>开始时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
||||
/// </param>
|
||||
/// <param name="endTime">
|
||||
/// <para>End time The value is a string in the format yyyy-MM-dd hh:mm:ss</para>
|
||||
///<para>结束时间,字符串类型,形如:yyyy-MM-dd hh:mm:ss</para>
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public static bool IsBetweenTimeSpan(DateTime dateTime, string startTime, string endTime)
|
||||
{
|
||||
var dtStartTime = Convert.ToDateTime(startTime);
|
||||
var dtEndTime = Convert.ToDateTime(endTime);
|
||||
var compNum1 = DateTime.Compare(dateTime, dtStartTime);
|
||||
var compNum2 = DateTime.Compare(dateTime, dtEndTime);
|
||||
return compNum1 >= 0 && compNum2 <= 0;
|
||||
}
|
||||
}
|
|
@ -121,9 +121,9 @@ public partial class WeaponTemplate : RigidBody2D, IItem
|
|||
var damage = new Damage
|
||||
{
|
||||
MaxDamage = Math.Abs(_maxContactInjury),
|
||||
MinDamage = Math.Abs(_minContactInjury)
|
||||
MinDamage = Math.Abs(_minContactInjury),
|
||||
Attacker = ownerCharacterTemplate
|
||||
};
|
||||
damage.Attacker = ownerCharacterTemplate;
|
||||
damage.CreateDamage();
|
||||
damage.MoveLeft = LinearVelocity.X < 0;
|
||||
damage.Type = Config.DamageType.Physical;
|
||||
|
|
Loading…
Reference in New Issue
Block a user