thombruce / verse

🚀 A universe in progress
Other
8 stars 0 forks source link

Feat/UI time #47

Closed thombruce closed 1 year ago

thombruce commented 1 year ago

By submitting this pull request, you agree to follow our Code of Conduct: https://github.com/thombruce/.github/blob/main/CODE_OF_CONDUCT.md


Internal use. Do not delete.

thombruce commented 1 year ago

Issues: The value in seconds was too large for f32 and became unwieldy. Substituted for f64, but this is a band aid.

We should create a reusable date and time resource where integer values are stored and updated for the current day, month, year, etc.

The arithmetic we're doing could then be run not for every tick of the game, but instead when necessary.

For instance, if game_time.elapsed_secs hits sixty, increment minute; if minute hits sixty, increment hour; etc.

It's possible for that system to break down if... for some reason the values aren't updated on any given increment and are forced to wait for the next one. 🤔

Other notes/ideas:

Maybe f64 is okay.

The way game_time works is by ticking a stopwatch with delta time:

fn tick_game_time(time: Res<Time>, mut game_time: ResMut<GameTime>) {
    game_time.0.tick(time.delta());
}

Could we do a similar thing for datetime resources? I'm just trying to think what might be the most efficient handling of this.

thombruce commented 1 year ago

Also note, the "HE" part of the year is...

  1. Confusing
  2. Redundant

We can't assume players are familiar with the Holocene Calendar (https://en.wikipedia.org/wiki/Holocene_calendar) - I wasn't.

It will be clearer if the year component is X years from the current date. Even though 12024 HE is the same as 2024 CE/AD, it looks like it's 10 thousand years in the future.

We could keep the +10000 year value, simply dropping the "HE" part. Or else we should find some other start year. This might be a question of lore:

It could also be a question of current setting and technical needs:

Generation ships are something I think it would be fun to explore, but they are somewhat setting-breaking: Why would any of them still have occupants after we developed FTL travel easily capable of ferrying them to their destination in no time?

Maybe that suggests something about the story and timeframe we're working from... Maybe in Verse human FTL travel is in its infancy, and so there would still be those generation ships out there with occupants to visit and ferry onwards. Maybe humanity's role in the galaxy is very small, with expansion to other worlds having barely started (note: I foresee expansion being dynamic, calculable from a time value). I think I quite like that idea...

And back to talking about time and dates... This might just be me, but anything that starts with a 2 and continues 2### feels like a year, whereas for numbers greater than 3000 this isn't the case.

Setting verse roughly 500 years in the future may make sense... 2523? Though... I'm also quite keen on the idea of setting the game shortly before the fourth millennium so that it is realistic that the game might see humanity celebrate another millennium. Something more like... 2990? So if the player plays 10 in-game years, they get to ring in the new millennium across the galaxy. Would have to consider how long that takes to play, because it might be infeasible to think anyone would play a single game for more than a hundred hours (even that's ambitious). Buut...

Maybe the start date is a variable configurable from the start. Given that I intend for human expansion to be calculable from a time value, the setting could be very different given a different start date. We just have to... simulate a little history, like Dwarf Fortress does.

Sorry, sorry - way off topic for this PR.


The year value is largely arbitrary for now, while there is no lore in need of a given timeframe, but consider some value >2500 and <3000.

For comparison's sake, Elite: Dangerous takes place in the 3300s (and is persistent in real time). I don't know what background lore there is there, or how far humans have expanded/colonised in that time... but the entire galaxy is reachable.

thombruce commented 1 year ago

Interesting lore titbit from Elite: Dangerous:

Screenshot 2023-10-12 023540

I had no idea that game had generation ships too, or that so many years on... there are still some out there that haven't been interfered with, still making their way to their end destination.

My thinking was that we'd have a few, making their way from some system near to Earth to another system near to Earth... but maybe that number ("a few") is bigger than I think. Something to think about.

thombruce commented 1 year ago

Would we benefit from a datetime library like chrono? https://github.com/chronotope/chrono

This would hand off the date and time arithmetic to chrono, simplifying our own use-case.

It, I assume, supports accurate calendrical dates inclusive of leap years... which are tricky to derive on our own.

The trouble with leap years? They complicate our orbital period calculations (that's why they exist - because orbits and rotations are imprecise), but provided I get the initial starting conditions right this shouldn't be an issue.

Time zones probably feature daylight savings time... which may or may not be obsolete a few hundred years from now - they are certainly obsolete in space. Space's "time zone" will be UTC. Earth... doesn't really matter at this point in development, but later when you can touch down on the planet, it might be useful to have local time values.

What else... Alien planets will likely have their own clocks and calendrical systems, particularly if they have intelligent life. There's no reason that an alien species should have a 24 hour day and 12 month calendar. Their year values could be very different to ours too...

While this sounds like an argument against using chrono, I want to make the case that it's actually a good reason to do so:

The alternative is to model our own datetime system, which might initially be a messy implementation. In the future, when we need to adapt this to support alien dates and times... we might have a lot of code to refactor. Using chrono now would mean we'd have to write something from scratch, but that might be better than refactoring a rough implementation.

I'm not sure.

Side note: I figured this would be the case but have just checked - the ISS celebrates the new year at midnight UTC.


While this is a long way off, imagine the case that the player chooses to play as an alien character. How would the game be different? Different calendar system, different language (would we make the UI display in an alien font or is that a bit off-putting? game dialogue is probably still displayed in the player's native language, though they may be presented with different communication options depending on the style of the alien species' communication...).

Anyway, the question right now is: Given that we know we might need to implement a different system later, do we use chrono for now? Yes or no.

thombruce commented 1 year ago

Decided against use of chrono for now.

The implementation at present is crude and inefficient, running far more frequently than it needs to. We'll refactor and optimise at a later time.