Update game time changing (triggers quests and updates properly)

This commit is contained in:
KingRainbow44
2023-05-04 21:41:41 -04:00
parent 0b87485bdf
commit 48e233eb9b
5 changed files with 28 additions and 10 deletions

View File

@@ -446,7 +446,7 @@ public class World implements Iterable<Player> {
return currentWorldTime;
}
/** Returns the current in game days world time in ingame minutes (0-1439) */
/** Returns the current in game days world time in in-game minutes (0-1439) */
public int getGameTime() {
return (int) (getTotalGameTimeMinutes() % 1440);
}
@@ -491,6 +491,22 @@ public class World implements Iterable<Player> {
this.getScenes().forEach((key, scene) -> scene.setPaused(paused));
}
/**
* Changes the game time of the world.
*
* @param gameTime The time in game minutes.
*/
public void changeTime(long gameTime) {
this.currentWorldTime = gameTime;
// Trigger script events.
this.players.forEach(
player ->
player
.getQuestManager()
.queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK));
}
/**
* Changes the time of the world.
*
@@ -512,8 +528,7 @@ public class World implements Iterable<Player> {
player ->
player
.getQuestManager()
.queueEvent(
QuestContent.QUEST_CONTENT_GAME_TIME_TICK, this.getGameTimeHours(), days));
.queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK));
}
@Override