Infinity PBR by Magic Pig Games
  • Infinity PBR Documentation
  • Game Modules 4
    • ➡️Quick Start
    • 📽️Video Tutorials
      • Quick Start: Creating Game Module Objects
      • Automating Start Actions on GameModulesActor
      • Inflicting Damage with Conditions
      • Updating UI (and more) with Blackboard Notes
      • Dynamic Menus with Item Objects and Dictionaries
      • Create Custom Quest Rewards
      • Save and Load Game Data
      • Stats: Deep Dive
      • Items: Deep Dive
      • Conditions: Deep Dive
      • First Person Movement
      • Tutorial: "Overheal" Effect with Condition & Stats
      • Tutorial: Create a Character & Actor Class Inheriting from GameModulesActor
    • 👀Game Modules Viewer
      • Viewer: Dictionaries
      • Viewer: Stat / GameStatList
      • Viewer: ItemObject / GameItemObjectList
      • Viewer: ItemAttribute / GameItemAttributeList
      • Viewer: Condition / GameConditionList
      • Viewer: Quest / GameQuestList
    • V4 Migration Tips
      • Introducing GameModulesActor
      • Interfaces
      • No More Tick*
      • Dictionaries
      • Repositories
      • Tips from Upgrading "Legend of the Stones"
    • Important Information
      • Game Modules Overview
      • Inherit from GameModulesActor
      • Things to not forget to do
      • Bugs, Backups, and Demos
      • FAQ / Tips & Tricks
      • Required Prefabs
      • Game Module Repository
      • Release Notes
    • Module Documentation
      • Game Modules Actor
      • Game Module "Lists"
        • Get() Methods
          • GameStatList Get() Methods
          • GameItemObjectList Get() Methods
          • GameItemAttribute Get() Methods
          • GameConditionList Get() Methods
          • GameQuestList Get() Methods
        • Contains() Methods
          • GameStatList Contains() Methods
          • GameItemObjectList Contains() Methods
          • GameItemAttributeList Contains() Methods
          • GameConditionList Contains() Methods
          • GameQuestList Contains() Methods
        • Count() Methods
          • GameStatList Count() Methods
          • GameItemObjectList Count() Methods
          • GameItemAttributeList Count() Methods
          • GameConditionList Count() Methods
          • GameQuestList Count() Methods
        • Remove() Methods
          • GameStatList Remove() Methods
          • GameItemObjectList Remove() Methods
          • GameItemAttributeList Remove() Methods
          • GameConditionList Remove() Methods
          • GameQuestList Remove() Methods
        • GameStatList
        • GameItemObjectList
        • GameItemAttributeList
        • GameQuestList
        • GameConditionList
      • Blackboard
        • Blackboard.cs
        • Blackboard Follower
        • Blackboard Note
        • Blackboard Event
        • Blackboard Values
        • Tips & Tricks
          • Use extension methods to check BlackboardNotes (or events)
      • Stats
        • IHaveStats
        • Stat.cs
        • GameStat.cs
        • GameStatList.cs
        • Mastery Levels
      • Loot
        • LootItems.cs
        • LootBox.cs
        • GameLootBox.cs
        • Generating & Handling Loot
        • Custom Loot Generation Algorithm
      • Items
        • ItemObject.cs
          • Manage Item Objects
          • Allowed Item Attributes
          • Starting Item Attributes
          • Item Attribute Variables
            • Variables Methods
        • GameItemObject.cs
        • GameItemObjectList.cs
        • ItemAttribute.cs
          • Manage Item Attributes
          • General Settings
          • Name Settings
          • Requisite Attributes
        • GameItemAttribute.cs
        • GameItemAttributeList.cs
        • Code Examples
      • Conditions
        • Condition.cs
          • Main Settings
          • Condition Time
          • Effects on Points
        • GameCondition.cs
        • GameConditionList.cs
        • Expiration Condition Handler
        • Code Examples
      • Quests
        • Quest
          • Main Settings
          • Quest Step Settings
        • Quest Steps
        • Quest Conditions
          • Create a Custom Quest Condition
            • Your Quest Condition
            • Your Quest Condition Editor
            • Your Quest Condition Drawer
          • Quest Condition Details
            • Blackboard Value Bool
            • Blackboard Value GameObject
            • Blackboard Value Number
            • Blackboard Value String
            • Final Stat Is
            • Game Condition List Contains
            • Game Item Object List Contains
            • Game Stat List Contains
          • Quest Condition Enums
        • Quest Rewards
          • Create a Custom Quest Reward
            • Your Quest Reward
            • Your Quest Reward Editor
            • Your Quest Reward Drawer
          • Quest Reward Details
            • Point Reward
            • Condition Reward
            • Quest Quest Reward
            • Item Object Reward
          • Custom Quest Reward Handler
        • GameQuest
        • GameQuestList
        • Quest Events
        • Demo Scene Quests
          • Push the Button
          • Add Money
          • Don't Get Poisoned
          • Rescue the Puppy
      • Voices
        • Voices
        • Voice.cs
        • Code Examples
      • Dictionaries
        • Dictionaries Setup
        • Dictionaries Methods
        • KeyValue Methods
        • Save and Load
        • Object Reference
      • Gametime & Timeboard
        • Timeboard
          • Timeboard Events
          • TimeboardFollower
        • Gametime
          • Pause Level
          • Time Options
          • Properties & Methods
        • TimeSpan
        • Code Examples
      • Property Code
      • Lookup Table
      • Save and Load
        • GameList & GameFile
        • Making objects saveable
        • Saving, and Loading
        • BlackboardEvents sent by Save and Load
    • Game Module "Systems"
      • Drag-and-Drop Inventory System
        • Scripts
          • PanelManager
          • OnScreenItem
          • Panel
          • BoxManager
        • Scene & Class Setup
        • Item / Object Setup
        • Item / Inventory Setup
        • Box Setup (Chests, Bags, Other Inventories)
        • Setup Your Scene
      • First Person Movement
      • Character Creation
    • Game Module Demo Projects
      • Party Based RPG
        • Title Scene
        • Character Creation Scene
        • World & Dungeon Scenes
    • Magic Time for Game Modules
  • ✨Northstar Tracking System
    • ✅Overview & Quickstart
      • ➡️Quick Start
      • 🫐Demo Scene
      • 🛠️Customizing & Overriding
        • Create a Custom Navigation Bar
        • Create a Custom Compass / Radar
        • Runtime Overrides
          • Screen & Edge Overlay
          • Navigation Bar
          • Compass / Radar
      • ☄️Tips & Code Examples
    • Northstar Documentation
      • Global Northstar Settings
      • Northstar Overlay Settings
      • Compass & Radar
        • Compass
        • Radar
      • Northstar Screen Overlay
        • Screen & Edge Overlay
        • Navigation Bar
      • Tracked Target Compass Radar
      • Tracked Target Overlay
        • Types
        • Override Values
      • Overlay Icon
      • Compass Icon
      • Distance Text
  • 🚀Projectile Factory
    • 👀Overview & Quickstart
      • ➡️Quick Start Guide
        • Create Your First Projectile
        • Add Projectile Factory & Create a Projectile Spawner
        • Use 3rd Party Integrations
        • Extending Projectile Factory
        • Making Lasers & Similar Attached Projectiles
      • 💡FAQs + Important Reminders
    • Game Modules 4 Integration
      • Projectiles with TimeMod
    • Magic Time for Projectile Factory
    • ✅3rd Party Particle Integrations [16]
      • ▶️Archanor VFX [5]
        • Sci-Fi Arsenal
        • Polygon Arsenal
        • Magic Arsenal
        • Retro Arsenal
        • Rainbow Magic
      • ▶️Gabriel Aguiar Prod [2]
        • Unique Projectiles Vol. 1
        • Unique Projectiles Vol. 2
      • ▶️HOVL Studio [4]
        • Toon Projectiles
        • Toon Projectiles 2
        • AAA Stylized Projectiles Vol. 1
        • AAA Projectiles Vol. 2
      • ▶️kripto289 [1]
        • Realistic Effects Pack 4
      • ▶️FORGE3D [1]
        • Sci-Fi Effects
      • ▶️Knife [1]
        • PRO Effects - Sci-Fi Shooter FX
      • ▶️Jean Moreno [1]
        • Cartoon FX Remastered
      • ▶️Synty Studios [1]
        • 🟡Synty Studios Particles
    • Projectile Factory Documentation
      • 🔫Projectile Spawner
        • Projectile Spawner Code
      • 🚀Projectile
        • Projectile Code
        • Projectile Data
      • ✨Spawn Behavior
        • Spawn Behavior Code
        • Spawn Behavior Modification
      • 🕊️Behaviors
        • Behavior Examples
      • ⚡Events
      • 👁️Observers, Global Observers, and Observer Objects
        • Toggle Objects At Events Observer Object
      • 👩‍💼Factory Manager
      • 🏹Trajectory
      • 🎱Object Pooling
      • 🤩Create Custom Behaviors
      • Spawn Point Manager
      • Helper Tools
        • Projectiles Quick Editor
        • Set Trail Auto Destroy to False
        • Set Layer of All Projectiles
        • Remove Colliders
      • Additional Scripts
        • Destroy or Pool Object
        • Project Force
        • Raycast Shooter + Handlers
        • Projectile Utilities
  • Additional Systems & Tools
    • 🎨Runtime Color Sampler
      • Quick Start
      • Demo Walkthrough
      • Runtime Color Sampler (Prefab & Class)
        • Sampler Sphere
        • Sampler Camera
      • Runtime Listener
      • Runtime Color Settings
      • Scripting
      • Additional Classes
    • 🙎‍♀️Portrait Avatars
      • Setup
        • Create a Portrait Avatar
        • Create a UI Portrait
      • Portrait Avatars
        • Scripting
      • Portrait3D
      • Portrait2D
      • Portrait UI
      • Avatar Camera
      • Important Considerations
    • 🎛️Audio Clip Combiner
    • 🌈Color Shifter
    • 🛠️Support Classes
      • Utilities.cs
      • InfinityExtensions.cs
  • ⌛Magic Time - Local Time Scale
    • Overview
    • ➡️Quick Start
    • 🛠️Integrations
    • 💡FAQ
    • Local Time Scale
      • Local Time Scale Scripting
    • Magic Time Manager
      • Magic Time Manager Scripting
    • Magic Time User
      • IHaveLocalTime
      • Magic Time User Scripting
      • Additional "Magic Time User" Components
    • Time Zone
  • Equipment Systems
    • Overview
    • Blend Shapes Manager
    • Blend Shapes Preset Manager
    • Prefab and Object Manager
      • Humanoid Demo & Setup
      • EquipmentObject.cs
      • Prefab Groups
      • Variables
      • Scripting Examples
    • Wardrobe Prefab Manager
  • 📽️General Tutorials
    • Quick 3rd Person Controller
  • ⚔️Legend of the Stones
    • Actors, Players, NPCs
    • Systems
      • Game State
  • External Links
  • Get them at the Asset Store
  • Connect on Discord
  • YouTube
  • Twitch
  • 🚧Work In Progress / Coming Soon
