示例#1
0
        protected override void OnUpdate()
        {
            Entities.WithAll <Simulated>().ForEach((Entity entity, DynamicBuffer <TransferAction> buffer) =>
            {
                if (buffer.Length == 0)
                {
                    return;
                }

                var transferAction = buffer[0];

                if (transferAction.accepted)
                {
                    EntityManager.RemoveComponent <Simulated>(entity);
                    EntityManager.RemoveComponent <LingerSimulated>(entity);
                    ReceiveUpdate.RemoveSyncComponents(EntityManager, entity);
                    ReceiveUpdate.AddCommandBuffers(EntityManager, entity);
                }

                if (transferAction.accepted && transferAction.participant == 0)
                {
                    EntityManager.AddComponent <Orphan>(entity);
                }

                buffer.Clear();
            }).WithStructuralChanges().Run();

            Dependency.Complete();
        }
        protected override void OnUpdate()
        {
            Entities.WithAll <Simulated>().ForEach((Entity entity, in TransferAction transferAction) =>
            {
                if (transferAction.accepted)
                {
                    EntityManager.RemoveComponent <Simulated>(entity);
                    EntityManager.RemoveComponent <LingerSimulated>(entity);
                    ReceiveUpdate.RemoveSyncComponents(EntityManager, entity);
                    ReceiveUpdate.AddCommandBuffers(EntityManager, entity);
                }
                if (transferAction.accepted && transferAction.participant == 0)
                {
                    EntityManager.AddComponent <Orphan>(entity);
                }
            }).WithStructuralChanges().Run();

            Dependency.Complete();
        }