From f18305a3c4ebf722ed37dc23a0734c919142c153 Mon Sep 17 00:00:00 2001 From: Gary Tierney Date: Sun, 31 Dec 2017 07:09:23 +0000 Subject: [PATCH] Add a tick counter that updates on every World pulse --- .../main/java/org/apollo/game/model/World.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/game/src/main/java/org/apollo/game/model/World.java b/game/src/main/java/org/apollo/game/model/World.java index 991a41fc..3473eb8c 100644 --- a/game/src/main/java/org/apollo/game/model/World.java +++ b/game/src/main/java/org/apollo/game/model/World.java @@ -66,6 +66,11 @@ public final class World { } + /** + * A counter for the number of ticks ran. + */ + private long tickCounter = 0; + /** * The logger for this class. */ @@ -208,6 +213,15 @@ public final class World { return releaseNumber; } + /** + * Get the current value of the {@link #tickCounter} (the number of ticks since the game started). + * + * @return The current value of the tick counter; + */ + public long tick() { + return tickCounter; + } + /** * Initialises the world by loading definitions from the specified file * system. @@ -277,6 +291,7 @@ public final class World { unregisterNpcs(); registerNpcs(); scheduler.pulse(); + tickCounter++; } /**