public void CollisionUpdate()
    {
        if (colliders.Count > 1)
        {
            SortAndSweep sortAndSweep = new SortAndSweep(colliders);
            List <SortAndSweep.GameObjectsPair> list = sortAndSweep.CheckForPossibleCollisions();

            foreach (SortAndSweep.GameObjectsPair pair in list)
            {
                var collision = pair.AreColliding();
                if (collision != null)
                {
                    Debug.Log("Cpollision");
                    ResolveCollisionWithImpulse(pair, collision);
                }
            }
        }
    }
        protected override void Initialize()
        {
            _grid = new AdjacencyGrid(_settings.WorldWidth, _settings.WorldHeight, 25);

            _renderSystem             = new RenderSystem(EntityManager, this);
            _transformHierarchySystem = new TransformHierarchySystem(EntityManager, _grid);
            _velocitySystem           = new VelocitySystem(EntityManager);

            // Declare rigidbody collision system
            _rigidbodyCollisionSystem = new SortAndSweep(EntityManager,
                                                         (e) => e.HasComponents(typeof(CircleColliderComponent), typeof(RigidBodyComponent)),
                                                         (e1, e2) => true); // All collisions should be resolved

            _mouthCollisionSystem = new SortAndSweep(EntityManager,
                                                     (e) => e.HasComponents(typeof(CircleColliderComponent)) &&
                                                     (e.HasComponents(typeof(MouthComponent)) || e.HasComponents(typeof(EdibleComponent))),
                                                     // Only resolve if 1 has a food and the other a mouth (but not both)
                                                     (e1, e2) =>
                                                     (e1.HasComponent <MouthComponent>() && e2.HasComponent <EdibleComponent>())
                                                     ^ (e2.HasComponent <MouthComponent>() && e1.HasComponent <EdibleComponent>())
                                                     );

            _weaponHealthCollisionSystem = new SortAndSweep(EntityManager,
                                                            (e) => e.HasComponents(typeof(CircleColliderComponent)) &&
                                                            (e.HasComponent <HealthComponent>() || e.HasComponent <WeaponComponent>()),
                                                            // Only resolve if 1 is a weapon and the other a health
                                                            (e1, e2) =>
                                                            (e1.HasComponent <HealthComponent>() && e2.HasComponent <WeaponComponent>())
                                                            ^ (e2.HasComponent <HealthComponent>() && e1.HasComponent <WeaponComponent>())
                                                            );

            _rigidBodySystem       = new RigidBodySystem(EntityManager);
            _dragSystem            = new DragSystem(EntityManager, _settings.MassDensity);
            _movementControlSystem = new MovementControlSystem(EntityManager);
            _brainSystem           = new BrainSystem(EntityManager, Settings);
            WorldBorderSystem      = new WorldBorderSystem(EntityManager, _worldWidth, _worldHeight);
            _visionSystem          = new VisionSystem(EntityManager, _grid);

            // These systems take a reference to a list of collisions. This means that should collision code checking change, the objects do not.
            RigidbodyCollisionSystem = new RigidBodyCollisionSystem(_rigidbodyCollisionSystem.Collisions);
            MouthFoodCollisionSystem = new MouthFoodCollisionSystem(EntityManager, _mouthCollisionSystem.Collisions);
            InfoRenderSystem         = new InfoRenderSystem(EntityManager, this);
            _noseSystem = new NoseSystem(EntityManager, _grid);

            // Global energy manager. This Ensures a closed system so there is a fixed amount of enegry in the simulation
            _energyManager = new EnergyManager(_settings.InitialWorldEnergy);

            // These are systems that take into account energy and need the energy manager system

            EnergyDeathSystem = new EnergyDeathSystem(EntityManager);
            HealthDeathSystem = new HealthDeathSystem(EntityManager, this, _energyManager);
            OldAgeDeathSystem = new OldAgeDeathSystem(EntityManager, this, _energyManager, _settings.OldAgeEnabled, _settings.OldAgeMultiplier);

            WeaponSystem = new WeaponSystem(EntityManager, _weaponHealthCollisionSystem.Collisions, _energyManager);
            _movementControlEnergyCostSystem = new MovementControlEnergyCostSystem(EntityManager, _energyManager);

            InnovationIdManager innovationIdManager = new InnovationIdManager(100, 100);

            // So textures are constantly refreshed
            _renderSystem.EditorMode = true;
        }