Skip to content

Commit 8461933

Browse files
committed
Feature: Reload locales and add comment
1 parent dfd19ab commit 8461933

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ExampleModCode.cs

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
using System.IO;
12
using NeoModLoader.api;
23
using ExampleMod.UI;
34
using ExampleMod.Content;
45
using NeoModLoader.api.attributes;
6+
using NeoModLoader.General;
57

68
namespace ExampleMod;
79

@@ -17,13 +19,23 @@ public static void Called(){
1719
}
1820

1921
private static bool _reload_switch;
22+
[Hotfixable]
2023
public void Reload()
2124
{
25+
// Reload locales when mod loaded, it's optional.
26+
// 重载模组时重新加载语言文件, 不是必需的
27+
var locale_dir = GetLocaleFilesDirectory(GetDeclaration());
28+
foreach(var file in Directory.GetFiles(locale_dir, "*.json")){
29+
LM.LoadLocale(Path.GetFileNameWithoutExtension(file), file);
30+
}
31+
32+
// 实现了重载切换ExampleTrait的action_special_effect
2233
_reload_switch = !_reload_switch;
2334
var example_trait_to_update = AssetManager.traits.get("ExampleTrait");
2435
example_trait_to_update.action_special_effect = _reload_switch ? ExampleActions.example_trait_special_effect : null;
2536
example_trait_to_update.special_effect_interval = 1f;
2637

38+
// 将特质的效果更新即时应用于所有单位.
2739
foreach(var actor in World.world.units){
2840
if(actor!=null && actor.isAlive() && actor.hasTrait("ExampleTrait")){
2941
actor.setStatsDirty();

0 commit comments

Comments
 (0)