Godot Version 4.2.1
Question
using Godot;
namespace Game.Data
{
public static partial class ModeTracker
{
[Signal] public delegate void ModeChangedEventHandler();
public enum Mode {None, Menu, Play, Pause, Selection};
private static Mode currentMode = Mode.Menu;
}
}
I want to create a class that contains the current game mode. I thought about creating a static class, but wondered at what point. I assume that when I try to call from another class, for example to bind the ModeChanged signal to the player, then this will definitely happen, because the static class will be created before the player class is created. I don’t quite understand how this works and I noticed that I can’t inherit from a class to get a static class. What do you think is best?
1. Create a non-static class and inherit from RefCounted and create a new instance when the game starts.
2. Create a static class like in the example above.
3. Create a non-static class and inherit from RefCounted and instead of creating an instance, add it to Autoload