Class GameTime

java.lang.Object
zombie.GameTime

public final class GameTime extends Object
Tracks both in-game time and real world time. This class is very old and so has a lot of random/deprecated functionality.
  • Field Details

    • MinutesPerHour

      public static final float MinutesPerHour
      See Also:
    • SecondsPerHour

      public static final float SecondsPerHour
      See Also:
    • SecondsPerMinute

      public static final float SecondsPerMinute
      See Also:
    • MULTIPLIER

      public static final float MULTIPLIER
      See Also:
    • instance

      public static GameTime instance
      Because of how Kahlua exposes static fields, when accessed from Lua, this will return a stale GameTime object that does not hold the correct game state. Lua mods should always use getGameTime() or GameTime.getInstance() instead of this field.
    • timeOfDay

      public float timeOfDay
    • nightsSurvived

      public int nightsSurvived
    • calender

      public PZCalendar calender
    • fpsMultiplier

      public float fpsMultiplier
    • moon

      public float moon
    • serverTimeOfDay

      public float serverTimeOfDay
    • serverLastTimeOfDay

      public float serverLastTimeOfDay
    • serverNewDays

      public int serverNewDays
    • lightSourceUpdate

      public float lightSourceUpdate
    • multiplierBias

      public float multiplierBias
    • lastLastTimeOfDay

      public float lastLastTimeOfDay
    • perObjectMultiplier

      public float perObjectMultiplier
  • Constructor Details

    • GameTime

      public GameTime()
  • Method Details

    • getInstance

      public static GameTime getInstance()
    • setInstance

      public static void setInstance(GameTime aInstance)
    • syncServerTime

      public static void syncServerTime(long timeClientSend, long timeServer, long timeClientReceive)
    • getServerTime

      public static long getServerTime()
    • getServerTimeMills

      public static long getServerTimeMills()
    • getServerTimeShiftIsSet

      public static boolean getServerTimeShiftIsSet()
    • setServerTimeShift

      public static void setServerTimeShift(long tshift)
    • isGamePaused

      public static boolean isGamePaused()
    • getRealworldSecondsSinceLastUpdate

      public float getRealworldSecondsSinceLastUpdate()
      Number of real seconds since the last tick.
    • getMultipliedSecondsSinceLastUpdate

      public float getMultipliedSecondsSinceLastUpdate()
      Number of real world seconds since the last tick, multiplied by game speed.
    • getGameWorldSecondsSinceLastUpdate

      public float getGameWorldSecondsSinceLastUpdate()
      Number of in-game seconds passed since the last tick.
    • daysInMonth

      public int daysInMonth(int year, int month)
      Returns the number of days in a month.
      Parameters:
      year - Year of the month. Required to account for leap years.
      month - 0 indexed month of the year.
      Returns:
      Number of days in the month.
    • getDeathString

      public String getDeathString(IsoPlayer playerObj)
      Returns the time survived string to show on death for a player.
      Parameters:
      playerObj - Player to get the string for.
      Returns:
      Time survived string.
    • getDaysSurvived

      public int getDaysSurvived()
      The number of full days survived by the current local player who has survived the longest modulo 30.
      Returns:
      Highest number of days survived by a current local player modulo 30.
    • getTimeSurvived

      public String getTimeSurvived(IsoPlayer playerObj)
      Gets a string that describes how long a player has survived for.
      Parameters:
      playerObj - Player to get the string for.
      Returns:
      String describing how long the player has survived.
    • getZombieKilledText

      public String getZombieKilledText(IsoPlayer playerObj)
      Returns a string describing how many zombies a player has killed.
      Parameters:
      playerObj - Player to get the string for.
      Returns:
      String describing how many zombies the player has killed.
    • getGameModeText

      public String getGameModeText()
      String describing the current game mode.
    • init

      public void init()
    • Lerp

      public float Lerp(float start, float end, float delta)
      Interpolates between two values by a given amount.
      Parameters:
      start - Value to interpolation from.
      end - Value to interpolate to.
      delta - 0-1 amount to interpolate between the two values.
      Returns:
      Interpolated value.
    • RemoveZombiesIndiscriminate

      public void RemoveZombiesIndiscriminate(int i)
      Removes a specific number of zombies from the world.
      Parameters:
      i - Number of zombies to remove.
    • TimeLerp

      public float TimeLerp(float startVal, float endVal, float startTime, float endTime)
      Interpolates between two values based on the current time of day.
      Parameters:
      startVal - Value to interpolate from.
      endVal - Value to interpoalte to.
      startTime - Time of day in hours to start interpolation. If the current time is before this, startVal is returned.
      endTime - Time of day in hours to end interpolation. If the current time is after this, endVal is returned. If this is less than startTime, it is considered a time in the next day.
      Returns:
      Interpolated value based on the current time.
    • getDeltaMinutesPerDay

      public float getDeltaMinutesPerDay()
      Delta between the default and current day length (as configured in the sandbox options). When using a time delta, multiply by this as well to make the value increase at a fixed game-time rate rather than real time.
      Returns:
      The default day length is considered by this method to be 30 minutes, so a 0.33 delta is expected on default settings, not 1.
    • getNightMin

      public float getNightMin()
      Deprecated.
    • setNightMin

      public void setNightMin(float min)
      Deprecated.
    • getNightMax

      public float getNightMax()
      Deprecated.
    • setNightMax

      public void setNightMax(float max)
      Deprecated.
    • getMinutes

      public int getMinutes()
    • setMoon

      public void setMoon(float moon)
      Deprecated.
    • update

      public void update(boolean bSleeping)
    • getMinutesStamp

      public long getMinutesStamp()
      Number of minutes since the world was created. Has the same inaccuracy as getWorldAgeHours().
      Returns:
      Number of minutes since the world was created.
    • getThunderStorm

      public boolean getThunderStorm()
      Deprecated.
    • getAmbient

      @Deprecated public float getAmbient()
      Deprecated.
      Returns:
      the Ambient
    • getSkyLightLevel

      public int getSkyLightLevel()
    • setAmbient

      public void setAmbient(float Ambient)
      Deprecated.
      Parameters:
      Ambient - the Ambient to set
    • getAmbientMax

      public float getAmbientMax()
      Deprecated.
      Returns:
      the AmbientMax
    • setAmbientMax

      public void setAmbientMax(float AmbientMax)
      Deprecated.
      Parameters:
      AmbientMax - the AmbientMax to set
    • getAmbientMin

      public float getAmbientMin()
      Deprecated.
      Returns:
      the AmbientMin
    • setAmbientMin

      public void setAmbientMin(float AmbientMin)
      Deprecated.
      Parameters:
      AmbientMin - the AmbientMin to set
    • getDay

      public int getDay()
      Current day of the month in the game world.
      Returns:
      0 indexed day of the month.
    • setDay

      public void setDay(int Day)
      Current day of the month in the game world.
      Parameters:
      Day - 0 indexed day of the month.
    • getDayPlusOne

      public int getDayPlusOne()
      Current day of the month in the game world, plus 1.
      Returns:
      1 indexed day of the month.
    • getStartDay

      public int getStartDay()
      Day of the month the game started on as defined by sandbox options. The value will change if sandbox options are changed, so getNightsSurvived() or getWorldAgeHours() should be used instead to determine the age of the world.
      Returns:
      0 indexed day of the month the game started on.
    • setStartDay

      public void setStartDay(int StartDay)
      Day of the month the game started on as defined by sandbox options. Changing this does not affect the age of the world.
      Parameters:
      StartDay - 0 indexed day of the month the game started on.
    • getMaxZombieCountStart

      public float getMaxZombieCountStart()
      Deprecated.
      Returns:
      the MaxZombieCountStart
    • setMaxZombieCountStart

      public void setMaxZombieCountStart(float MaxZombieCountStart)
      Deprecated.
      Parameters:
      MaxZombieCountStart - the MaxZombieCountStart to set
    • getMinZombieCountStart

      public float getMinZombieCountStart()
      Deprecated.
      Returns:
      the MinZombieCountStart
    • setMinZombieCountStart

      public void setMinZombieCountStart(float MinZombieCountStart)
      Deprecated.
      Parameters:
      MinZombieCountStart - the MinZombieCountStart to set
    • getMaxZombieCount

      public float getMaxZombieCount()
      Deprecated.
      Returns:
      the MaxZombieCount
    • setMaxZombieCount

      public void setMaxZombieCount(float MaxZombieCount)
      Deprecated.
      Parameters:
      MaxZombieCount - the MaxZombieCount to set
    • getMinZombieCount

      public float getMinZombieCount()
      Deprecated.
      Returns:
      the MinZombieCount
    • setMinZombieCount

      public void setMinZombieCount(float MinZombieCount)
      Deprecated.
      Parameters:
      MinZombieCount - the MinZombieCount to set
    • getMonth

      public int getMonth()
      Current month of the year in the game world.
      Returns:
      0 indexed month of the year.
    • setMonth

      public void setMonth(int Month)
      Current month of the year in the game world.
      Parameters:
      Month - 0 indexed month of the year.
    • getStartMonth

      public int getStartMonth()
      Month of the year the game started on as defined by sandbox options. The value will change if sandbox options are changed, so getNightsSurvived() or getWorldAgeHours() should be used instead to determine the age of the world.
      Returns:
      0 indexed month of the year the game started on.
    • setStartMonth

      public void setStartMonth(int StartMonth)
      Month of the year the game started on as defined by sandbox options. Changing this does not affect the age of the world.
      Parameters:
      StartMonth - 0 indexed month of the year the game started on.
    • getNightTint

      public float getNightTint()
      Deprecated.
      Returns:
      the NightTint
    • getNight

      public float getNight()
      Deprecated.
      Returns:
      the NightTint
    • getTimeOfDay

      public float getTimeOfDay()
      Returns:
      the TimeOfDay
    • setTimeOfDay

      public void setTimeOfDay(float TimeOfDay)
      Parameters:
      TimeOfDay - the TimeOfDay to set
    • getStartTimeOfDay

      public float getStartTimeOfDay()
      Time of day the game started on as defined by sandbox options. The value will change if sandbox options are changed, so getNightsSurvived() or getWorldAgeHours() should be used instead to determine the age of the world.
      Returns:
      The time of day in hours the game started at.
    • setStartTimeOfDay

      public void setStartTimeOfDay(float StartTimeOfDay)
      Time of day the game started on as defined by sandbox options. The value will change if sandbox options are changed, so getNightsSurvived() or getWorldAgeHours() should be used instead to determine the age of the world. Changing this does not affect the age of the world.
      Parameters:
      StartTimeOfDay - The time of day in hours the game started at.
    • getViewDist

      public float getViewDist()
      Returns:
      the ViewDist
    • getViewDistMax

      public float getViewDistMax()
      Returns:
      the ViewDistMax
    • setViewDistMax

      public void setViewDistMax(float ViewDistMax)
      Parameters:
      ViewDistMax - the ViewDistMax to set
    • getViewDistMin

      public float getViewDistMin()
      Deprecated.
      Returns:
      the ViewDistMin
    • setViewDistMin

      public void setViewDistMin(float ViewDistMin)
      Deprecated.
      Parameters:
      ViewDistMin - the ViewDistMin to set
    • getYear

      public int getYear()
      Current year in the game world.
      Returns:
      Current year in the game world.
    • setYear

      public void setYear(int Year)
      Current year in the game world.
    • getStartYear

      public int getStartYear()
      Year the game started on.
      Returns:
      Year the game started on.
    • setStartYear

      public void setStartYear(int StartYear)
      Year the game started on. Changing this does not affect the age of the world.
      Parameters:
      StartYear - Year the game started on.
    • getNightsSurvived

      public int getNightsSurvived()
      Gets the number of nights that have passed since the save was created. 7am is considered the end of a night.
      Returns:
      Number of nights since game start.
    • setNightsSurvived

      public void setNightsSurvived(int NightsSurvived)
      Number of nights since the game began. A night is survived when the time passes 7am.
      Parameters:
      NightsSurvived - the NightsSurvived to set
    • getWorldAgeDaysSinceBegin

      public double getWorldAgeDaysSinceBegin()
    • getWorldAgeHours

      public double getWorldAgeHours()
      Gets the age of the world from the start of the game in hours. The value can be slightly off from the true value depending on game settings, as it considers every 7am passing to be a 24 hour period, however the game does not by default start at 7am. The true number of hours can be calculated by subtracting (getStartTimeOfDay() - 7). However, the uncorrected value is still suitable as a timestamp, as the offset is consistent.
      Returns:
      Age of the world in hours.
    • getHoursSurvived

      public double getHoursSurvived()
      Deprecated.
      Returns:
      the HoursSurvived
    • setHoursSurvived

      public void setHoursSurvived(double HoursSurvived)
      Deprecated.
      Parameters:
      HoursSurvived - the HoursSurvived to set
    • getHour

      public int getHour()
    • getCalender

      public PZCalendar getCalender()
      Returns:
      the Calender
    • setCalender

      public void setCalender(PZCalendar Calender)
      Parameters:
      Calender - the Calender to set
    • updateCalendar

      public void updateCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute)
    • getMinutesPerDay

      public float getMinutesPerDay()
      Returns:
      the MinutesPerDay
    • setMinutesPerDay

      public void setMinutesPerDay(float MinutesPerDay)
      Parameters:
      MinutesPerDay - the MinutesPerDay to set
    • getLastTimeOfDay

      public float getLastTimeOfDay()
      Returns:
      the LastTimeOfDay
    • setLastTimeOfDay

      public void setLastTimeOfDay(float LastTimeOfDay)
      Parameters:
      LastTimeOfDay - the LastTimeOfDay to set
    • setTargetZombies

      public void setTargetZombies(int TargetZombies)
      Deprecated.
      Parameters:
      TargetZombies - the TargetZombies to set
    • isRainingToday

      public boolean isRainingToday()
      Returns:
      the RainingToday
    • getMultiplier

      public float getMultiplier()
      Number of real world seconds since the last tick, multiplied by game speed. Also multiplied by 48 for some reason.
      Returns:
      the Multiplier
    • setMultiplier

      public void setMultiplier(float in_multiplier)
      The multiplier scales the game simulation speed. getTrueMultiplier() can be used to retrieve this value. getMultiplier() does not return this value.
      Parameters:
      in_multiplier - the Multiplier to set
    • getTimeDelta

      public float getTimeDelta()
      Number of real world seconds since the last tick, multiplied by game speed.
    • getTimeDeltaFromMultiplier

      public float getTimeDeltaFromMultiplier(float in_multiplier)
    • getMultiplierFromTimeDelta

      public float getMultiplierFromTimeDelta(float in_timeDelta)
    • getServerMultiplier

      public float getServerMultiplier()
      Delta based on the target framerate rather than the actual framerate. Unclear purpose. Probably shouldn't be used.
    • getUnmoddedMultiplier

      public float getUnmoddedMultiplier()
      Number of real world seconds since the last tick, multiplied by game speed.
    • getInvMultiplier

      public float getInvMultiplier()
      Return the inverse of getMultiplier() (1 / getMultiplier()). Per-tick RNG functions can multiply by this value to keep chances relatively stable across different framerates.
    • getTrueMultiplier

      public float getTrueMultiplier()
      Returns the current game speed multiplier (from the singleplayer speed up UI or while all players are sleeping).
    • getThirtyFPSMultiplier

      public float getThirtyFPSMultiplier()
    • saveToBufferMap

      public void saveToBufferMap(SaveBufferMap bufferMap)
    • save

      public void save()
    • save

      public void save(DataOutputStream output) throws IOException
      Throws:
      IOException
    • save

      public void save(ByteBuffer output) throws IOException
      Throws:
      IOException
    • load

      public void load(DataInputStream input) throws IOException
      Throws:
      IOException
    • load

      public void load(ByteBuffer input) throws IOException
      Throws:
      IOException
    • load

      public void load()
    • getDawn

      public int getDawn()
      Deprecated.
    • setDawn

      public void setDawn(int dawn)
      Deprecated.
    • getDusk

      public int getDusk()
      Deprecated.
    • setDusk

      public void setDusk(int dusk)
      Deprecated.
    • getModData

      public se.krka.kahlua.vm.KahluaTable getModData()
      This was used to store non-object-specific mod data in the save file before global mod data was added. It is generally better to use the global mod data API provided by ModData.
    • isThunderDay

      public boolean isThunderDay()
      Deprecated.
    • setThunderDay

      public void setThunderDay(boolean thunderDay)
      Deprecated.
    • saveToPacket

      public void saveToPacket(ByteBuffer bb) throws IOException
      Throws:
      IOException
    • getHelicopterDay1

      public int getHelicopterDay1()
    • getHelicopterDay

      public int getHelicopterDay()
    • setHelicopterDay

      public void setHelicopterDay(int day)
    • getHelicopterStartHour

      public int getHelicopterStartHour()
    • setHelicopterStartHour

      public void setHelicopterStartHour(int hour)
    • getHelicopterEndHour

      public int getHelicopterEndHour()
    • setHelicopterEndHour

      public void setHelicopterEndHour(int hour)
    • isEndlessDay

      public boolean isEndlessDay()
    • isEndlessNight

      public boolean isEndlessNight()
    • isDay

      public boolean isDay()
    • isNight

      public boolean isNight()
    • isZombieActivityPhase

      public boolean isZombieActivityPhase()
    • isZombieInactivityPhase

      public boolean isZombieInactivityPhase()