Powered by GitBook
On this page
  • Properties
  • Methods
  • Converting & Comparing

Was this helpful?

  1. Game Modules 4
  2. Module Documentation
  3. Gametime & Timeboard
  4. Gametime

Properties & Methods

v4.0

Properties

When gameTime is not specified (i.e. defaults to -1), the Now() gameTime will be used.

Day and Month have an additional bool shiftForNumbericalDisplay, which is false by default. When true, the value returned will be 1 higher, since humans don't use "0" for the first day or month.

public int GameTime => _gameTime; // Returns an int

// Return ints
public int Minute(int gameTime = -1)
public int Hour(int gameTime = -1)
public int Day(int gameTime = -1, bool shiftForNumericalDisplay = false)
public int Week(int gameTime = -1)
public int Month(int gameTime = -1, bool shiftForNumericalDisplay = false)
public int Season(int gameTime = -1)
public int Year(int gameTime = -1)

// Return strings
public string DayName(int gameTime = -1)
public string MonthName(int gameTime = -1)
public string SeasonName(int gameTime = -1)

public int DaysPerWeek
public int NumberOfMonths
public int NumberOfSeasons
public int DaysPerMonth
public int MinutesPerHour
public int HoursPerDay
public int DaysPerYear
public int DaysPerSeason // There could be different number of days per season if the year is not divisible!
public int WeeksPerYear // Any last partial week is counted!
public float DaysPerSeasonFloat
public float WeeksPerYearFloat

// In-game time
public float SecondsPerGameMinute
public float SecondsPerGameHour
public float SecondsPerGameDay
public float SecondsPerGameWeek
public float SecondsPerGameMonth
public float SecondsPerGameSeason
public float SecondsPerGameYear

// 1 in-game minute = 1 "GameMinute" -- these are the same as "MinutesPer"
public int GameTimePerHour => minutesPerHour; // minutesPerHour is the same as GameTimePerHour!
public int GameTimePerDay
public int GameTimePerWeek
public int GameTimePerMonth
public int GameTimePerSeason
public int GameTimePerYear

Methods

The Gametime Module contains many methods which perform time and date calculations, and may be quite convenient for your project.

FullDate() returns a human-readable string, and can be formatted in a variety of ways.

public string FullDate(int gameTime = -1 // -1 uses = Now()
    , bool numericalDisplay = true // Ex. 6/12/2023
    , bool includeTime = true // Ex. 6/12/2023 10:19pm
    , bool includeDayOfWeek = true // Ex. Monday June 12, 2023 10:20 pm
    , string dateSeparator = "/") // Ex 6/12/2023

These methods will get a gameTime value back.

public float Now(bool includeSubtime = true)

// Returns Now() plus or minus a gameTime value based on the read-world minutes
public float LaterRealTime(float realWorldMinutes)
public float EarlierRealTime(float realWorldMinutes)

// Returns Now() plus or minus the values in the provided TimeSpan object
public float Later(TimeSpan span)
public float Earlier(TimeSpan span)

// Returns Now() plus or minus the values provided
public float Later(float seconds = 0f, float minutes = 0f, float hours = 0f
    , float days = 0f, float weeks = 0f, float months = 0f, float seasons = 0f
    , float years = 0f)
public float Earlier(float seconds = 0f, float minutes = 0f, float hours = 0f
    , float days = 0f, float weeks = 0f, float months = 0f, float seasons = 0f
    , float years = 0f)
    
// Gets the gameTime for the start of the season in the year provided
public float SeasonGameTime(int season, int year = -1) // -1 = Current Year

These methods will manage gameTime in some way.

// Handles real-world values, converting them to in-game additions
public void AddRealWorldSeconds(float realWorldSeconds)
public void AddRealWorldMinutes(int realWorldMinutes)
public void AddRealWorldHours(int realWorldHours)

// Handles in-game values [Use negative values to subtract]
public void AddMinutes(float minutesToAdd)
public void AddHours(float hoursToAdd)
public void AddDays(float daysToAdd)
public void AddWeeks(float weeksToAdd)
public void AddMonths(float monthsToAdd)
public void AddYears(float yearsToAdd)
public void AddSeasons(float seasonsToAdd)

Converting & Comparing

Convert between "Real Seconds", GameTime, TimeSpan, and DatePart

