添加新遗物
以下示例默认已经在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 using Godot;using MegaCrit.Sts2.Core.Commands;using MegaCrit.Sts2.Core.Entities.Cards;using MegaCrit.Sts2.Core.Entities.Players;using MegaCrit.Sts2.Core.Entities.Relics;using MegaCrit.Sts2.Core.GameActions.Multiplayer;using MegaCrit.Sts2.Core.Localization.DynamicVars;using MegaCrit.Sts2.Core.Models.RelicPools;using MegaCrit.Sts2.Core.Saves.Runs;using STS2RitsuLib.Interop.AutoRegistration;using STS2RitsuLib.Scaffolding.Content;namespace Test.Scripts ; [RegisterRelic(typeof(SharedRelicPool)) ]public class TestRelic : ModRelicTemplate { public override RelicRarity Rarity => RelicRarity.Common; protected override IEnumerable<DynamicVar> CanonicalVars => [new CardsVar(1 )]; public override RelicAssetProfile AssetProfile => new ( IconPath: $"res://Test/images/relics/{GetType().Name} .png" , IconOutlinePath: $"res://Test/images/relics/{GetType().Name} .png" , BigIconPath: $"res://Test/images/relics/{GetType().Name} .png" ); public override async Task AfterPlayerTurnStart (PlayerChoiceContext choiceContext, Player player ) { await CardPileCmd.Draw(choiceContext, DynamicVars.Cards.IntValue, player); } }
然后放一张图片Test/images/relics/TestRelic.png。这里偷懒三张图片用了一样的,可以自己修改路径。
然后写一个本地化文件,{modId}/localization/{Language}/relics.json。
1 2 3 4 5 { "TEST_RELIC_TEST_RELIC.title" : "测试遗物" , "TEST_RELIC_TEST_RELIC.description" : "每回合开始时,抽[blue]{Cards}[/blue]张牌。" , "TEST_RELIC_TEST_RELIC.flavor" : "觉得很眼熟?" }
最终项目参考 1 2 3 4 5 6 7 8 9 10 11 Test ├── Scripts │ ├── Entry.cs │ └── TestRelic.cs (或者放单独的Relics文件夹) └── Test ├── images │ └── relics │ └── TestRelic.png └── localization └── zhs └── relics.json