/** Executes this {@code Wait} task. * @return {@link Status#SUCCEEDED} if the specified timeout has expired; {@link Status#RUNNING} otherwise. */ @Override public Status execute () { return GdxAI.getTimepiece().getTime() - startTime < timeout ? Status.RUNNING : Status.SUCCEEDED; }
/** Creates a {@code BehaviorTreeLibrary} with the given debug level and using the new internal resolver returned by the call * {@link FileSystem#newResolver(FileType) GdxAI.getFileSystem().newResolver(FileType.Internal)}. * @param parseDebugLevel the debug level the parser will use */ public BehaviorTreeLibrary (int parseDebugLevel) { this(GdxAI.getFileSystem().newResolver(FileType.Internal), parseDebugLevel); }
/** Draws a value from the distribution that determines the seconds to wait for. * <p> * This method is called when the task is entered. Also, this method internally calls {@link Timepiece#getTime() * GdxAI.getTimepiece().getTime()} to get the current AI time. This means that * <ul> * <li>if you forget to {@link Timepiece#update(float) update the timepiece} this task will keep running indefinitely.</li> * <li>the timepiece should be updated before this task runs.</li> * </ul> */ @Override public void start () { timeout = seconds.nextFloat(); startTime = GdxAI.getTimepiece().getTime(); }
@Override protected void startStatement (String name, boolean isSubtreeReference, boolean isGuard) { if (btParser.debugLevel > BehaviorTreeParser.DEBUG_LOW) GdxAI.getLogger().debug(TAG, (isGuard? " guard" : " task") + " name '" + name + "'"); this.isSubtreeRef = isSubtreeReference; this.statement = isSubtreeReference ? Statement.TreeTask : checkStatement(name); if (isGuard) { if (statement != Statement.TreeTask) throw new GdxRuntimeException(name + ": only tree's tasks can be guarded"); } statement.enter(this, name, isGuard); }
@Override public boolean finalizeSearch (long timeToRun) { hpfRequest.pathFound = pathFound; if (pathFound) { // Take the first move of this plan and use it for the next run through endNode = resultPath.get(1); } if (DEBUG) GdxAI.getLogger().debug(TAG, "LevelPathFinder finalizeSearch; status: " + status); return true; }
@Override public FileHandleResolver newResolver (final FileType fileType) { return new FileHandleResolver() { @Override public FileHandle resolve (String fileName) { return new DesktopFileHandle(fileName, fileType); } }; }
@Override public void debug (String tag, String message) { println("DEBUG", tag, message); }
@Override public FileHandle resolve (String fileName) { return new DesktopFileHandle(fileName, fileType); } };
@Override public void error (String tag, String message) { println("ERROR", tag, message); }
@Override public FileHandle newFileHandle (String fileName, FileType type) { return new DesktopFileHandle(fileName, type); }
@Override public void info (String tag, String message) { println("INFO", tag, message); }
@Override public FileHandle newFileHandle (String fileName) { return new DesktopFileHandle(fileName, FileType.Absolute); }
@Override public void debug (String tag, String message, Throwable exception) { println("DEBUG", tag, message, exception); }
@Override public FileHandle newFileHandle (File file) { return new DesktopFileHandle(file, FileType.Absolute); }
@Override public void info (String tag, String message, Throwable exception) { println("INFO", tag, message, exception); }
@Override public FileHandle newFileHandle (File file, FileType type) { return new DesktopFileHandle(file, type); }
@Override public void error (String tag, String message, Throwable exception) { println("ERROR", tag, message, exception); }
public FileHandle parent () { File parent = file.getParentFile(); if (parent == null) { if (type == FileType.Absolute) parent = new File("/"); else parent = new File(""); } return new DesktopFileHandle(parent, type); }