添加充能球
先创建类:
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 { 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)以生成。
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")