Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.risenphoenix.jnk.StarField.AI;
- import java.util.ArrayList;
- import net.risenphoenix.jnk.StarField.Engine;
- import net.risenphoenix.jnk.StarField.Entity.Entity;
- import net.risenphoenix.jnk.StarField.Entity.EntityType;
- public class AIEngine {
- private ArrayList<SFAIAction> events = new ArrayList<SFAIAction>();
- private ArrayList<SFAIAction> purge = new ArrayList<SFAIAction>();
- private int ticks;
- private final int limit = 100;
- public void tickEngine() {
- ticks++;
- tickActions();
- checkStatus();
- purge();
- if (ticks >= limit) {
- assignActions();
- ticks = 0;
- }
- }
- private void tickActions() {
- for (SFAIAction action:events) {
- action.tickAction();
- }
- }
- private void checkStatus() {
- for (SFAIAction action:events) {
- if (action.isComplete()) {
- purge.add(action);
- } else if (action.getTicks() >= limit) {
- purge.add(action);
- }
- }
- }
- private void purge() {
- for (SFAIAction action:purge) {
- events.remove(action);
- }
- purge.clear();
- }
- private void assignActions() {
- ArrayList<Entity> entities = Engine.game.getEntityEngine().getEntities();
- for (Entity e:entities) {
- // Main AI Assignment Logic
- if (e.getEntityType().equals(EntityType.ASTEROID)) {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement