Reme

添加充能球

先创建类:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Godot;
using MegaCrit.Sts2.Core.Commands;
using MegaCrit.Sts2.Core.Entities.Creatures;
using MegaCrit.Sts2.Core.GameActions.Multiplayer;
using STS2RitsuLib.Interop.AutoRegistration;
using STS2RitsuLib.Scaffolding.Content;

namespace Test.Scripts;

[RegisterOrb]
public class TestOrb : ModOrbTemplate
{
// 被动效果数值,ModifyOrbValue表示是否吃集中等
public override decimal PassiveVal => ModifyOrbValue(1);

// 激发效果数值
public override decimal EvokeVal => ModifyOrbValue(2);

// 暗色,使用球的主体色的暗色调
public override Color DarkenedColor => new(0.1f, 0.2f, 0.5f);

public override OrbAssetProfile AssetProfile => new(
// 提示文本小图标路径
IconPath: "res://icon.svg",
// 充能球场景路径
VisualsScenePath: "res://Test/scenes/test_orb.tscn"
);

// 让你不需要手动挂脚本。复制即可。
protected override Node2D? TryCreateOrbSprite() => RitsuGodotNodeFactories.CreateFromScenePath<Node2D>(AssetProfile.VisualsScenePath!);

// 回合开始时触发被动
public override async Task AfterTurnStartOrbTrigger(PlayerChoiceContext choiceContext)
{
await Passive(choiceContext, null);
}

// 触发被动
public override async Task Passive(PlayerChoiceContext choiceContext, Creature? target)
{
Trigger();
await CardPileCmd.Draw(choiceContext, PassiveVal, Owner);
}

// 触发激发,返回受影响的角色
public override async Task<IEnumerable<Creature>> Evoke(PlayerChoiceContext playerChoiceContext)
{
PlayEvokeSfx();
await CardPileCmd.Draw(playerChoiceContext, EvokeVal, Owner);
return [Owner.Creature];
}
}

然后创建{modId}/localization/{Language}/orbs.json

1
2
3
4
5
{
"TEST_ORB_TEST_ORB.description": "充能球:回合开始时抽牌。",
"TEST_ORB_TEST_ORB.smartDescription": "[gold]被动:[/gold]回合开始时,抽[blue]{Passive}[/blue]张牌。\n[gold]激发:[/gold]抽[blue]{Evoke}[/blue]张牌。",
"TEST_ORB_TEST_ORB.title": "戈多球"
}

使用await OrbCmd.Channel<TestOrb>(choiceContext, cardPlay.Card.Owner)以生成。

alt text

test_orb.tscn:

1
2
3
4
5
6
7
8
9
[gd_scene load_steps=2 format=3 uid="uid://megsnq8c4cxc"]

[ext_resource type="Texture2D" uid="uid://ddxmxgyyfy8mn" path="res://icon.svg" id="1_voa3m"]

[node name="TestOrb" type="Node2D"]

[node name="Icon" type="Sprite2D" parent="."]
texture = ExtResource("1_voa3m")

Author: Reme
Link:https://glitchedreme.github.io/SlayTheSpire2ModdingTutorials/docs/04-ritsulib/04-08-add-orb/
版权声明:本文采用 CC BY-NC-SA 4.0 CN 协议进行许可