<commit_before>package model.physics;

import model.entity.IEntity;
import model.entity.IEntitySystem;
import api.IPhysicsEngine;
import javafx.scene.shape.Shape;
import model.component.movement.Position;
import model.component.movement.Velocity;
import model.component.physics.Collision;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


public class PhysicsEngine implements IPhysicsEngine {
    IEntitySystem settings;

    public PhysicsEngine(IEntitySystem settings) {
        this.settings = settings;
    }

    @Override
    public IEntitySystem update(IEntitySystem universe, double dt) {
        Collection<IEntity> dynamicEntities = universe.getAllEntities().stream()
                .filter(p -> p.hasComponents(Position.class, Velocity.class))
                .collect(Collectors.toSet());
        dynamicEntities.stream().forEach(p -> {
            Position pos = p.getComponent(Position.class);
            Velocity velocity = p.getComponent(Velocity.class);
            double dx = dt * velocity.getVX();
            double dy = dt * velocity.getVY();
            pos.add(dx, dy);
        });
        return universe;
    }

    public void applyImpulse(IEntity body, Impulse J) {
        if (body.hasComponent(Velocity.class)) {
            Velocity v = body.getComponent(Velocity.class);
            v.add(J.getJx(), J.getJy());
        }
    }

    public boolean areCollidingEntities(IEntity e1, IEntity e2) {
        List<Collision> cList1 = e1.getComponentList(Collision.class);
        List<Collision> cList2 = e2.getComponentList(Collision.class);
        for (Collision c1 : cList1) {
            Shape mask1 = c1.getMask();
            Collection<String> IDList1 = c1.getIDs();
            for (Collision c2 : cList2) {
                Shape mask2 = c2.getMask();
                Collection<String> IDList2 = c2.getIDs();
                if (!this.areIntersectingIDLists(IDList1, IDList2)) {
                    // TODO
                }
            }
        }

        return false; // TODO
    }

<<<<<<< HEAD
    public Collection<IEntity> getEntitiesCollidingWith (IEntity e) {

        return null; // TODO
    }

    private boolean areIntersectingIDLists (Collection<String> IDList1,
                                            Collection<String> IDList2) {
=======
    private boolean areIntersectingIDLists(Collection<String> IDList1,
                                           Collection<String> IDList2) {
>>>>>>> 7482a2c93b027f3897be1bd32d6e7e437c4753a8
        Set<String> IDSet = new HashSet<String>();
        IDSet.addAll(IDList1);
        IDSet.addAll(IDList2);
        return (IDSet.size() < IDList1.size() + IDList2.size());
    }

}
<commit_msg>resolved conflict again<commit_after>package model.physics;

import model.entity.IEntity;
import model.entity.IEntitySystem;
import api.IPhysicsEngine;
import javafx.scene.shape.Shape;
import model.component.movement.Position;
import model.component.movement.Velocity;
import model.component.physics.Collision;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


public class PhysicsEngine implements IPhysicsEngine {
    IEntitySystem settings;

    public PhysicsEngine(IEntitySystem settings) {
        this.settings = settings;
    }

    @Override
    public IEntitySystem update(IEntitySystem universe, double dt) {
        Collection<IEntity> dynamicEntities = universe.getAllEntities().stream()
                .filter(p -> p.hasComponents(Position.class, Velocity.class))
                .collect(Collectors.toSet());
        dynamicEntities.stream().forEach(p -> {
            Position pos = p.getComponent(Position.class);
            Velocity velocity = p.getComponent(Velocity.class);
            double dx = dt * velocity.getVX();
            double dy = dt * velocity.getVY();
            pos.add(dx, dy);
        });
        return universe;
    }

    public void applyImpulse(IEntity body, Impulse J) {
        if (body.hasComponent(Velocity.class)) {
            Velocity v = body.getComponent(Velocity.class);
            v.add(J.getJx(), J.getJy());
        }
    }

    public boolean areCollidingEntities(IEntity e1, IEntity e2) {
        List<Collision> cList1 = e1.getComponentList(Collision.class);
        List<Collision> cList2 = e2.getComponentList(Collision.class);
        for (Collision c1 : cList1) {
            Shape mask1 = c1.getMask();
            Collection<String> IDList1 = c1.getIDs();
            for (Collision c2 : cList2) {
                Shape mask2 = c2.getMask();
                Collection<String> IDList2 = c2.getIDs();
                if (!this.areIntersectingIDLists(IDList1, IDList2)) {
                    // TODO
                }
            }
        }

        return false; // TODO
    }

    public Collection<IEntity> getEntitiesCollidingWith (IEntity e) {

        return null; // TODO
    }

    private boolean areIntersectingIDLists (Collection<String> IDList1,
                                            Collection<String> IDList2) {
        Set<String> IDSet = new HashSet<String>();
        IDSet.addAll(IDList1);
        IDSet.addAll(IDList2);
        return (IDSet.size() < IDList1.size() + IDList2.size());
    }

}

{'fraction_non_alphanumeric': 0.10843598357596118, 'fraction_numerical': 0.015117581187010079, 'mean_word_length': 2.3451935081148565, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2121283', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1537, 'n_words': 306}