/** 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; }
/** 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(); }
/** 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, float currentTime = 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(); } }
float currentTime = GdxAI.getTimepiece().getTime(); if (this.lastTime != currentTime) {
/** 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; }
/** 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(); if (this.lastTime != currentTime) {
protected void monitorAnimationTransition(DogCharacter dog, TaskAnimation ta) { if (dog.monitoredTaskAnimation != ta) { if (dog.currentTaskAnimation != null) { dog.monitoredTaskAnimation = ta; dog.switchAnimationTime = GdxAI.getTimepiece().getTime() + 0.2f; return; } } else if (dog.switchAnimationTime < GdxAI.getTimepiece().getTime()) { return; } // Start the new animation since the dog has maintained appropriate speed for long enough dog.currentTaskAnimation = ta; dog.monitoredTaskAnimation = null; dog.switchAnimationTime = -1; startAnimation(dog); }
@Override protected SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { float now = GdxAI.getTimepiece().getTime(); if (lastTime > 0) { float delta = now - lastTime;
/** 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(); }
/** 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(); }
/** 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); } }
/** * 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); } }
public void update(float deltaTime) { // Update AI time GdxAI.getTimepiece().update(deltaTime); // Dispatch delayed messages MessageManager.getInstance().update(); // Update Bullet simulation // On default fixedTimeStep = 1/60, small objects (the stick) will fall through // the ground (the ground has relatively big triangles). dynamicsWorld.stepSimulation(deltaTime, 10, 1f / 240f); for (GameObject object : objectsById.values()) { if (object != null) { object.update(deltaTime); } } }
/** 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(); } }
GdxAI.getTimepiece().update(tpf);
/** * 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 SteeringAcceleration<T> calculateRealSteering (SteeringAcceleration<T> steering) { float now = GdxAI.getTimepiece().getTime(); if (lastTime > 0) { float delta = now - lastTime;