Files
crtr/Assets/Cryville/Crtr/Event/RMVPool.cs
2023-04-19 13:31:17 +08:00

27 lines
1.0 KiB
C#

using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Collections.Specialized;
using System.Collections.Generic;
namespace Cryville.Crtr.Event {
internal class RMVPool : CategorizedPool<int, RealtimeMotionValue> {
public static RMVPool Shared;
private class Bucket : ObjectPool<RealtimeMotionValue> {
readonly MotionRegistry _reg;
public Bucket(Identifier name, int capacity) : base(capacity) {
_reg = ChartPlayer.motionRegistry[name];
}
protected override RealtimeMotionValue Construct() {
return new RealtimeMotionValue().Init(_reg.InitValue);
}
}
readonly IntKeyedDictionary<ObjectPool<RealtimeMotionValue>> m_buckets;
protected override IReadOnlyDictionary<int, ObjectPool<RealtimeMotionValue>> Buckets { get { return m_buckets; } }
public RMVPool() {
m_buckets = new IntKeyedDictionary<ObjectPool<RealtimeMotionValue>>(ChartPlayer.motionRegistry.Count);
foreach (var reg in ChartPlayer.motionRegistry)
m_buckets.Add(reg.Key.Key, new Bucket(reg.Key, 4096));
}
}
}