using Cryville.Common; using Cryville.Common.Buffers; using Cryville.Common.Collections.Specialized; using System; using System.Collections.Generic; namespace Cryville.Crtr.Event { internal class MotionCache { public bool Valid { get; set; } public Vector Value { get; set; } public void CopyTo(MotionCache dest) { dest.Valid = Valid; Value.CopyTo(dest.Value); } } internal class MotionCachePool : CategorizedPool { public static MotionCachePool Shared; private class Bucket : ObjectPool { readonly MotionRegistry _reg; public Bucket(Identifier name, int capacity) : base(capacity) { _reg = ChartPlayer.motionRegistry[name]; } protected override MotionCache Construct() { var result = new MotionCache { Value = (Vector)Activator.CreateInstance(_reg.Type) }; return result; } protected override void Reset(MotionCache obj) { obj.Valid = false; } } readonly IntKeyedDictionary> m_buckets; protected override IDictionary> Buckets { get { return m_buckets; } } public MotionCachePool() { m_buckets = new IntKeyedDictionary>(ChartPlayer.motionRegistry.Count); foreach (var reg in ChartPlayer.motionRegistry) m_buckets.Add(reg.Key.Key, new Bucket(reg.Key, 4096)); } } }