Class GameTime
java.lang.Object
zombie.GameTime
Tracks both in-game time and real world time. This class is very old and so has a lot of random/deprecated functionality.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfloatstatic GameTimeBecause 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.floatfloatstatic final floatfloatstatic final floatfloatintfloatstatic final floatstatic final floatfloatintfloatfloat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdaysInMonth(int year, int month) Returns the number of days in a month.floatDeprecated.floatDeprecated.floatDeprecated.intgetDawn()Deprecated.intgetDay()Current day of the month in the game world.intCurrent day of the month in the game world, plus 1.intThe number of full days survived by the current local player who has survived the longest modulo 30.getDeathString(IsoPlayer playerObj) Returns the time survived string to show on death for a player.floatDelta between the default and current day length (as configured in the sandbox options).intgetDusk()Deprecated.String describing the current game mode.floatNumber of in-game seconds passed since the last tick.intintintintintgetHour()doubleDeprecated.static GameTimefloatReturn the inverse of getMultiplier() (1 / getMultiplier()).floatfloatDeprecated.floatDeprecated.intfloatlongNumber of minutes since the world was created.floatDeprecated.floatDeprecated.se.krka.kahlua.vm.KahluaTableThis was used to store non-object-specific mod data in the save file before global mod data was added.intgetMonth()Current month of the year in the game world.floatNumber of real world seconds since the last tick, multiplied by game speed.floatNumber of real world seconds since the last tick, multiplied by game speed.floatgetMultiplierFromTimeDelta(float in_timeDelta) floatgetNight()Deprecated.floatDeprecated.floatDeprecated.intGets the number of nights that have passed since the save was created.floatDeprecated.floatNumber of real seconds since the last tick.floatDelta based on the target framerate rather than the actual framerate.static longstatic longstatic booleanintintDay of the month the game started on as defined by sandbox options.intMonth of the year the game started on as defined by sandbox options.floatTime of day the game started on as defined by sandbox options.intYear the game started on.floatbooleanDeprecated.floatNumber of real world seconds since the last tick, multiplied by game speed.floatgetTimeDeltaFromMultiplier(float in_multiplier) floatgetTimeSurvived(IsoPlayer playerObj) Gets a string that describes how long a player has survived for.floatReturns the current game speed multiplier (from the singleplayer speed up UI or while all players are sleeping).floatNumber of real world seconds since the last tick, multiplied by game speed.floatfloatfloatDeprecated.doubledoubleGets the age of the world from the start of the game in hours.intgetYear()Current year in the game world.getZombieKilledText(IsoPlayer playerObj) Returns a string describing how many zombies a player has killed.voidinit()booleanisDay()booleanbooleanstatic booleanbooleanisNight()booleanbooleanDeprecated.booleanbooleanfloatLerp(float start, float end, float delta) Interpolates between two values by a given amount.voidload()voidload(DataInputStream input) voidload(ByteBuffer input) voidRemoveZombiesIndiscriminate(int i) Removes a specific number of zombies from the world.voidsave()voidsave(DataOutputStream output) voidsave(ByteBuffer output) voidsaveToBufferMap(SaveBufferMap bufferMap) voidvoidsetAmbient(float Ambient) Deprecated.voidsetAmbientMax(float AmbientMax) Deprecated.voidsetAmbientMin(float AmbientMin) Deprecated.voidsetCalender(PZCalendar Calender) voidsetDawn(int dawn) Deprecated.voidsetDay(int Day) Current day of the month in the game world.voidsetDusk(int dusk) Deprecated.voidsetHelicopterDay(int day) voidsetHelicopterEndHour(int hour) voidsetHelicopterStartHour(int hour) voidsetHoursSurvived(double HoursSurvived) Deprecated.static voidsetInstance(GameTime aInstance) voidsetLastTimeOfDay(float LastTimeOfDay) voidsetMaxZombieCount(float MaxZombieCount) Deprecated.voidsetMaxZombieCountStart(float MaxZombieCountStart) Deprecated.voidsetMinutesPerDay(float MinutesPerDay) voidsetMinZombieCount(float MinZombieCount) Deprecated.voidsetMinZombieCountStart(float MinZombieCountStart) Deprecated.voidsetMonth(int Month) Current month of the year in the game world.voidsetMoon(float moon) Deprecated.voidsetMultiplier(float in_multiplier) The multiplier scales the game simulation speed.voidsetNightMax(float max) Deprecated.voidsetNightMin(float min) Deprecated.voidsetNightsSurvived(int NightsSurvived) Number of nights since the game began.static voidsetServerTimeShift(long tshift) voidsetStartDay(int StartDay) Day of the month the game started on as defined by sandbox options.voidsetStartMonth(int StartMonth) Month of the year the game started on as defined by sandbox options.voidsetStartTimeOfDay(float StartTimeOfDay) Time of day the game started on as defined by sandbox options.voidsetStartYear(int StartYear) Year the game started on.voidsetTargetZombies(int TargetZombies) Deprecated.voidsetThunderDay(boolean thunderDay) Deprecated.voidsetTimeOfDay(float TimeOfDay) voidsetViewDistMax(float ViewDistMax) voidsetViewDistMin(float ViewDistMin) Deprecated.voidsetYear(int Year) Current year in the game world.static voidsyncServerTime(long timeClientSend, long timeServer, long timeClientReceive) floatTimeLerp(float startVal, float endVal, float startTime, float endTime) Interpolates between two values based on the current time of day.voidupdate(boolean bSleeping) voidupdateCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute)
-
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
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
-
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
-
setInstance
-
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
-
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
-
getZombieKilledText
-
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
-
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
- Returns:
- the Calender
-
setCalender
- 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
-
save
public void save() -
save
- Throws:
IOException
-
save
- Throws:
IOException
-
load
- Throws:
IOException
-
load
- 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
- 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()
-