示例#1
0
 private void OnDisconnect(DisconnectOp op)
 {
     WorldCommands.DeallocateWorldCommandRequesters(EntityManager, worker.WorkerEntity);
     EntityManager.AddSharedComponentData(worker.WorkerEntity,
                                          new OnDisconnected {
         ReasonForDisconnect = op.Reason
     });
 }
        internal void OnRemoveEntity(RemoveEntityOp op)
        {
            var entityId = op.EntityId;

            if (!worker.TryGetEntity(entityId, out var entity))
            {
                throw new InvalidSpatialEntityStateException(
                          string.Format(Errors.EntityNotFoundForDeleteError, entityId.Id));
            }

            WorldCommands.DeallocateWorldCommandRequesters(EntityManager, entity);
            EntityManager.DestroyEntity(worker.EntityIdToEntity[entityId]);
            worker.EntityIdToEntity.Remove(entityId);
        }
示例#3
0
        private void OnRemoveEntity(RemoveEntityOp op)
        {
            var entityId = op.EntityId;

            if (!worker.TryGetEntity(entityId, out var entity))
            {
                worker.LogDispatcher.HandleLog(LogType.Error, new LogEvent(Errors.NoEntityFoundDuringDeletion)
                                               .WithField(LoggingUtils.LoggerName, LoggerName)
                                               .WithField(LoggingUtils.EntityId, entityId));
                return;
            }

            WorldCommands.DeallocateWorldCommandRequesters(EntityManager, entity);
            EntityManager.DestroyEntity(worker.EntityMapping[entityId]);
            worker.EntityMapping.Remove(entityId);
        }
        public void TearDown()
        {
            foreach (var entity in worker.EntityIdToEntity.Values)
            {
                try
                {
                    WorldCommands.DeallocateWorldCommandRequesters(entityManager, entity);
                }
                catch (Exception)
                {
                }
            }

            worker.EntityIdToEntity.Clear();

            using (var allEntities = entityManager.GetAllEntities())
            {
                foreach (var entity in allEntities.Where(x => x != worker.WorkerEntity))
                {
                    entityManager.DestroyEntity(entity);
                }
            }

            firstComponentDispatcher.Reset();
            secondComponentDispatcher.Reset();

            createEntityStorage.CommandRequestsInFlight.Clear();
            deleteEntityStorage.CommandRequestsInFlight.Clear();
            reserveEntityIdsStorage.CommandRequestsInFlight.Clear();
            entityQueryStorage.CommandRequestsInFlight.Clear();

            WorldCommands.CreateEntity.ResponsesProvider.CleanDataInWorld(world);
            WorldCommands.EntityQuery.ResponsesProvider.CleanDataInWorld(world);
            WorldCommands.DeleteEntity.ResponsesProvider.CleanDataInWorld(world);
            WorldCommands.ReserveEntityIds.ResponsesProvider.CleanDataInWorld(world);
        }