/** 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; }
float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG, "Instant telegram dispatched at time: " + currentTime + " by " + sender + " for " + receiver float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG, "Delayed telegram from " + sender + " for " + receiver + " recorded at time " + currentTime + ". Message code is " + msg); else GdxAI.getLogger().info(LOG_TAG, "Delayed telegram from " + sender + " for " + receiver + " rejected by the queue. Message code is " + msg);
/** 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); }
@Override protected void startLine (int indent) { if (btParser.debugLevel > BehaviorTreeParser.DEBUG_LOW) GdxAI.getLogger().debug(TAG, lineNumber + ": <" + indent + ">"); this.indent = indent; }
@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; }
/** 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(); }
/** Dispatches any delayed telegrams with a timestamp that has expired. Dispatched telegrams are removed from the queue. * <p> * This method must be called regularly from inside the main game loop to facilitate the correct and timely dispatch of any * delayed messages. Notice that the message dispatcher internally calls {@link Timepiece#getTime() * GdxAI.getTimepiece().getTime()} to get the current AI time and properly dispatch delayed messages. This means that * <ul> * <li>if you forget to {@link Timepiece#update(float) update the timepiece} the delayed messages won't be dispatched.</li> * <li>ideally the timepiece should be updated before the message dispatcher.</li> * </ul> */ public void update () { float currentTime = GdxAI.getTimepiece().getTime(); // Peek at the queue to see if any telegrams need dispatching. // Remove all telegrams from the front of the queue that have gone // past their time stamp. Telegram telegram; while ((telegram = queue.peek()) != null) { // Exit loop if the telegram is in the future if (telegram.getTimestamp() > currentTime) break; if (debugEnabled) { GdxAI.getLogger().info(LOG_TAG, "Queued telegram ready for dispatch: Sent to " + telegram.receiver + ". Message code is " + telegram.message); } // Send the telegram to the recipient discharge(telegram); // Remove it from the queue queue.poll(); } }
@Override public boolean search (PathFinder<N> pathFinder, long timeToRun) { if (DEBUG) GdxAI.getLogger().debug(TAG, "LevelPathFinder search; status: " + status); return super.search(pathFinder, timeToRun); }
/** 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); }
/** Scans the queue and passes pending messages to the given callback in any particular order. * <p> * Typically this method is used to save (serialize) pending messages and restore (deserialize and schedule) them back on game * loading. * @param callback The callback used to report pending messages individually. **/ public void scanQueue (PendingMessageCallback callback) { float currentTime = GdxAI.getTimepiece().getTime(); int queueSize = queue.size(); for (int i = 0; i < queueSize; i++) { Telegram telegram = queue.get(i); callback.report(telegram.getTimestamp() - currentTime, telegram.sender, telegram.receiver, telegram.message, telegram.extraInfo, telegram.returnReceiptStatus); } }
float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG, "Instant telegram dispatched at time: " + currentTime + " by " + sender + " for " + receiver float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG, "Delayed telegram from " + sender + " for " + receiver + " recorded at time " + currentTime + ". Message code is " + msg); else GdxAI.getLogger().info(LOG_TAG, "Delayed telegram from " + sender + " for " + receiver + " rejected by the queue. Message code is " + msg);
@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); }
float currentTime = GdxAI.getTimepiece().getTime(); if (this.lastTime != currentTime) {
float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG + "Instant telegram dispatched at time: " + currentTime + " by " + sender + " for " + receiver float currentTime = GdxAI.getTimepiece().getTime(); GdxAI.getLogger().info( LOG_TAG + "Delayed telegram from " + sender + " for " + receiver + " recorded at time " + currentTime + ". Message code is " + msg); else GdxAI.getLogger().info(LOG_TAG + "Delayed telegram from " + sender + " for " + receiver + " rejected by the queue. Message code is " + msg);
+ maxVerticalVelocity * maxVerticalVelocity); float time = (-maxVerticalVelocity + sqrtTerm) / g; if (DEBUG_ENABLED) GdxAI.getLogger().info("Jump", "1st jump time = " + time); if (DEBUG_ENABLED) GdxAI.getLogger().info("Jump", "2nd jump time = " + time); if (!checkAirborneTimeAndCalculateVelocity(outVelocity, time, jumpDescriptor, maxLinearSpeed)) { return -1f; // Unachievable jump
/** 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; }
/** Dispatches any delayed telegrams with a timestamp that has expired. Dispatched telegrams are removed from the queue. * <p> * This method must be called regularly from inside the main game loop to facilitate the correct and timely dispatch of any * delayed messages. Notice that the message dispatcher internally calls {@link Timepiece#getTime() * GdxAI.getTimepiece().getTime()} to get the current AI time and properly dispatch delayed messages. This means that * <ul> * <li>if you forget to {@link Timepiece#update(float) update the timepiece} the delayed messages won't be dispatched.</li> * <li>ideally the timepiece should be updated before the message dispatcher.</li> * </ul> */ public void update () { float currentTime = GdxAI.getTimepiece().getTime(); // Peek at the queue to see if any telegrams need dispatching. // Remove all telegrams from the front of the queue that have gone // past their time stamp. Telegram telegram; while ((telegram = queue.peek()) != null) { // Exit loop if the telegram is in the future if (telegram.getTimestamp() > currentTime) break; if (debugEnabled) { GdxAI.getLogger().info(LOG_TAG, "Queued telegram ready for dispatch: Sent to " + telegram.receiver + ". Message code is " + telegram.message); } // Send the telegram to the recipient discharge(telegram); // Remove it from the queue queue.poll(); } }
@Override protected void attribute (String name, Object value) { if (btParser.debugLevel > BehaviorTreeParser.DEBUG_LOW) GdxAI.getLogger().debug(TAG, lineNumber + ": attribute '" + name + " : " + value + "'"); boolean validAttribute = statement.attribute(this, name, value); if (!validAttribute) { if (statement == Statement.TreeTask) { throw stackedTaskException(getCurrentTask(), "unknown attribute '" + name + "'"); } else { throw new GdxRuntimeException(statement.name + ": unknown attribute '" + name + "'"); } } }
/** 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; }
/** * Dispatches any delayed telegrams with a timestamp that has expired. Dispatched telegrams are removed from the queue. * <p> * This method must be called regularly from inside the main game loop to facilitate the correct and timely dispatch of any * delayed messages. Notice that the message dispatcher internally calls {@link Timepiece#getTime() * GdxAI.getTimepiece().getTime()} to get the current AI time and properly dispatch delayed messages. This means that * <ul> * <li>if you forget to {@link Timepiece#update(float) update the timepiece} the delayed messages won't be dispatched.</li> * <li>ideally the timepiece should be updated before the message dispatcher.</li> * </ul> */ public void update() { float currentTime = GdxAI.getTimepiece().getTime(); // Peek at the queue to see if any telegrams need dispatching. // Remove all telegrams from the front of the queue that have gone // past their time stamp. Telegram telegram; while ((telegram = queue.peek()) != null) { // Exit loop if the telegram is in the future if (telegram.getTimestamp() > currentTime) break; if (debugEnabled) { GdxAI.getLogger().info(LOG_TAG + "Queued telegram ready for dispatch: Sent to " + telegram.receiver + ". Message code is " + telegram.message); } // Send the telegram to the recipient discharge(telegram); // Remove it from the queue queue.poll(); } }