2024-07-16 14:11:57 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using ColdMint.scripts.camp;
|
|
|
|
|
using ColdMint.scripts.contribute;
|
2024-08-05 16:27:51 +00:00
|
|
|
|
using ColdMint.scripts.database;
|
2024-07-16 14:11:57 +00:00
|
|
|
|
using ColdMint.scripts.deathInfo;
|
|
|
|
|
using ColdMint.scripts.debug;
|
|
|
|
|
using ColdMint.scripts.inventory;
|
|
|
|
|
using ColdMint.scripts.loot;
|
|
|
|
|
using ColdMint.scripts.map;
|
|
|
|
|
using ColdMint.scripts.map.roomInjectionProcessor;
|
2024-07-21 15:18:44 +00:00
|
|
|
|
using ColdMint.scripts.mod;
|
2024-07-16 14:11:57 +00:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
namespace ColdMint.scripts.loader.uiLoader;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>SplashScreenLoader</para>
|
|
|
|
|
/// <para>启动画面加载器</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class SplashScreenLoader : UiLoaderTemplate
|
|
|
|
|
{
|
|
|
|
|
private Label? _loadingLabel;
|
|
|
|
|
private PackedScene? _mainMenuScene;
|
|
|
|
|
private AnimationPlayer? _animationPlayer;
|
2024-07-17 14:54:42 +00:00
|
|
|
|
private string _startup = "startup";
|
|
|
|
|
private Label? _nameLabel;
|
2024-07-16 14:11:57 +00:00
|
|
|
|
|
|
|
|
|
public override void InitializeData()
|
|
|
|
|
{
|
2024-10-09 02:49:10 +00:00
|
|
|
|
_mainMenuScene = ResourceLoader.Load<PackedScene>("res://scenes/mainMenu.tscn");
|
2024-07-16 14:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void InitializeUi()
|
|
|
|
|
{
|
2024-07-17 14:54:42 +00:00
|
|
|
|
_nameLabel = GetNode<Label>("NameLabel");
|
2024-07-16 14:11:57 +00:00
|
|
|
|
_loadingLabel = GetNode<Label>("loadingStateLabel");
|
|
|
|
|
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
2024-07-17 14:54:42 +00:00
|
|
|
|
//Disable animation in Debug mode.
|
|
|
|
|
//在Debug模式禁用动画。
|
|
|
|
|
if (Config.IsDebug())
|
|
|
|
|
{
|
|
|
|
|
_loadingLabel.Modulate = Colors.White;
|
|
|
|
|
_nameLabel.Modulate = Colors.White;
|
|
|
|
|
AnimationFinished(_startup);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_animationPlayer.Play(_startup);
|
|
|
|
|
_animationPlayer.AnimationFinished += AnimationFinished;
|
|
|
|
|
}
|
2024-07-16 14:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void AnimationFinished(StringName name)
|
|
|
|
|
{
|
|
|
|
|
await LoadingGlobalData();
|
|
|
|
|
if (_mainMenuScene == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetTree().ChangeSceneToPacked(_mainMenuScene);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <para>Load the game's global data</para>
|
|
|
|
|
/// <para>加载游戏的全局数据</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private async Task LoadingGlobalData()
|
|
|
|
|
{
|
|
|
|
|
//Set the minimum log level to Info in debug mode.(Print all logs)
|
|
|
|
|
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
|
|
|
|
//Disable all logs in the release version.
|
|
|
|
|
//在发行版禁用所有日志。
|
|
|
|
|
LogCat.MinLogLevel = Config.IsDebug() ? LogCat.InfoLogLevel : LogCat.DisableAllLogLevel;
|
2024-08-24 14:49:59 +00:00
|
|
|
|
AssetHolder.LoadStaticAsset();
|
2024-07-16 14:11:57 +00:00
|
|
|
|
ContributorDataManager.RegisterAllContributorData();
|
2024-10-06 04:04:59 +00:00
|
|
|
|
DeathInfoGenerator.RegisterDeathInfoHandler(new ResignationCertificateDeathInfoHandler());
|
2024-07-16 14:11:57 +00:00
|
|
|
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
|
|
|
|
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);
|
2024-07-24 15:29:22 +00:00
|
|
|
|
//Create a game data folder
|
2024-07-16 14:11:57 +00:00
|
|
|
|
//创建游戏数据文件夹
|
|
|
|
|
var dataPath = Config.GetGameDataDirectory();
|
|
|
|
|
if (!Directory.Exists(dataPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(dataPath);
|
|
|
|
|
}
|
2024-07-28 02:09:44 +00:00
|
|
|
|
|
2024-08-05 16:27:51 +00:00
|
|
|
|
var databasePath = Config.GetDataBaseDirectory();
|
|
|
|
|
if (!Directory.Exists(databasePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(databasePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataBaseManager.InitDataBases(databasePath);
|
2024-07-16 14:11:57 +00:00
|
|
|
|
//Registered camp
|
|
|
|
|
//注册阵营
|
|
|
|
|
var defaultCamp = new Camp(Config.CampId.Default)
|
|
|
|
|
{
|
|
|
|
|
FriendInjury = true
|
|
|
|
|
};
|
|
|
|
|
CampManager.SetDefaultCamp(defaultCamp);
|
2024-08-14 15:08:07 +00:00
|
|
|
|
var mazoku = new Camp(Config.CampId.Mazoku)
|
|
|
|
|
{
|
|
|
|
|
FriendInjury = true
|
|
|
|
|
};
|
2024-07-16 14:11:57 +00:00
|
|
|
|
CampManager.AddCamp(mazoku);
|
|
|
|
|
var aborigines = new Camp(Config.CampId.Aborigines);
|
|
|
|
|
CampManager.AddCamp(aborigines);
|
|
|
|
|
//Register ItemTypes from file
|
|
|
|
|
//从文件注册物品类型
|
|
|
|
|
ItemTypeRegister.RegisterFromFile();
|
|
|
|
|
//Hardcoded ItemTypes Register
|
|
|
|
|
//硬编码注册物品类型
|
|
|
|
|
ItemTypeRegister.StaticRegister();
|
|
|
|
|
//静态注册掉落表
|
|
|
|
|
LootRegister.StaticRegister();
|
2024-07-24 15:29:22 +00:00
|
|
|
|
//Load mod
|
|
|
|
|
//加载模组
|
2024-07-28 02:09:44 +00:00
|
|
|
|
if (Config.EnableMod())
|
2024-07-24 15:29:22 +00:00
|
|
|
|
{
|
2024-07-28 02:09:44 +00:00
|
|
|
|
var modPath = Config.GetModDataDirectory();
|
|
|
|
|
if (!Directory.Exists(modPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(modPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ModLoader.Init();
|
|
|
|
|
ModLoader.LoadAllMods(modPath);
|
2024-07-24 15:29:22 +00:00
|
|
|
|
}
|
2024-07-28 02:09:44 +00:00
|
|
|
|
|
2024-07-28 03:12:53 +00:00
|
|
|
|
await Task.Yield();
|
2024-07-16 14:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|