Improve the log of map generator.
完善地图生成器的日志。
This commit is contained in:
parent
ace9ba5b65
commit
b0da4b049e
|
@ -1,10 +0,0 @@
|
||||||
id,zh,en,jp
|
|
||||||
Object reference not set to an instance of an object.,尝试在空对象上调用虚拟方法。,Object reference not set to an instance of an object.,空のオブジェクト上で仮想メソッドを呼び出してみます。
|
|
||||||
missing_parameters,缺少参数。,Missing parameters.,パラメータが不足しています。
|
|
||||||
room_root_node_must_be_node2d,房间根节点必须是 Node2D。,Room root node must be Node2D.,ルートノードはNode2Dでなければなりません。
|
|
||||||
width_or_height_of_room_slot_must_be_1,房间槽的宽度或高度必须为1。,The width or height of the room slot must be 1.,部屋の溝の幅または高さは1でなければなりません。
|
|
||||||
connected_room_timeout,连接房间超时。,Connecting the room timed out.,接続部屋はタイムアウトです。
|
|
||||||
projectiles_is_empty,未设置抛射体。,The projectile is not set.,射出体は設置されていません。
|
|
||||||
map_generator_missing_parameters,地图生成器缺少参数。,Map generator missing parameters.,マップジェネレータが不足しています。
|
|
||||||
map_generator_attempts_to_parse_empty_layout_diagrams,地图生成器尝试解析空的布局图。,Map generator attempts to parse empty layout diagrams.,マップジェネレータは空のレイアウト図を解析しようとしています。
|
|
||||||
map_generator_has_no_starting_room_data,地图生成器没有起点房间数据。,Map generator has no starting room data.,マップ生成器に起点部屋データはありません。
|
|
|
|
@ -1,17 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="csv_translation"
|
|
||||||
type="Translation"
|
|
||||||
uid="uid://nmtkvo0t7p7n"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
files=["res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/Error.jp.translation"]
|
|
||||||
|
|
||||||
source_file="res://locals/Error.csv"
|
|
||||||
dest_files=["res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/Error.jp.translation"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress=true
|
|
||||||
delimiter=0
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1,18 @@
|
||||||
id,zh,en,jp
|
id,zh,en,jp
|
||||||
|
map_generator_is_running,地图生成器正在运行中,请稍后重试。,"Map Generator is running, please try again later.",マップ生成器が動作中ですので、後ほどリトライしてください。
|
||||||
|
missing_parameters,缺少参数。,Missing parameters.,パラメータが不足しています。
|
||||||
|
room_root_node_must_be_node2d,房间根节点必须是 Node2D。,Room root node must be Node2D.,ルートノードはNode2Dでなければなりません。
|
||||||
|
width_or_height_of_room_slot_must_be_1,房间槽的宽度或高度必须为1。,The width or height of the room slot must be 1.,部屋の溝の幅または高さは1でなければなりません。
|
||||||
|
connected_room_timeout,连接房间超时。,Connecting the room timed out.,接続部屋はタイムアウトです。
|
||||||
|
projectiles_is_empty,未设置抛射体。,The projectile is not set.,射出体は設置されていません。
|
||||||
|
map_generator_missing_parameters,地图生成器缺少参数。,Map generator missing parameters.,マップジェネレータが不足しています。
|
||||||
|
map_generator_attempts_to_parse_empty_layout_diagrams,地图生成器尝试解析空的布局图。,Map generator attempts to parse empty layout diagrams.,マップジェネレータは空のレイアウト図を解析しようとしています。
|
||||||
|
map_generator_has_no_starting_room_data,地图生成器没有起点房间数据。,Map generator has no starting room data.,マップ生成器に起点部屋データはありません。
|
||||||
|
room_placement_strategy_terminates_map_generation,房间的放置策略终止了地图生成。,The room placement strategy terminates map generation.,部屋の配置ポリシーはマップ作成を終了します。
|
||||||
|
start_room_placement_information_returns_empty,起始房间放置信息返回空。,Start room placement information returns empty.,スタートルーム放置情報は空に戻ります。
|
||||||
|
start_room_placement_failed,起始房间放置失败。,Start room placement failed.,スタートルーム放置失敗です。
|
||||||
|
room_data_missing,房间数据缺失。,Room data missing.,部屋データが欠落しています。
|
||||||
|
failed_to_calculate_the_room_location,计算房间{0}位置时失败。,Failed to calculate the location of room {0}.,部屋{0}の位置を計算するのに失敗します。
|
||||||
|
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}に配置しました。
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -30,3 +30,4 @@ load,加载,Load,ろーど
|
||||||
delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します
|
delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します
|
||||||
re_create_map,重新创建地图,Re-create map,地図を再作成します
|
re_create_map,重新创建地图,Re-create map,地図を再作成します
|
||||||
seed_info,种子:{0},Seed: {0},シード:{0}
|
seed_info,种子:{0},Seed: {0},シード:{0}
|
||||||
|
tags,标签,Tags,と呼ぶ
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -146,8 +146,7 @@ hotbar_previous={
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/Error.jp.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation")
|
locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation")
|
||||||
locale/test="jp"
|
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
@ -135,11 +135,22 @@ grow_vertical = 0
|
||||||
text = "creation"
|
text = "creation"
|
||||||
|
|
||||||
[node name="RoomTemplateCollectionTextEdit" type="TextEdit" parent="CreateOrEditorPanel"]
|
[node name="RoomTemplateCollectionTextEdit" type="TextEdit" parent="CreateOrEditorPanel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = 9.0
|
||||||
|
offset_top = 184.0
|
||||||
|
offset_right = -11.0
|
||||||
|
offset_bottom = 298.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
|
||||||
|
[node name="Label5" type="Label" parent="CreateOrEditorPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 16.0
|
offset_left = 21.0
|
||||||
offset_top = 187.0
|
offset_top = 354.0
|
||||||
offset_right = 1111.0
|
offset_right = 61.0
|
||||||
offset_bottom = 303.0
|
offset_bottom = 379.0
|
||||||
|
text = "tags"
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
@ -68,6 +68,7 @@ public static class LogCat
|
||||||
StringBuilder.Append("INFO");
|
StringBuilder.Append("INFO");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder.Append(DateTime.Now.ToString(" yyyy-M-d HH:mm:ss : "));
|
StringBuilder.Append(DateTime.Now.ToString(" yyyy-M-d HH:mm:ss : "));
|
||||||
StringBuilder.Append(TranslationServerUtils.Translate(message));
|
StringBuilder.Append(TranslationServerUtils.Translate(message));
|
||||||
return StringBuilder;
|
return StringBuilder;
|
||||||
|
@ -120,7 +121,7 @@ public static class LogCat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GD.PrintErr(HandleMessage(WarningLogLevel, message));
|
GD.Print(HandleMessage(WarningLogLevel, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LogErrorWithFormat(string message, params object?[] args)
|
public static void LogErrorWithFormat(string message, params object?[] args)
|
||||||
|
@ -144,6 +145,16 @@ public static class LogCat
|
||||||
GD.Print(string.Format(HandleMessage(InfoLogLevel, message).ToString(), args));
|
GD.Print(string.Format(HandleMessage(InfoLogLevel, message).ToString(), args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void LogWarningWithFormat(string message, params object?[] args)
|
||||||
|
{
|
||||||
|
if (_minLogLevel > InfoLogLevel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GD.Print(string.Format(HandleMessage(WarningLogLevel, message).ToString(), args));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>This method is called when an exception is caught</para>
|
/// <para>This method is called when an exception is caught</para>
|
||||||
/// <para>当捕获异常后调用此方法</para>
|
/// <para>当捕获异常后调用此方法</para>
|
||||||
|
|
|
@ -27,6 +27,8 @@ public static class MapGenerator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static ILayoutStrategy? _layoutStrategy;
|
private static ILayoutStrategy? _layoutStrategy;
|
||||||
|
|
||||||
|
private static bool _running;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Map root node</para>
|
/// <para>Map root node</para>
|
||||||
/// <para>地图根节点</para>
|
/// <para>地图根节点</para>
|
||||||
|
@ -89,16 +91,26 @@ public static class MapGenerator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task GenerateMap()
|
public static async Task GenerateMap()
|
||||||
{
|
{
|
||||||
|
if (_running)
|
||||||
|
{
|
||||||
|
LogCat.LogWarning("map_generator_is_running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_running = true;
|
||||||
if (_layoutStrategy == null || _roomPlacementStrategy == null || _layoutParsingStrategy == null ||
|
if (_layoutStrategy == null || _roomPlacementStrategy == null || _layoutParsingStrategy == null ||
|
||||||
_mapRoot == null)
|
_mapRoot == null)
|
||||||
{
|
{
|
||||||
LogCat.LogError("map_generator_missing_parameters");
|
LogCat.LogError("map_generator_missing_parameters");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeUtils.DeleteAllChild(_mapRoot);
|
NodeUtils.DeleteAllChild(_mapRoot);
|
||||||
if (!await _roomPlacementStrategy.StartGeneration(_mapRoot))
|
if (!await _roomPlacementStrategy.StartGeneration(_mapRoot))
|
||||||
{
|
{
|
||||||
|
LogCat.LogError("room_placement_strategy_terminates_map_generation");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +121,7 @@ public static class MapGenerator
|
||||||
levelGraphEditorSaveData.RoomNodeDataList.Count == 0)
|
levelGraphEditorSaveData.RoomNodeDataList.Count == 0)
|
||||||
{
|
{
|
||||||
LogCat.LogError("map_generator_attempts_to_parse_empty_layout_diagrams");
|
LogCat.LogError("map_generator_attempts_to_parse_empty_layout_diagrams");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +136,7 @@ public static class MapGenerator
|
||||||
if (startRoomNodeData == null || string.IsNullOrEmpty(startRoomNodeData.Id))
|
if (startRoomNodeData == null || string.IsNullOrEmpty(startRoomNodeData.Id))
|
||||||
{
|
{
|
||||||
LogCat.LogError("map_generator_has_no_starting_room_data");
|
LogCat.LogError("map_generator_has_no_starting_room_data");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +145,16 @@ public static class MapGenerator
|
||||||
startRoomNodeData);
|
startRoomNodeData);
|
||||||
if (startingRoomPlacementData == null)
|
if (startingRoomPlacementData == null)
|
||||||
{
|
{
|
||||||
|
LogCat.LogError("start_room_placement_information_returns_empty");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var placeSuccess = await PlaceRoomAndAddRecord(startRoomNodeData.Id, startingRoomPlacementData, roomDictionary);
|
var placeSuccess = await PlaceRoomAndAddRecord(startRoomNodeData.Id, startingRoomPlacementData, roomDictionary);
|
||||||
if (!placeSuccess)
|
if (!placeSuccess)
|
||||||
{
|
{
|
||||||
|
LogCat.LogError("start_room_placement_failed");
|
||||||
|
_running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +165,7 @@ public static class MapGenerator
|
||||||
var roomNodeData = await _layoutParsingStrategy.Next();
|
var roomNodeData = await _layoutParsingStrategy.Next();
|
||||||
if (roomNodeData == null || string.IsNullOrEmpty(roomNodeData.Id))
|
if (roomNodeData == null || string.IsNullOrEmpty(roomNodeData.Id))
|
||||||
{
|
{
|
||||||
|
LogCat.LogWarning("room_data_missing");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,14 +186,17 @@ public static class MapGenerator
|
||||||
roomNodeData);
|
roomNodeData);
|
||||||
if (roomPlacementData == null)
|
if (roomPlacementData == null)
|
||||||
{
|
{
|
||||||
|
LogCat.LogWithFormat("failed_to_calculate_the_room_location", roomNodeData.Id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await PlaceRoomAndAddRecord(roomNodeData.Id, roomPlacementData, roomDictionary);
|
await PlaceRoomAndAddRecord(roomNodeData.Id, roomPlacementData, roomDictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
//All rooms have been placed.
|
//All rooms have been placed.
|
||||||
//所有房间已放置完毕。
|
//所有房间已放置完毕。
|
||||||
await _roomPlacementStrategy.GeneratedComplete(_mapRoot);
|
await _roomPlacementStrategy.GeneratedComplete(_mapRoot);
|
||||||
|
_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -198,15 +220,18 @@ public static class MapGenerator
|
||||||
|
|
||||||
if (dictionary.ContainsKey(roomNodeDataId))
|
if (dictionary.ContainsKey(roomNodeDataId))
|
||||||
{
|
{
|
||||||
|
LogCat.LogWithFormat("place_existing_rooms", roomNodeDataId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!await _roomPlacementStrategy.PlaceRoom(_mapRoot, roomPlacementData))
|
if (!await _roomPlacementStrategy.PlaceRoom(_mapRoot, roomPlacementData))
|
||||||
{
|
{
|
||||||
|
LogCat.LogWarningWithFormat("room_placement_failed", roomNodeDataId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dictionary.Add(roomNodeDataId, roomPlacementData.Room);
|
dictionary.Add(roomNodeDataId, roomPlacementData.Room);
|
||||||
|
LogCat.LogWithFormat("room_placement_information",roomNodeDataId,roomPlacementData.Position.ToString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using ColdMint.scripts.utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
using FileAccess = Godot.FileAccess;
|
using FileAccess = Godot.FileAccess;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public static class RoomFactory
|
||||||
|
|
||||||
var room = new Room
|
var room = new Room
|
||||||
{
|
{
|
||||||
RoomScene = GD.Load<PackedScene>(resPath)
|
RoomScene = GD.Load<PackedScene>(ResUtils.GetAbsolutePath(resPath))
|
||||||
};
|
};
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
18
scripts/utils/ResUtils.cs
Normal file
18
scripts/utils/ResUtils.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ColdMint.scripts.utils;
|
||||||
|
|
||||||
|
public class ResUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>The game returns the res directory with a.remap suffix at runtime, causing an error while loading the resource</para>
|
||||||
|
/// <para>游戏在运行时返回res目录后带有.remap后缀,导致加载资源时出错</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetAbsolutePath(string path)
|
||||||
|
{
|
||||||
|
var index = path.LastIndexOf(".remap", StringComparison.Ordinal);
|
||||||
|
return index > -1 ? path[..index] : path;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user