Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
You are viewing a potentially older version of this package.
View all versions.
| Date uploaded | a month ago |
| Version | 1.0.0 |
| Download link | cn_xc-RandomValueLib-1.0.0.zip |
| Downloads | 46 |
| Dependency string | cn_xc-RandomValueLib-1.0.0 |
README
markdown
RandomValueLib
核心随机价格库,为《REPO》模组提供统一的贵重物品价格随机化逻辑。
功能
- 确定性随机算法(基于物品 ID 和可选额外种子)
- 可配置倍率范围、黑白名单、现金袋保护、高价物品排除
- 提供纯计算和直接修改两种方式
- 反射读写价格字段,兼容公共化与非公共化环境
使用示例
using RandomValueLib;
var config = new RandomizationConfig
{
MinMultiplier = 0.5f,
MaxMultiplier = 2.0f,
// 根据需要设置其他规则
};
// 方式一:直接应用随机价格
float newPrice = RandomValueService.ApplyRandomPrice(valuableObject, config);
// 方式二:先判断是否随机化
if (RandomValueService.ShouldRandomize(obj, config))
{
float price = RandomValueService.GetRandomPrice(instanceID, originalPrice, config);
RandomValueService.SetItemPrice(vo, price);
}
依赖
游戏 Assembly-CSharp.dll
.NET Standard 2.0 或 .NET Framework 4.7.2
安装
将 RandomValueLib.dll 放入 BepInEx/plugins 文件夹(作为其他模组的依赖自动安装,一般无需手动操作)。
text
CHANGELOG
📜 更新日志
v1.0.1 (2026-03-22)
- 文档: 添加 MIT 许可证。
- 说明: 当前仅维护此库,主模组后续研究。
v1.0.0 (2026-03-22)
- 核心功能: 提供确定性随机算法
GetRandomPrice,基于物品实例 ID 和可选额外种子。 - 配置模型:
RandomizationConfig包含倍率范围、黑白名单、现金袋保护、高价物品排除等规则。 - 规则检查:
ShouldRandomize根据配置判断物品是否应被随机化。 - 价格读写: 通过反射获取/设置
ValuableObject的dollarValueCurrent和dollarValueOriginal字段。 - 便捷方法:
ApplyRandomPrice一键完成规则检查、价格计算和价格修改。 - 扩展方法:
ValuableObjectExtensions.ApplyRandomPrice提供更流畅的调用方式。 - 兼容性: 不依赖 BepInEx 或 Harmony,仅需游戏
Assembly-CSharp.dll。 - 目标框架: .NET Standard 2.0 / .NET Framework 4.7.2。