-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: task based AI controllers and basic plane AI
- Loading branch information
Showing
11 changed files
with
268 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package me.vinceh121.wanderer.ai; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.entity.IControllableEntity; | ||
|
||
public abstract class Task<T extends IControllableEntity> { | ||
/** | ||
* @param delta Delta time in seconds | ||
* @param game TODO | ||
* @param controlled Entity being controlled | ||
* @return The next task to use, or null to keep current task | ||
*/ | ||
public abstract Task<T> process(final float delta, final Wanderer game, final T controlled); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.vinceh121.wanderer.ai; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.entity.IControllableEntity; | ||
|
||
public class TaskAIController<T extends IControllableEntity> extends AIController<T> { | ||
private Task<T> currentTask; | ||
|
||
public TaskAIController(Wanderer game, T target) { | ||
super(game, target); | ||
} | ||
|
||
@Override | ||
public void tick(float delta) { | ||
if (this.currentTask != null) { | ||
final Task<T> maybeNewTask = this.currentTask.process(delta, this.game, this.target); | ||
|
||
if (maybeNewTask != null) { | ||
this.currentTask = maybeNewTask; | ||
} | ||
} | ||
} | ||
|
||
public Task<T> getCurrentTask() { | ||
return currentTask; | ||
} | ||
|
||
public void setCurrentTask(Task<T> currentTask) { | ||
this.currentTask = currentTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.building.AbstractBuilding; | ||
|
||
public class Garage extends AbstractBuilding { | ||
|
||
public Garage(Wanderer game, GaragePrototype prototype) { | ||
super(game, prototype); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
core/src/me/vinceh121/wanderer/entity/plane/GaragePrototype.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.vinceh121.wanderer.entity.plane; | ||
|
||
import me.vinceh121.wanderer.Wanderer; | ||
import me.vinceh121.wanderer.building.AbstractBuildingPrototype; | ||
import me.vinceh121.wanderer.entity.AbstractEntity; | ||
|
||
public class GaragePrototype extends AbstractBuildingPrototype { | ||
@Override | ||
public AbstractEntity create(Wanderer game) { | ||
return new Garage(game, this); | ||
} | ||
} |
Oops, something went wrong.