Fixed complex time travel edge cases with player-follow logic.

Updates

Simplified follow states using only follows/followedBy components - no other component states or differences exist between different player entities, other than current color/time state. Head entities can be easily determined by checking if the “follows” component does not exist.

Added cycle detection algorithms, added cycle prevention checks, and fixed multiple infinite loop bugs.

Fixed position and direction wrapping bugs by wrapping computed positions and directions. Added a new wrapped direction method to the spatial entity map.

Wrote a two-pass algorithm for the “follow” system. The first pass prunes follow connections between player entities, when they become invalid - either detached from the world, or have impossible positions. Entities that follow must be exactly behind, as well as having a direction that is forward, left, or right. The second pass attempts to follow followable entities that are not currently following, using the opposite conditions used to prune. This two-pass approach works cleanly with the four directions of time travel/undo, and allows practically any player creation/destruction states throughout the timeline to stay valid and make intuitive sense to the player.

Next

Implement color and time state merging updates on merged player entity groups. Use simple OR logic that is consistent with the rest of the game. Focus on fixing all remaining bugs and issues. Potentially may start working on a way to solve the camera issue - caused by the fact that there is more than one player entity now.