using System.Collections.Generic; using SepCore.CustomComponent; namespace SepCore.Battle { /// /// 战斗启动请求,创建后视为只读。 /// 战斗开始失败时不得消耗随机数、修改单局状态或暂停状态计数。 /// public sealed class BattleStartRequest { /// /// 用于将结果关联回地图敌人实例。 /// public readonly int EncounterId; /// /// 1 到 4 个玩家输入,保持战备顺序。 /// public readonly IReadOnlyList Players; /// /// 用于按队伍预设创建 1 到 4 个敌人运行时单位。 /// public readonly int EnemyPartyConfigId; /// /// 是否启用第一轮玩家先制。 /// public readonly bool IsPreemptive; /// /// 当前单局唯一的随机源实例,来自 RandomComponent,不创建战斗私有随机源。 /// public readonly IRunRandomSource Random; public BattleStartRequest(int encounterId, IReadOnlyList players, int enemyPartyConfigId, bool isPreemptive, IRunRandomSource random) { EncounterId = encounterId; Players = players != null ? Copy(players) : new BattlePlayerInput[0]; EnemyPartyConfigId = enemyPartyConfigId; IsPreemptive = isPreemptive; Random = random; } private static BattlePlayerInput[] Copy(IReadOnlyList source) { BattlePlayerInput[] copy = new BattlePlayerInput[source.Count]; for (int i = 0; i < source.Count; i++) { copy[i] = source[i]; } return copy; } } }