Continued goal implementation

This commit is contained in:
Auxilor
2022-03-01 19:44:27 +00:00
parent 32ef8d8c5c
commit 7176342e15
19 changed files with 431 additions and 42 deletions

View File

@@ -2,6 +2,7 @@ package com.willfp.eco.core.entities.ai;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
import org.bukkit.entity.Mob;
import org.jetbrains.annotations.NotNull;
@@ -16,8 +17,8 @@ public interface ControlledEntity {
* @param goal The goal.
* @return The entity.
*/
ControlledEntity addTarget(int priority,
@NotNull EntityGoal goal);
ControlledEntity addTargetGoal(int priority,
@NotNull TargetGoal goal);
/**
* Add a goal to the entity.
@@ -26,8 +27,8 @@ public interface ControlledEntity {
* @param goal The goal.
* @return The entity.
*/
ControlledEntity addGoal(int priority,
@NotNull EntityGoal goal);
ControlledEntity addEntityGoal(int priority,
@NotNull EntityGoal goal);
/**
* Get the mob back from the controlled entity.

View File

@@ -1,11 +0,0 @@
package com.willfp.eco.core.entities.ai.goals;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
public record EntityGoalNearestAttackableTarget(
@NotNull Class<? extends LivingEntity> targetClass,
boolean checkVisibility
) implements EntityGoal {
}

View File

@@ -0,0 +1,8 @@
package com.willfp.eco.core.entities.ai.goals;
/**
* A goal for entity AI.
*/
public interface TargetGoal {
}

View File

@@ -0,0 +1,26 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import java.util.function.Predicate;
/**
* Avoid entities.
*
* @param avoidClass The entity classes to avoid.
* @param fleeDistance The distance to flee to.
* @param slowSpeed The slow movement speed.
* @param fastSpeed The fast movement speed.
* @param filter The filter for entities to check if they should be avoided.
*/
public record EntityGoalAvoidEntity(
@NotNull Class<? extends LivingEntity> avoidClass,
double fleeDistance,
double slowSpeed,
double fastSpeed,
@NotNull Predicate<LivingEntity> filter
) implements EntityGoal {
}

View File

@@ -0,0 +1,14 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Break doors.
*
* @param maxProgress The time taken to break the door (any integer above 240).
*/
public record EntityGoalBreakDoor(
int maxProgress
) implements EntityGoal {
}

View File

@@ -0,0 +1,11 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Breathe air.
*/
public record EntityGoalBreatheAir(
) implements EntityGoal {
}

View File

@@ -0,0 +1,11 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Eat block.
*/
public record EntityGoalEatBlock(
) implements EntityGoal {
}

View File

@@ -0,0 +1,14 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Flee sun.
*
* @param speed The speed at which to flee.
*/
public record EntityGoalFleeSun(
double speed
) implements EntityGoal {
}

View File

@@ -0,0 +1,11 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Float in water.
*/
public record EntityGoalFloat(
) implements EntityGoal {
}

View File

@@ -0,0 +1,11 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Follow boats.
*/
public record EntityGoalFollowBoats(
) implements EntityGoal {
}

View File

@@ -0,0 +1,18 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
/**
* Follow other mobs.
*
* @param speed The speed at which to follow.
* @param minDistance The minimum follow distance.
* @param maxDistance The maximum follow distance.
*/
public record EntityGoalFollowMobs(
double speed,
double minDistance,
double maxDistance
) implements EntityGoal {
}

View File

@@ -0,0 +1,20 @@
package com.willfp.eco.core.entities.ai.goals.entity;
import com.willfp.eco.core.entities.ai.goals.EntityGoal;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
/**
* Interact with other mobs.
*
* @param targetClass The type of entity to interact with.
* @param range The range at which to interact.
* @param chance The chance for interaction, as a percentage.
*/
public record EntityGoalInteract(
@NotNull Class<? extends LivingEntity> targetClass,
double range,
double chance
) implements EntityGoal {
}

View File

@@ -0,0 +1,23 @@
package com.willfp.eco.core.entities.ai.goals.target;
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
/**
* Hurt by entity.
*
* @param blacklist The entities not to attack when hurt by.
*/
public record TargetGoalHurtBy(
@NotNull Class<? extends LivingEntity>... blacklist
) implements TargetGoal {
/**
* Create target goal.
*
* @param blacklist The entities not to attack when hurt by.
*/
@SafeVarargs
public TargetGoalHurtBy {
}
}

View File

@@ -0,0 +1,18 @@
package com.willfp.eco.core.entities.ai.goals.target;
import com.willfp.eco.core.entities.ai.goals.TargetGoal;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
/**
* Target nearest attackable entity.
*
* @param targetClass The types of entities to attack.
* @param checkVisibility If visibility should be checked.
*/
public record TargetGoalNearestAttackable(
@NotNull Class<? extends LivingEntity> targetClass,
boolean checkVisibility
) implements TargetGoal {
}