-
-
Save macalinao/1509150 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package org.getspout.api.entity; | |
import org.getspout.api.entity.ai.AI; | |
import org.getspout.api.plugin.Plugin; | |
/** | |
* Represents an entity that can have AI. | |
*/ | |
public interface AIable<T extends Entity> { | |
/** | |
* Gets the current AI of the entity. | |
* @return The entity's AI | |
*/ | |
public AI getAI(); | |
/** | |
* Registers an AI with this entity. | |
* @param ai | |
* @param priority | |
* @param plugin | |
*/ | |
public void registerAI(AI<T> ai, AI.Priority priority, Plugin plugin); | |
} |
This file contains hidden or 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
package org.getspout.api.entity.ai; | |
import java.util.List; | |
import org.getspout.api.entity.Entity; | |
public abstract class AI<T extends Entity> { | |
/** | |
* Returns true if the AI should run. | |
* @return True if the AI should run. | |
*/ | |
public abstract boolean shouldRun(); | |
/** | |
* Updates the entity's AI. | |
* @param entity The entity's AI. | |
*/ | |
public abstract void pulse(T entity); | |
/** | |
* Pulses a list of entites associated with the AI. | |
* @param entities The entities to pulse. | |
*/ | |
public final void pulse(List<? extends T> entities) { | |
for (T entity : entities) { | |
pulse(entity); | |
} | |
} | |
/** | |
* An enum holding the priority of this AI's execution. | |
*/ | |
public enum Priority { | |
/** | |
* AI of the lowest priority. This AI will be executed first. | |
*/ | |
Lowest, | |
/** | |
* AI of low priority. | |
*/ | |
Low, | |
/** | |
* AI of normal priority. | |
*/ | |
Normal, | |
/** | |
* AI of high priority. | |
*/ | |
High, | |
/** | |
* AI of highest priority. This will be run last. | |
*/ | |
Highest; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment