Ejemplo n.º 1
0
        internal bool TryDequeue(out EntityChangeData changeData)
        {
            /*
             * if (EntityChanges.TryDequeue(out changeData))
             * {
             *  if (changeData.ChangeType == EntityChangeData.EntityChangeType.EntityRemoved)
             *      ListningToEntites.Remove(changeData.Entity);
             *  if (changeData.ChangeType == EntityChangeData.EntityChangeType.EntityAdded)
             *  {
             *
             *      if (changeData.Entity.HasDataBlob<OwnedDB>() && changeData.Entity.GetDataBlob<OwnedDB>().OwnedByFaction != ListenForFaction)
             *      {
             *          if(
             *      }
             *
             *  }
             *  return true;
             * }
             *
             *
             *
             * return
             * false; */

            return(EntityChanges.TryDequeue(out changeData));
        }
Ejemplo n.º 2
0
        private void OnEntityAdded(EntityChangeData changeData)
        {
            bool include = false;

            foreach (var includeitem in IncludeDBTypeIndexFilter)
            {
                //debug
                var someentity = changeData.Entity.Manager.GetFirstEntityWithDataBlob(includeitem);
                var db         = someentity.GetDataBlob <BaseDataBlob>(includeitem);
                //end debug

                if (changeData.Entity.HasDataBlob(includeitem))
                {
                    include = true;
                }
                else
                {
                    include = false;
                    break;
                }
            }
            if (include && _ownerDB.OwnedEntities.ContainsKey(changeData.Entity.Guid)) //note: this will miss a lot of new entittes, since this code gets called before ownership is set on a new entity. it will get caught when a datablob is set though.
            {
                ListningToEntites.Add(changeData.Entity);
                EntityChanges.Enqueue(changeData);
            }
        }
Ejemplo n.º 3
0
 private void OnEntityRemoved(EntityChangeData changeData)
 {
     if (ListningToEntites.Contains(changeData.Entity))
     {
         ListningToEntites.Add(changeData.Entity);
         EntityChanges.Enqueue(changeData);
     }
 }
Ejemplo n.º 4
0
 private void OnDBRemoved(EntityChangeData changeData)
 {
     if (ListningToEntites.Contains(changeData.Entity))
     {
         if (IncludeDBTypeIndexFilter.Contains(EntityManager.DataBlobTypes[changeData.Datablob.GetType()]))
         {
             ListningToEntites.Remove(changeData.Entity);
         }
         EntityChanges.Enqueue(changeData);
     }
 }
Ejemplo n.º 5
0
 private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change)
 {
     if (EntityListners.Count > 0)
     {
         var changeData = new EntityChangeData()
         {
             Entity     = entity,
             Datablob   = db,
             ChangeType = change
         };
         foreach (var item in EntityListners)
         {
             item.AddChange(changeData);
         }
     }
 }
Ejemplo n.º 6
0
        private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change)
        {
            //listners to this work on thier own threads and are not affected by this one.
            if (EntityListners.Count > 0)
            {
                var changeData = new EntityChangeData()
                {
                    Entity     = entity,
                    Datablob   = db,
                    ChangeType = change
                };
                foreach (var item in EntityListners)
                {
                    item.AddChange(changeData);
                }
            }


            //this one works on the active (ie this) thread
            entity.InvokeChangeEvent(change, db);
        }
Ejemplo n.º 7
0
        internal virtual void AddChange(EntityChangeData changeData)
        {
            if (changeData.ChangeType != EntityChangeData.EntityChangeType.EntityAdded)
            {
                if (ListningToEntites.Contains(changeData.Entity))
                {
                    EntityChanges.Enqueue(changeData);
                }
            }
            else
            {
                bool isvalid = changeData.Entity.IsValid;

                ListningToEntites.Add(changeData.Entity);
                EntityChanges.Enqueue(changeData);
            }
            if (changeData.ChangeType == EntityChangeData.EntityChangeType.EntityRemoved)
            {
                ListningToEntites.Remove(changeData.Entity);
            }
        }
Ejemplo n.º 8
0
 private void OnDBAdded(EntityChangeData changeData)
 {
     if (ListningToEntites.Contains(changeData.Entity))
     {
         ListningToEntites.Add(changeData.Entity);
         EntityChanges.Enqueue(changeData);
     }
     else
     {
         if (IncludeDBTypeIndexFilter.Contains(EntityManager.DataBlobTypes[changeData.Datablob.GetType()]))
         {
             bool include = false;
             foreach (var includeitem in IncludeDBTypeIndexFilter)
             {
                 if (!changeData.Entity.HasDataBlob(includeitem))
                 {
                     include = false;
                     break;
                 }
                 else
                 {
                     include = true;
                 }
             }
             if (include && _ownerDB.OwnedEntities.ContainsKey(changeData.Entity.Guid))
             {
                 ListningToEntites.Add(changeData.Entity);
                 EntityChangeData addedChange = new EntityChangeData()
                 {
                     ChangeType = EntityChangeData.EntityChangeType.EntityAdded,
                     Entity     = changeData.Entity
                 };
                 EntityChanges.Enqueue(addedChange);
                 //EntityChanges.Enqueue(changeData);
             }
         }
     }
 }
Ejemplo n.º 9
0
        internal override void AddChange(EntityChangeData changeData)
        {
            switch (changeData.ChangeType)
            {
            case EntityChangeData.EntityChangeType.EntityAdded:
                OnEntityAdded(changeData);
                break;

            case EntityChangeData.EntityChangeType.EntityRemoved:
                OnEntityRemoved(changeData);
                break;

            case EntityChangeData.EntityChangeType.DBAdded:
                OnDBAdded(changeData);
                break;

            case EntityChangeData.EntityChangeType.DBRemoved:
                OnDBRemoved(changeData);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 10
0
 internal void Enqueue(EntityChangeData changeData)
 {
     EntityChanges.Enqueue(changeData);
 }