ProjectDDD/Assets/_DDD/_Scripts/RestaurantState/Customer/RegularSpawnScheduleBuilder.cs

38 lines
1.3 KiB
C#
Raw Normal View History

2025-08-12 11:46:30 +00:00
using System;
using System.Collections.Generic;
using static DDD.SpawnScheduleUtils;
namespace DDD
{
public class RegularSpawnScheduleBuilder : ISpawnScheduleBuilder
{
public SpawnSchedule Build(SpawnScheduleBuildArgs args)
{
int normalQuota = Math.Max(0, args.NormalQuota);
int specialQuota = Math.Max(0, args.SpecialQuota);
if (args.NormalIds == null || args.NormalIds.Count == 0) normalQuota = 0;
if (args.SpecialIds == null || args.SpecialIds.Count == 0) specialQuota = 0;
var kinds = BuildProportionalKinds(normalQuota, specialQuota);
int normalIndex = 0, specialIndex = 0;
var result = new List<string>(kinds.Count);
foreach (var kind in kinds)
{
if (kind == CustomerType.Special)
{
var id = NextRoundRobin(args.SpecialIds, ref specialIndex);
if (!string.IsNullOrEmpty(id)) result.Add(id);
}
else
{
var id = NextRoundRobin(args.NormalIds, ref normalIndex);
if (!string.IsNullOrEmpty(id)) result.Add(id);
}
}
return new SpawnSchedule(result);
}
}
}