You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by DeathPhoenix22 November 7, 2023
Hi,
I was partially looking at how I'll be able to save & load games. I've found how with 1 limitation that I could easily overcum, but feel like any project will require it if they use LocalTimer.
Long story short, you can't save a timer. There is no access to it's current "Now" value, which in fact isn't truly interesting. But, to save and load, you need to store the remaining time and instantiate a Timer with that time already added up.
Let's check with a use case:
The Player starts the construction of a building which takes 120 seconds to build.
The Application creates a LocalTimer for 120 seconds
The Player Save game after 110 seconds since the construction was started
The Application can't access the current 110 seconds elapsed time and therefor cannot save the "time" value of a LocalTimer (private)
The Player load the save
The Application load the building under construction state
The Application creates a new localTimer and cannot preset the elapsed time (could not access it at save time & can't assign it either)
The solution:
Add a Getter the "time" value of a LocalTimer (Optional)
Add a Getter the "elapsedTime" value of a LocalTimer (Mandatory) -> return now - time
Add a Constructor parameter allowing instantiation of LocalTimer at a predefined "elapsedTime" (Mandatory) -> will do time = now - elapsedTime
Add a timeProperty so LocalTimer can also be displayed easily in the UI (That would be really useful ! )
@AlmasB Do you want me to integrate this to the Engine or you prefer that I implement it only in my own game?
Thanks
The text was updated successfully, but these errors were encountered:
Discussed in #1320
Originally posted by DeathPhoenix22 November 7, 2023
Hi,
I was partially looking at how I'll be able to save & load games. I've found how with 1 limitation that I could easily overcum, but feel like any project will require it if they use LocalTimer.
Long story short, you can't save a timer. There is no access to it's current "Now" value, which in fact isn't truly interesting. But, to save and load, you need to store the remaining time and instantiate a Timer with that time already added up.
Let's check with a use case:
The solution:
@AlmasB Do you want me to integrate this to the Engine or you prefer that I implement it only in my own game?
Thanks
The text was updated successfully, but these errors were encountered: