Working On Schedules


Programming


Hello Universe!

Was working on the scheduling system

Working on popping in the night sky and the planets into the game. Experimented with some blur effects that in the end I did not like. It gave a sense of scale but artistically looked wrong. In the end I went with an alpha transition from horizon to sky to create a sense of space between the game and the background. It's far from finished, but the direction is there. Perhaps a choice of a different colour for the fade.

Interestingly enough, the planets and even the night sky both use the same scheduling system as the npcs! Which is super cool. So, example, the planets at at 6pm: set position, lerp position, go for 4 in game hours, destroy. Or the night sky which has a single fade node in it's routine.

Then this is where the bugs started happening.

When tackling how the schedules deal with different days(I.E loading another schedule file), the crashes started happening. I went for the approach of: load the new routine npcs first, then delete the routine npcs that are not a part of that list. The issue was with the deletion part. See, I'm using my own "shared_ptr" class so to speak. It takes on the observer model, where nobody but the pool owns the data. Everyone else just observes the data. I did it this way to avoid cache misses when iterating the pool(by using the move operator), and avoid the instance of everyone owning the piece of data and deleting when the last instance of "shared_ptr" is gone, or weird unique_ptr, weak_ptr stuff. Instead, it's when the last observer is gone, or when the program calls delete on the data, nullifying all observers.

The problem was there, in the move operator fancy cache thing I was doing, resetting entity parents. It was a whole thing, took days T_T. The short story is that entities were being swapped and then observers, which made the parents point to a null child(But not the one I wanted to delete). But, in the end I decided to eradicate cache coherence and move operators, and used a freeslot vector approach. This is where if a pool slot dies, it stays in it's spot, and when the next creation happens it overwrites that free slot. This fixed everything. PHEW! It will do for now...

Here is what I have so far.

It is sped up by 50x and during this night transition there is a LoadSchedule() happening that checks entities reloads routines and deletes npcs(I.E planets and sky)

Leave a comment

Log in with itch.io to leave a comment.