M0 回合制战斗壳层:接口与单局状态、调试入口、暂停联动
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace SepCore.CustomComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 以 System.Random 实现的本局共享随机源。
|
||||
/// 由 TurnBattleComponent 以单局 seed 创建,供地图生成、敌人 AI、逃跑与掉落共用。
|
||||
/// EditMode 测试使用可注入的序列随机源,不依赖本类。
|
||||
/// </summary>
|
||||
public sealed class RunRandomSource : IRunRandomSource
|
||||
{
|
||||
private readonly Random _random;
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定种子创建随机源。
|
||||
/// </summary>
|
||||
public RunRandomSource(int seed)
|
||||
{
|
||||
_random = new Random(seed);
|
||||
}
|
||||
|
||||
public int NextInt(int minInclusive, int maxExclusive)
|
||||
{
|
||||
return _random.Next(minInclusive, maxExclusive);
|
||||
}
|
||||
|
||||
public bool RollPermille(int successPermille)
|
||||
{
|
||||
return NextInt(0, 1000) < successPermille;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user