1
1
using System . IO ;
2
- using NeoModLoader . api ;
3
- using ExampleMod . UI ;
4
2
using ExampleMod . Content ;
3
+ using ExampleMod . UI ;
4
+ using NeoModLoader . api ;
5
5
using NeoModLoader . api . attributes ;
6
6
using NeoModLoader . General ;
7
7
8
8
namespace ExampleMod ;
9
9
10
- public class ExampleModMain : BasicMod < ExampleModMain > , IReloadable {
11
- protected override void OnModLoad ( ) {
12
- LogInfo ( "Hello World!" ) ;
13
- ExampleGodPowers . init ( ) ;
14
- ExampleTab . Init ( ) ;
15
- ExampleTraits . Init ( ) ;
16
- }
17
- public static void Called ( ) {
18
- LogInfo ( "Hello World From Another!" ) ;
19
- }
20
-
10
+ public class ExampleModMain : BasicMod < ExampleModMain > , IReloadable
11
+ {
21
12
private static bool _reload_switch ;
13
+
22
14
[ Hotfixable ]
23
15
public void Reload ( )
24
16
{
25
17
// Reload locales when mod loaded, it's optional.
26
18
// 重载模组时重新加载语言文件, 不是必需的
27
19
var locale_dir = GetLocaleFilesDirectory ( GetDeclaration ( ) ) ;
28
- foreach ( var file in Directory . GetFiles ( locale_dir , "*.json" ) ) {
20
+ foreach ( var file in Directory . GetFiles ( locale_dir , "*.json" ) )
21
+ {
29
22
LM . LoadLocale ( Path . GetFileNameWithoutExtension ( file ) , file ) ;
30
23
}
31
-
24
+
32
25
// 实现了重载切换ExampleTrait的action_special_effect
33
26
_reload_switch = ! _reload_switch ;
34
27
var example_trait_to_update = AssetManager . traits . get ( "ExampleTrait" ) ;
@@ -40,18 +33,34 @@ public void Reload()
40
33
if ( pTarget != null ) return false ;
41
34
// You can modify the method when game running. And click the reload button in the mod menu to reload the method.
42
35
// 你可以在游戏运行时修改方法,然后点击mod菜单中的reload按钮来重新加载方法。
43
- ExampleModMain . LogInfo ( $ "lambda function called") ;
36
+ LogInfo ( $ "lambda function called") ;
44
37
return true ;
45
38
} ;
46
39
example_trait_to_update . special_effect_interval = 1f ;
47
40
// 重载匿名函数示例
48
41
if ( ! _reload_switch ) example_trait_to_update . action_special_effect ( null , null ) ;
49
-
42
+
50
43
// 将特质的效果更新即时应用于所有单位.
51
- foreach ( var actor in World . world . units ) {
52
- if ( actor != null && actor . isAlive ( ) && actor . hasTrait ( "ExampleTrait" ) ) {
44
+ foreach ( var actor in World . world . units )
45
+ {
46
+ if ( actor != null && actor . isAlive ( ) && actor . hasTrait ( "ExampleTrait" ) )
47
+ {
53
48
actor . setStatsDirty ( ) ;
54
49
}
55
50
}
56
51
}
52
+
53
+ protected override void OnModLoad ( )
54
+ {
55
+ LogInfo ( "Hello World!" ) ;
56
+ ExampleNameGenerators . init ( ) ;
57
+ ExampleGodPowers . init ( ) ;
58
+ ExampleTab . Init ( ) ;
59
+ ExampleTraits . Init ( ) ;
60
+ }
61
+
62
+ public static void Called ( )
63
+ {
64
+ LogInfo ( "Hello World From Another!" ) ;
65
+ }
57
66
}
0 commit comments