1 | package g0803.bindingofshiba.controller.game.events; | |
2 | ||
3 | import g0803.bindingofshiba.App; | |
4 | import g0803.bindingofshiba.bundles.Bundle; | |
5 | import g0803.bindingofshiba.controller.Controller; | |
6 | import g0803.bindingofshiba.events.IEventManager; | |
7 | import g0803.bindingofshiba.events.game.MonsterCollisionWithMonsterEvent; | |
8 | import g0803.bindingofshiba.math.BoundingBox; | |
9 | import g0803.bindingofshiba.model.game.Game; | |
10 | import g0803.bindingofshiba.model.game.elements.Monster; | |
11 | import java.util.ArrayList; | |
12 | import java.util.List; | |
13 | ||
14 | public class MonsterToMonsterCollisionEventsController extends Controller<Game> { | |
15 | ||
16 | public MonsterToMonsterCollisionEventsController(Game model, IEventManager eventManager) { | |
17 | super(model, eventManager); | |
18 | } | |
19 | ||
20 | @Override | |
21 | public void tick(App app, double dt) { | |
22 | Bundle<BoundingBox> boundingBoxes = app.getBoundingBoxes(); | |
23 | List<Monster> monsters = getModel().getCurrentRoom().getMonsters(); | |
24 | ArrayList<MonsterCollisionWithMonsterEvent> eventsToDispatch = new ArrayList<>(); | |
25 | ||
26 | BoundingBox monsterBox = boundingBoxes.get("monster"); | |
27 |
4
1. tick : changed conditional boundary → SURVIVED 2. tick : Changed increment from 1 to -1 → KILLED 3. tick : Replaced integer subtraction with addition → KILLED 4. tick : negated conditional → KILLED |
for (int i = 0; i < monsters.size() - 1; i++) { |
28 | Monster monster1 = monsters.get(i); | |
29 | ||
30 |
3
1. tick : changed conditional boundary → KILLED 2. tick : Replaced integer addition with subtraction → KILLED 3. tick : negated conditional → KILLED |
for (int j = i + 1; j < monsters.size(); j++) { |
31 | Monster monster2 = monsters.get(j); | |
32 | ||
33 | BoundingBox monsterBox1 = monsterBox.translate(monster1.getNextPosition(dt)); | |
34 | BoundingBox monsterBox2 = monsterBox.translate(monster2.getNextPosition(dt)); | |
35 |
1
1. tick : negated conditional → KILLED |
if (monsterBox1.collides(monsterBox2)) |
36 | eventsToDispatch.add( | |
37 | new MonsterCollisionWithMonsterEvent(dt, app, monster1, monster2)); | |
38 | } | |
39 | } | |
40 | ||
41 | for (MonsterCollisionWithMonsterEvent event : eventsToDispatch) | |
42 |
1
1. tick : removed call to g0803/bindingofshiba/events/IEventManager::dispatchEvent → KILLED |
getEventManager().dispatchEvent(event); |
43 | } | |
44 | } | |
Mutations | ||
27 |
1.1 2.2 3.3 4.4 |
|
30 |
1.1 2.2 3.3 |
|
35 |
1.1 |
|
42 |
1.1 |