예제 #1
0
 public static Component?GetComponent(this Entity entity, Type componentType)
 {
     if (IsComponent(componentType) && EntityExists(entity))
     {
         return(components.Get(entity.Index, entity.Gen, componentType));
     }
     return(null);
 }
        public void Remove(EventBean theEvent, AnyMap parent)
        {
            Object sortable = _propertyGetter.Get(theEvent);

            if (sortable == null)
            {
                if (_nullKeys != null)
                {
                    _nullKeys.Remove(theEvent);
                }
                return;
            }

            sortable = EventBeanUtility.Coerce(sortable, _coercionType);

            // if this is a leaf, remove event
            if (_next == null)
            {
                var eventMap = parent;
                if (eventMap == null)
                {
                    return;
                }

                var events = eventMap.Get(sortable) as ICollection <EventBean>;
                if (events == null)
                {
                    return;
                }

                if (!events.Remove(theEvent))
                {
                    return;
                }

                if (events.IsEmpty())
                {
                    parent.Remove(sortable);
                }
            }
            else
            {
                var innerIndex = (AnyMap)parent.Get(sortable);
                if (innerIndex == null)
                {
                    return;
                }
                _next.Remove(theEvent, innerIndex);
                if (innerIndex.IsEmpty())
                {
                    parent.Remove(sortable);
                }
            }
        }
예제 #3
0
        public void Enter(EventBean theEvent, AnyMap parent)
        {
            var mk         = EventBeanUtility.GetMultiKey(theEvent, _propertyGetters, _keyCoercionTypes);
            var innerIndex = (AnyMap)parent.Get(mk);

            if (innerIndex == null)
            {
                innerIndex = new OrderedDictionary <Object, Object>();
                parent.Put(mk, innerIndex);
            }
            _next.Enter(theEvent, innerIndex);
        }
예제 #4
0
        public void Remove(EventBean theEvent, AnyMap parent)
        {
            var mk         = EventBeanUtility.GetMultiKey(theEvent, _propertyGetters, _keyCoercionTypes);
            var innerIndex = (AnyMap)parent.Get(mk);

            if (innerIndex == null)
            {
                return;
            }
            _next.Remove(theEvent, innerIndex);
            if (innerIndex.IsEmpty())
            {
                parent.Remove(mk);
            }
        }
        public void Enter(EventBean theEvent, AnyMap parent)
        {
            Object sortable = _propertyGetter.Get(theEvent);

            if (sortable == null)
            {
                if (_nullKeys == null)
                {
                    _nullKeys = new HashSet <EventBean>();
                }
                _nullKeys.Add(theEvent);
                return;
            }

            sortable = EventBeanUtility.Coerce(sortable, _coercionType);

            // if this is a leaf, enter event
            if (_next == null)
            {
                var eventMap = parent;
                var events   = eventMap.Get(sortable) as ICollection <EventBean>;
                if (events == null)
                {
                    events = new HashSet <EventBean>();
                    eventMap.Put(sortable, events);
                }

                events.Add(theEvent);
            }
            else
            {
                AnyMap innerIndex = (AnyMap)parent.Get(sortable);
                if (innerIndex == null)
                {
                    innerIndex = new OrderedDictionary <object, object>();
                    parent.Put(sortable, innerIndex);
                }
                _next.Enter(theEvent, innerIndex);
            }
        }