提交Demo。
This commit is contained in:
parent
b84fa3da0b
commit
c4889d67b6
|
@ -10,6 +10,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
|
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0-preview.6.24327.7" />
|
||||||
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -3,6 +3,9 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ColdMint.scripts.utils;
|
using ColdMint.scripts.utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using OpenTelemetry.Exporter;
|
||||||
|
using OpenTelemetry.Logs;
|
||||||
|
|
||||||
namespace ColdMint.scripts.debug;
|
namespace ColdMint.scripts.debug;
|
||||||
|
|
||||||
|
@ -27,19 +30,19 @@ public static class LogCat
|
||||||
/// <para>阵营管理器</para>
|
/// <para>阵营管理器</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string CampManager = "CampManager";
|
public const string CampManager = "CampManager";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>State context</para>
|
/// <para>State context</para>
|
||||||
/// <para>状态上下文</para>
|
/// <para>状态上下文</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StateContext = "StateContext";
|
public const string StateContext = "StateContext";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>StateMachineTemplate</para>
|
/// <para>StateMachineTemplate</para>
|
||||||
/// <para>状态机模板</para>
|
/// <para>状态机模板</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StateMachineTemplate = "StateMachineTemplate";
|
public const string StateMachineTemplate = "StateMachineTemplate";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Pursuit enemy processor</para>
|
/// <para>Pursuit enemy processor</para>
|
||||||
/// <para>追击敌人处理器</para>
|
/// <para>追击敌人处理器</para>
|
||||||
|
@ -103,6 +106,25 @@ public static class LogCat
|
||||||
private static HashSet<string> DisabledLogLabels { get; } = [];
|
private static HashSet<string> DisabledLogLabels { get; } = [];
|
||||||
|
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var loggerFactory = LoggerFactory.Create(builder =>
|
||||||
|
{
|
||||||
|
builder.AddOpenTelemetry(options => { options.AddOtlpExporter(OtlpExporterOptions); });
|
||||||
|
});
|
||||||
|
var logger = loggerFactory.CreateLogger("323");
|
||||||
|
logger.Log(LogLevel.Debug, "你好");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OtlpExporterOptions(OtlpExporterOptions options)
|
||||||
|
{
|
||||||
|
options.Protocol = OtlpExportProtocol.HttpProtobuf;
|
||||||
|
options.Endpoint = new Uri("http://test.coldmint.top/api/default/traces");
|
||||||
|
options.Headers =
|
||||||
|
"Authorization=Basic cm9vdEBleGFtcGxlLmNvbTp5V0kwVzZYcWhteTBzQml3,organization=default,stream-name=default";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Disable log Label</para>
|
/// <para>Disable log Label</para>
|
||||||
/// <para>禁用某个日志标签</para>
|
/// <para>禁用某个日志标签</para>
|
||||||
|
|
|
@ -20,148 +20,149 @@ namespace ColdMint.scripts.loader.uiLoader;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainMenuLoader : UiLoaderTemplate
|
public partial class MainMenuLoader : UiLoaderTemplate
|
||||||
{
|
{
|
||||||
private Button? _startGameButton;
|
private Button? _startGameButton;
|
||||||
private Label? _copyrightLabel;
|
private Label? _copyrightLabel;
|
||||||
private StringBuilder? _copyrightBuilder;
|
private StringBuilder? _copyrightBuilder;
|
||||||
private PackedScene? _gameScene;
|
private PackedScene? _gameScene;
|
||||||
private PackedScene? _contributor;
|
private PackedScene? _contributor;
|
||||||
private PackedScene? _levelGraphEditor;
|
private PackedScene? _levelGraphEditor;
|
||||||
private Label? _sloganLabel;
|
private Label? _sloganLabel;
|
||||||
private Label? _versionLabel;
|
private Label? _versionLabel;
|
||||||
private Button? _levelGraphEditorButton;
|
private Button? _levelGraphEditorButton;
|
||||||
private LinkButton? _contributorButton;
|
private LinkButton? _contributorButton;
|
||||||
|
|
||||||
public override void InitializeData()
|
public override void InitializeData()
|
||||||
{
|
{
|
||||||
if (Config.IsDebug())
|
LogCat.Init();
|
||||||
{
|
if (Config.IsDebug())
|
||||||
//Set the minimum log level to Info in debug mode.(Print all logs)
|
{
|
||||||
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
//Set the minimum log level to Info in debug mode.(Print all logs)
|
||||||
LogCat.MinLogLevel = LogCat.InfoLogLevel;
|
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
||||||
}
|
LogCat.MinLogLevel = LogCat.InfoLogLevel;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
//Disable all logs in the release version.
|
{
|
||||||
//在发行版禁用所有日志。
|
//Disable all logs in the release version.
|
||||||
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
//在发行版禁用所有日志。
|
||||||
}
|
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
||||||
|
}
|
||||||
|
|
||||||
ContributorDataManager.RegisterAllContributorData();
|
ContributorDataManager.RegisterAllContributorData();
|
||||||
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
||||||
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
||||||
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
//创建游戏数据文件夹
|
//创建游戏数据文件夹
|
||||||
var dataPath = Config.GetGameDataDirectory();
|
var dataPath = Config.GetGameDataDirectory();
|
||||||
if (!Directory.Exists(dataPath))
|
if (!Directory.Exists(dataPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dataPath);
|
Directory.CreateDirectory(dataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Registered camp
|
//Registered camp
|
||||||
//注册阵营
|
//注册阵营
|
||||||
var defaultCamp = new Camp(Config.CampId.Default)
|
var defaultCamp = new Camp(Config.CampId.Default)
|
||||||
{
|
{
|
||||||
FriendInjury = true
|
FriendInjury = true
|
||||||
};
|
};
|
||||||
CampManager.SetDefaultCamp(defaultCamp);
|
CampManager.SetDefaultCamp(defaultCamp);
|
||||||
var mazoku = new Camp(Config.CampId.Mazoku);
|
var mazoku = new Camp(Config.CampId.Mazoku);
|
||||||
CampManager.AddCamp(mazoku);
|
CampManager.AddCamp(mazoku);
|
||||||
var aborigines = new Camp(Config.CampId.Aborigines);
|
var aborigines = new Camp(Config.CampId.Aborigines);
|
||||||
CampManager.AddCamp(aborigines);
|
CampManager.AddCamp(aborigines);
|
||||||
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
||||||
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
||||||
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
||||||
|
|
||||||
//Register ItemTypes from file
|
//Register ItemTypes from file
|
||||||
//从文件注册物品类型
|
//从文件注册物品类型
|
||||||
ItemTypeRegister.RegisterFromFile();
|
ItemTypeRegister.RegisterFromFile();
|
||||||
//Hardcoded ItemTypes Register
|
//Hardcoded ItemTypes Register
|
||||||
//硬编码注册物品类型
|
//硬编码注册物品类型
|
||||||
ItemTypeRegister.StaticRegister();
|
ItemTypeRegister.StaticRegister();
|
||||||
|
|
||||||
//静态注册掉落表
|
//静态注册掉落表
|
||||||
LootRegister.StaticRegister();
|
LootRegister.StaticRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InitializeUi()
|
public override void InitializeUi()
|
||||||
{
|
{
|
||||||
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
||||||
_startGameButton = GetNode<Button>("StartGameButton");
|
_startGameButton = GetNode<Button>("StartGameButton");
|
||||||
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
||||||
//The level map editor is only available in debug mode.
|
//The level map editor is only available in debug mode.
|
||||||
//关卡图编辑器仅在调试模式可用。
|
//关卡图编辑器仅在调试模式可用。
|
||||||
_levelGraphEditorButton.Visible = Config.IsDebug();
|
_levelGraphEditorButton.Visible = Config.IsDebug();
|
||||||
_startGameButton.GrabFocus();
|
_startGameButton.GrabFocus();
|
||||||
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
||||||
//Generative copyright
|
//Generative copyright
|
||||||
//生成版权
|
//生成版权
|
||||||
_copyrightLabel = GetNode<Label>("VBoxContainer/CopyrightLabel");
|
_copyrightLabel = GetNode<Label>("VBoxContainer/CopyrightLabel");
|
||||||
_sloganLabel = GetNode<Label>("CenterContainer2/SloganLabel");
|
_sloganLabel = GetNode<Label>("CenterContainer2/SloganLabel");
|
||||||
_copyrightBuilder = new StringBuilder();
|
_copyrightBuilder = new StringBuilder();
|
||||||
_copyrightBuilder.Append('\u00a9');
|
_copyrightBuilder.Append('\u00a9');
|
||||||
var currentYear = DateTime.Now.Year;
|
var currentYear = DateTime.Now.Year;
|
||||||
_copyrightBuilder.Append(Config.CreationYear);
|
_copyrightBuilder.Append(Config.CreationYear);
|
||||||
if (currentYear != Config.CreationYear)
|
if (currentYear != Config.CreationYear)
|
||||||
{
|
{
|
||||||
_copyrightBuilder.Append('-');
|
_copyrightBuilder.Append('-');
|
||||||
_copyrightBuilder.Append(currentYear);
|
_copyrightBuilder.Append(currentYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
_copyrightBuilder.Append(' ');
|
_copyrightBuilder.Append(' ');
|
||||||
_copyrightBuilder.Append(Config.CompanyName);
|
_copyrightBuilder.Append(Config.CompanyName);
|
||||||
_copyrightBuilder.Append(" all rights reserved.");
|
_copyrightBuilder.Append(" all rights reserved.");
|
||||||
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
||||||
_versionLabel.Text = "ver." + Config.GetVersion();
|
_versionLabel.Text = "ver." + Config.GetVersion();
|
||||||
_sloganLabel.Text = SloganProvider.GetSlogan();
|
_sloganLabel.Text = SloganProvider.GetSlogan();
|
||||||
_contributorButton.Text =
|
_contributorButton.Text =
|
||||||
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
||||||
ContributorDataManager.GetContributorTotals());
|
ContributorDataManager.GetContributorTotals());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LoadUiActions()
|
public override void LoadUiActions()
|
||||||
{
|
{
|
||||||
if (_startGameButton != null)
|
if (_startGameButton != null)
|
||||||
{
|
{
|
||||||
_startGameButton.Pressed += () =>
|
_startGameButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
if (_gameScene == null)
|
if (_gameScene == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_gameScene);
|
GetTree().ChangeSceneToPacked(_gameScene);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_contributorButton != null)
|
if (_contributorButton != null)
|
||||||
{
|
{
|
||||||
_contributorButton.Pressed += () =>
|
_contributorButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
if (_contributor == null)
|
if (_contributor == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_contributor);
|
GetTree().ChangeSceneToPacked(_contributor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_levelGraphEditorButton != null)
|
if (_levelGraphEditorButton != null)
|
||||||
{
|
{
|
||||||
_levelGraphEditorButton.Pressed += () =>
|
_levelGraphEditorButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
LogCat.Log("level_graph_editor");
|
LogCat.Log("level_graph_editor");
|
||||||
if (_levelGraphEditor == null)
|
if (_levelGraphEditor == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user