package entity.model.mind.goal

import entity.model.Animal
import org.joml.Vector2f
import java.util.function.Function
import java.util.function.Predicate
import java.util.stream.Collectors

abstract class Goal(val animal: Animal) {
    private val preReqs: List<Goal>? = null
    private var next: Goal? = null

    abstract fun getMovement(delta: Float): Vector2f

    fun preReqs(): List<Goal> {
        return this.preReqs!!
                .filter { goal -> !goal.isCompleted }
    }

    abstract val isCompleted: Boolean

    fun next(next: Goal) {
        this.next = next
    }

    operator fun next(): Goal {
        return this.next!!
    }
}

@@ -23,16 +23,17 @@
 ind.goal
+;
 %0A%0Aimport
@@ -52,16 +52,17 @@
 l.Animal
+;
 %0Aimport 
@@ -78,16 +78,69 @@
 Vector2f
+;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;
 %0Aimport 
@@ -166,16 +166,17 @@
 Function
+;
 %0Aimport 
@@ -203,16 +203,17 @@
 redicate
+;
 %0Aimport 
@@ -239,18 +239,26 @@
 llectors
+;
 %0A%0A
+public 
 abstract
@@ -272,30 +272,37 @@
 Goal
-(val a
+ %7B%0A    private A
 nimal
-: A
+ a
 nimal
-) %7B
+;
 %0A   
@@ -314,19 +314,26 @@
 ate 
-v
+List%3CGo
 al
+%3E
  preReqs
 : Li
@@ -332,28 +332,29 @@
 Reqs
-: List%3CGoal%3E? = null
+ = new ArrayList%3C%3E();
 %0A   
@@ -366,35 +366,153 @@
 ate 
-var
+Goal
  next
-: Goal? = null%0A%0A   
+;%0A%0A    public Goal(Animal animal) %7B%0A        this.animal = animal;%0A    %7D%0A%0A    public Animal getAnimal() %7Breturn this.animal;%7D%0A%0A    public
  abs
@@ -517,19 +517,24 @@
 bstract 
-fun
+Vector2f
  getMove
@@ -542,51 +542,33 @@
 ent(
-delta: Float): Vector2f%0A%0A    fun preReqs():
+float delta);%0A%0A    public
  Lis
@@ -574,16 +574,26 @@
 st%3CGoal%3E
+ preReqs()
  %7B%0A     
@@ -614,18 +614,25 @@
 .preReqs
-!!
+.stream()
 %0A       
@@ -651,11 +651,9 @@
 lter
- %7B 
+(
 goal
@@ -677,21 +677,147 @@
 eted
+())%0A                .collect(Collectors.toList());%0A   
  %7D%0A
+%0A
     
-%7D%0A%0A   
+protected void addPreReq(Goal preReq) %7Bthis.preReqs.add(preReq);%7D%0A%0A    public
  abs
@@ -826,11 +826,15 @@
 act 
-val
+boolean
  isC
@@ -845,118 +845,89 @@
 eted
-: Boolean%0A%0A    fun next(next: Goal) %7B%0A        this.next = next%0A    %7D%0A%0A    operator fun next(): Goal %7B%0A        
+();%0A%0A    public void next(Goal next) %7Bthis.next = next;%7D%0A    public Goal next() %7B
 retu
@@ -942,15 +942,9 @@
 next
-!!%0A    
+;
 %7D%0A%7D%0A

Add complex goals