예제 #1
0
        public void Update(Controllers.BaseControllers controllers, GameObject ownerEnt, double dt)
        {
            using (UpgradeableReadLock.CreateLock(m_componentsAddQueueLock))
            {
                foreach (var comp in m_componentsAddQueue)
                {
                    AddComponent(comp);
                }

                using (WriteLock.CreateLock(m_componentsAddQueueLock))
                {
                    m_componentsAddQueue.Clear();
                }
            }

            using (WriteLock.CreateLock(m_componentsRemoveQueueLock))
            {
                foreach (var comp in m_componentsRemoveQueue)
                {
                    m_componentsSorted.Remove(comp);
                }

                m_componentsRemoveQueue.Clear();
            }

            using (ReadLock.CreateLock(m_componentsSortedLock))
            {
                foreach (var component in m_componentsSorted)
                {
                    component.Value.Tick(controllers, ownerEnt, dt);
                }
            }
        }
예제 #2
0
        public void AddComponentAsType(EntityComponentBase component, Type type)
        {
            using (UpgradeableReadLock.CreateLock(m_componentsSortedLock))
            {
                if (m_componentsSorted.ContainsKey(type.FullName.GetHashCode()))
                {
                    return;
                }

                using (WriteLock.CreateLock(m_componentsSortedLock))
                {
                    m_componentsSorted[type.FullName.GetHashCode()] = component;
                }
            }
        }