Apply BASE engine improvements
This commit is contained in:
@@ -20,7 +20,7 @@ public class AnimalAI implements AI {
|
||||
this.animal = animal;
|
||||
this.character = character;
|
||||
this.range = range;
|
||||
this.idleAI = new RandomMovementAI(animal, 4);
|
||||
this.idleAI = new RandomMovementAI<>(animal, 4);
|
||||
this.runawayAI = new RunawayAI<>(animal, character);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class SimpleEnemyAI extends FollowEntityAI<Enemy, Character> {
|
||||
public SimpleEnemyAI(Enemy enemy, Character target, int range) {
|
||||
super(new AstarPathFinder(ASTAR_MAX_NODES), enemy, target);
|
||||
this.range = range;
|
||||
this.idle = new RandomMovementAI(enemy, IDLE_MOVEMENT_INTERVAL);
|
||||
this.idle = new RandomMovementAI<>(enemy, IDLE_MOVEMENT_INTERVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.bartlomiejpluta.demo.util;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DiceRoller {
|
||||
private static final Pattern CODE_PATTERN = Pattern.compile("(\\d+)d(\\d+)([+-]\\d+)?");
|
||||
private final Random random = new Random();
|
||||
private int rolls;
|
||||
private int dice;
|
||||
private int modifier;
|
||||
|
||||
public int roll() {
|
||||
var sum = modifier;
|
||||
|
||||
for(int i=0; i<rolls; ++i) {
|
||||
sum += random.nextInt(dice) + 1;
|
||||
}
|
||||
|
||||
return Math.max(0, sum);
|
||||
}
|
||||
|
||||
public static DiceRoller of(String code) {
|
||||
var matcher = CODE_PATTERN.matcher(code);
|
||||
matcher.matches();
|
||||
return new DiceRoller(Integer.valueOf(matcher.group(1)), Integer.valueOf(matcher.group(2)), Integer.valueOf(matcher.group(3)));
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ import lombok.*;
|
||||
import org.joml.Vector2i;
|
||||
import com.bartlomiejpluta.base.api.context.Context;
|
||||
import com.bartlomiejpluta.base.lib.animation.*;
|
||||
import com.bartlomiejpluta.base.util.random.DiceRoller;
|
||||
|
||||
import com.bartlomiejpluta.demo.database.model.MeleeWeaponModel;
|
||||
import com.bartlomiejpluta.demo.entity.Character;
|
||||
import com.bartlomiejpluta.demo.util.DiceRoller;
|
||||
|
||||
import com.bartlomiejpluta.demo.event.HitEvent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user