Unless your grid is 1000x1000 (don’t make a grid of 1000x1000!), you should be fine disabling all of the locations.
Even if the speed is constant, at a certain point the turn order will naturally change. For example, if unit A has a speed of 30 and unit B has a speed of 60, then unit B will get two moves for every move that unit A gets. It also sets up a situation where you can conserve turn counters… In Final Fantasy Tactics, if you skip your turn, then your turn counter is reset to roughly 1/3rd of what it would be. If you move, but don’t act, it’s 2/3rds, same with acting but not moving. This means a ranged character that doesn’t move will get more turns than a character with the same speed that acts AND moves.
The whole scheme is simple… each unit gets a float NextMove;. At the end of the unit’s turn, that NextMove is incremented by 60/speed (that 60 is arbitrary, as we’re not doing “real time” in the simulation, but I use a similar scheme for time between actions in my real time rpg). So if the unit’s speed is 60, then NextTurn will start at 1, if it’s 30, it will start at 2, etc.
Here’s the entire TurnBroker class:
TurnBroker.cs
using System;
using System.Collections.Generic;
using System.Linq;
using Attributes;
using Object = UnityEngine.Object;
namespace TurnManagement
{
public class TurnBroker
{
public static event Action<Unit> OnNextCharacterTurn;
public static IEnumerable<Unit> GetUnits()
{
return Object.FindObjectsOfType<Unit>().Where(h => !h.GetComponent<Health>().IsDead)
.OrderBy(u => u.nextTurn);
}
public static void NextTurn()
{
OnNextCharacterTurn?.Invoke(GetUnits().FirstOrDefault());
}
}
}
GetUnits is public to set up a visualization (yep, I definitely plan on showing the list of turns, and I plan on having the AI factor that list into it’s decision making process!).
When a unit finishes it’s turn, it simply calculates it’s next turn score and calls TurnBroker.NextMove(); The entire class is static, so no Singletons, no worries about finding the turn broker, no race conditions, as the TurnBroker gets it’s data as it needs it.