添加新药水
以下示例默认已经在Entry.Init()中调用了RitsuLibFramework.EnsureGodotScriptsRegistered(...)和ModTypeDiscoveryHub.RegisterModAssembly(...),否则自动注册不会生效。
首先创建类:(很多代码和卡牌类似,参考即可)
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 using MegaCrit.Sts2.Core.Entities.Creatures;using MegaCrit.Sts2.Core.Entities.Potions;using MegaCrit.Sts2.Core.GameActions.Multiplayer;using MegaCrit.Sts2.Core.HoverTips;using MegaCrit.Sts2.Core.Localization.DynamicVars;using MegaCrit.Sts2.Core.Models.Cards;using STS2RitsuLib.Interop.AutoRegistration;using STS2RitsuLib.Scaffolding.Content;namespace Test.Scripts ; [RegisterPotion(typeof(SharedPotionPool)) ]public class TestPotion : ModPotionTemplate { public override PotionRarity Rarity => PotionRarity.Common; public override PotionUsage Usage => PotionUsage.CombatOnly; public override TargetType TargetType => TargetType.Self; protected override IEnumerable<DynamicVar> CanonicalVars => [new CardsVar(3 )]; protected override IEnumerable<IHoverTip> AdditionalHoverTips => [HoverTipFactory.FromCard<Soul>()]; public override PotionAssetProfile AssetProfile => new ( ImagePath: "res://icon.svg" , OutlinePath: "res://icon.svg" ); protected override async Task OnUse (PlayerChoiceContext choiceContext, Creature? target ) { await Soul.CreateInHand(Owner, DynamicVars.Cards.IntValue, Owner.Creature.CombatState!); } }
[RegisterPotion(typeof(TestPotionPool))]会把药水自动注册到指定药水池。示例里用的是自定义角色药水池。
继承的是ModPotionTemplate。
CanonicalVars、AdditionalHoverTips这些写法和卡牌类似。
AssetProfile里的ImagePath和OutlinePath分别对应药水本体和轮廓图。
然后创建{ModId}/localization/{Language}/potions.json。
1 2 3 4 { "TEST_POTION_TEST_POTION.title" : "戈多药水" , "TEST_POTION_TEST_POTION.description" : "将[blue]{Cards}[/blue]张[gold]灵魂[/gold]加入你的[gold]手牌[/gold]。" }
最终项目参考 1 2 3 4 5 6 7 8 9 10 Test ├── Scripts │ ├── Entry.cs │ ├── TestPotion.cs │ └── TestPotionPool.cs ├── icon.svg └── Test └── localization └── zhs └── potions.json