// Real Seconds to...
public TimeSpan RealSecondsToTimeSpan(float realSeconds)
public float RealSecondsToGameTime(float realSeconds)
public float RealSecondsToDatePart(DatePart datePart, float realSeconds)

// GameTime to...
private TimeSpan GameTimeToTimeSpan(float gameTime) 
public float GameTimeToRealSeconds(float gameTime)
public float GameTimeToDatePart(DatePart datePart, float gameTime)

// TimeSpan to...
public float TimespanToGameTime(TimeSpan timeSpan)
public float TimeSpanToRealSeconds(TimeSpan timeSpan)
public float TimeSpanToDatePart(DatePart datePart, TimeSpan timeSpan)

/// DatePart to...
public float DatePartToGameTime(DatePart datePart, float value)
public float DatePartToRealSeconds(DatePart datePart, float value)
public TimeSpan DatePartToTimeSpan(DatePart datePart, float value)

We use Real Seconds for converting between real-world time and in-game gameTime, because it is the lowest common measurement, using the variable realWorldSecondsPerGameMinute

This value is the basis for all in-game time.

DatePart comparisons to gameTime

When gameTime is not provided, it defaults to Now()

// Returns the current lowest value of datePart compared to the next greatest
// denominator.
public int GetDatePart(DatePart datePart, float gameTime = -1)

// Returns the selected datePart since the last comparison DatePart
public float DatePartInto(DatePart datePart, DatePart comparison, float gameTime = -1)

// Returns the datePart until the next comparison DatePart
public float DatePartUntil(DatePart datePart, DatePart comparison, float gameTime = -1)

Examples

// Hours until the next day starts
var hoursUntilMidnight = DatePartUntil(DatePart.Hour, DatePart.Day);

// Days into the current season, for a specific gameTime
var daysIntoSeason = DatePartInto(DatePart.Day, DatePart.Season, savedGameTime);

These helper methods may be more convenient to use.

// DatePart past the last comparison DatePart
public float SecondsInto(DatePart comparison, float gameTime = -1)
public float MinutesInto(DatePart comparison, float gameTime = -1)
public float HoursInto(DatePart comparison, float gameTime = -1)
public float DaysInto(DatePart comparison, float gameTime = -1)
public float WeeksInto(DatePart comparison, float gameTime = -1)
public float MonthsInto(DatePart comparison, float gameTime = -1)
public float SeasonsInto(DatePart comparison, float gameTime = -1)

// DatePart until the next comparison DatePart
public float SecondsUntil(DatePart comparison, float gameTime = -1)
public float MinutesUntil(DatePart comparison, float gameTime = -1)
public float HoursUntil(DatePart comparison, float gameTime = -1)
public float DaysUntil(DatePart comparison, float gameTime = -1)
public float WeeksUntil(DatePart comparison, float gameTime = -1)
public float MonthsUntil(DatePart comparison, float gameTime = -1) 
public float SeasonsUntil(DatePart comparison, float gameTime = -1)

// DatePart comparisons to New Year
public float SecondsSinceNewYear(int gameTime = -1)
public float MinutesSinceNewYear(int gameTime = -1)
public float HoursSinceNewYear(int gameTime = -1)
public float DaysSinceNewYear(int gameTime = -1)
public float WeeksSinceNewYear(int gameTime = -1)
public float MonthsSinceNewYear(int gameTime = -1)

public float SecondsUntilNewYear(int gameTime = -1)
public float MinutesUntilNewYear(int gameTime = -1)
public float HoursUntilNewYear(int gameTime = -1)
public float DaysUntilNewYear(int gameTime = -1)
public float WeeksUntilNewYear(int gameTime = -1)
public float MonthsUntilNewYear(int gameTime = -1)
public float SeasonsUntilNewYear(int gameTime = -1)
PreviousTime OptionsNextTimeSpan

Last updated 1 year ago

Was this helpful?