Skip to content

Commit b2eb71c

Browse files
committed
Feature: Add example of lambda function hotfix
1 parent 8461933 commit b2eb71c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ExampleModCode.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ public void Reload()
3232
// 实现了重载切换ExampleTrait的action_special_effect
3333
_reload_switch = !_reload_switch;
3434
var example_trait_to_update = AssetManager.traits.get("ExampleTrait");
35-
example_trait_to_update.action_special_effect = _reload_switch ? ExampleActions.example_trait_special_effect : null;
35+
example_trait_to_update.action_special_effect = _reload_switch
36+
? ExampleActions.example_trait_special_effect
37+
: [Hotfixable](pTarget, pTile) =>
38+
{
39+
// 用于重载的匿名函数示例
40+
if (pTarget != null) return false;
41+
// You can modify the method when game running. And click the reload button in the mod menu to reload the method.
42+
// 你可以在游戏运行时修改方法,然后点击mod菜单中的reload按钮来重新加载方法。
43+
ExampleModMain.LogInfo($"lambda function called");
44+
return true;
45+
};
3646
example_trait_to_update.special_effect_interval = 1f;
47+
// 重载匿名函数示例
48+
if (!_reload_switch) example_trait_to_update.action_special_effect(null, null);
3749

3850
// 将特质的效果更新即时应用于所有单位.
3951
foreach(var actor in World.world.units){

0 commit comments

Comments
 (0)