190 - API文档汉化 - 道具
Updated a week ago道具
自定义道具
本API支持添加自定义的消耗品道具。 要创建一个道具,您需要新建一个继承自ConsumableItem的类。
指定您的道具类及其使用时的效果。
public class CustomConsumableItem : ConsumableItem
{
public override IEnumerator ActivateSequence()
{
base.PlayExitAnimation();
yield return new WaitForSeconds(0.25f);
yield return base.StartCoroutine(Singleton<ResourcesManager>.Instance.AddBones(4, null));
yield break;
}
public override bool ExtraActivationPrerequisitesMet()
{
if (!base.ExtraActivationPrerequisitesMet())
{
return false;
}
// 可选:阻止玩家使用该道具!
return true;
}
}
添加新道具
若您没有自定义模型,可使用API提供的ConsumableItemManager.ModelType中的默认类型之一。
ConsumableItemManager.ModelType modelType = ConsumableItemManager.ModelType.Basic;
ConsumableItemManager.New(Plugin.PluginGuid, "Custom Item", "Does a thing!", textureOrSprite, typeof(CustomConsumableItem), modelType)
.SetDescription(learnText)
.SetAct1();
若要创建简单的“瓶中卡牌”类道具,可使用如下预设方法:
ConsumableItemManager.NewCardInABottle(PluginGuid, cardInfo.name)
.SetAct1();
若您拥有道具的自定义模型,可在不同构造函数中指定:
GameObject prefab = ...
ConsumableItemManager.New(Plugin.PluginGuid, "Custom Item", "Does a thing!", textureOrSprite, typeof(CustomConsumableItem), prefab)
.SetDescription(learnText)
.SetAct1();
若希望道具在多个章节的规则书中出现,可对返回的ConsumableItemData使用扩展方法AddExtraRulebookCategories
。
Pages
- 0 - 邪恶冥刻模组简体中文语言包Wiki
- 100 - API文档汉化 - 首页
- 110 - API文档汉化 - 入门指南
- 120 - API文档汉化 - 卡牌
- 121 - API文档汉化 - 自定义卡牌费用系统
- 122 - API文档汉化 - 会说话的卡牌
- 123 - API文档汉化 - 自定义毛皮
- 130 - API文档汉化 - 能力
- 131 - API文档汉化 - 自定义触发器
- 132 - API文档汉化 - 自定义狙击逻辑
- 133 - API文档汉化 - 伤害护盾行为
- 134 - API文档汉化 - 卡槽修改功能
- 135 - API文档汉化 - 触发器与执行顺序
- 140 - API文档汉化 - 自定义/扩展属性
- 150 - API文档汉化 - 扬升(凯茜模组)
- 160 - API文档汉化 - 地图与遭遇战
- 170 - API文档汉化 - 对手
- 180 - API文档汉化 - 图腾
- 190 - API文档汉化 - 道具
- 1A0 - API文档汉化 - 规则书
- 1A1 - API文档汉化 - 添加自定义页面
- 1A2 - API文档汉化 - 添加文本重定向功能
- 1B0 - API文档汉化 - 本地化
- 1B0 - API文档汉化 - 声音
- 1B0 - API文档汉化 - 资产包
- 1C0 - API文档汉化 - 其他特性
- 200 - JSONLoader文档汉化 - Wiki
- 201 - JSONLoader文档汉化 - 枚举值