using Godot;
using GodotSteam;

public partial class SteamworksHandler : Node
{
	[Export] private bool enableSteam = false;
	private bool isSteamInitialized = false;

	public override void _Ready()
	{
		if (!enableSteam) return;

		SteamInitExStatus status = Steam.SteamInitEx(false).Status;
		if (status != 0)
		{
			GD.Print("Steam not initialized!");
			return;
		}

		GD.Print("Steam initialized!");
		GD.Print("User: " + Steam.GetPersonaName());
		isSteamInitialized = true;
	}

	public override void _Process(double delta)
	{
		if (!isSteamInitialized) return;

		Steam.RunCallbacks();
	}

	public override void _ExitTree()
	{
		if (!isSteamInitialized) return;

		Steam.SteamShutdown();
	}
}
