Пример #1
0
        internal DataEventListener When <T>(string entityName, Action <T> onAdded) where T : BaseData
        {
            DataEventListenerImpl dataEventListenerImpl = new DataEventListenerImpl();

            dataEventListenerImpl.ListenerCollection = this;
            dataEventListenerImpl.Key.EntityName     = entityName;
            dataEventListenerImpl.Key.Type           = typeof(T);
            DataEventListenerImpl dataEventListenerImpl2 = dataEventListenerImpl;
            DataEntityHandle      dataEntityHandle       = dataEntityCollection.FindEntityByName(entityName);

            if (!dataEntityHandle.IsNull && dataEntityCollection.HasComponent <T>(dataEntityHandle))
            {
                onAdded(dataEntityCollection.GetComponent <T>(dataEntityHandle));
            }
            else
            {
                ListenerKey listenerKey = default(ListenerKey);
                listenerKey.EntityName = entityName;
                listenerKey.Type       = typeof(T);
                ListenerKey key = listenerKey;
                dataEventListenerImpl2.AddedHandler = createComponentAddedHandler(key, onAdded, onlyOnce: true);
            }
            return(dataEventListenerImpl2);
        }
Пример #2
0
 public bool TryFindEntity <T, F>(F identifier, out DataEntityHandle dataEntityHandle) where T : BaseData, IEntityIdentifierData <F>
 {
     dataEntityHandle = FindEntity <T, F>(identifier);
     return(!dataEntityHandle.IsNull);
 }
Пример #3
0
 public DataEventListener Whenever <T>(DataEntityHandle handle, Action <T> onAdded, Action <T> onRemoved) where T : BaseData
 {
     return(Whenever(handle.Id, onAdded, onRemoved));
 }
Пример #4
0
 public bool HasComponent <T>(DataEntityHandle handle) where T : BaseData
 {
     validateHandle(handle, "HasComponent");
     return(entities[handle].ContainsKey(typeof(T)));
 }