- ConsoleManager: lazy GameManager/AchievementManager via Instance (fixes NullRef on console commands) - AchievementManager, GhostManager: add static Instance property - GhostEventHandler: use GhostManager.Instance, add _ExitTree unsubscription - SpeedRunManager: remove unused IsVisible guard; TimeUpdated now emits when running - SpeedRunHud: use SpeedRunManager.Instance, remove dead IsVisible binding - SaveDataDto: moved to scripts/State/SaveDataDto.cs - GameManager.AddCoins: XML doc clarifying permanent vs session coins
131 lines
3.1 KiB
C#
131 lines
3.1 KiB
C#
using Godot;
|
|
using Mr.BrickAdventures;
|
|
using Mr.BrickAdventures.scripts.components;
|
|
|
|
namespace Mr.BrickAdventures.Autoloads;
|
|
|
|
public partial class ConsoleManager : Node
|
|
{
|
|
private GameManager GameManager => GameManager.Instance;
|
|
private AchievementManager AchievementManager => AchievementManager.Instance;
|
|
private SkillManager _skillManager;
|
|
private SkillUnlockerComponent _skillUnlockerComponent;
|
|
|
|
public override void _Ready()
|
|
{
|
|
_skillManager = SkillManager.Instance;
|
|
}
|
|
|
|
private void AddCoinsCommand(int amount)
|
|
{
|
|
GameManager.AddCoins(amount);
|
|
}
|
|
|
|
private void SetCoinsCommand(int amount)
|
|
{
|
|
GameManager.SetCoins(amount);
|
|
}
|
|
|
|
private void SetLivesCommand(int amount)
|
|
{
|
|
GameManager.SetLives(amount);
|
|
}
|
|
|
|
private void AddLivesCommand(int amount)
|
|
{
|
|
GameManager.AddLives(amount);
|
|
}
|
|
|
|
private void SetHealthCommand(float amount)
|
|
{
|
|
var playerHealthComponent = GameManager.Player.GetNode<HealthComponent>("HealthComponent");
|
|
if (playerHealthComponent != null)
|
|
{
|
|
playerHealthComponent.Health = amount;
|
|
}
|
|
}
|
|
|
|
private void ResetSessionCommand()
|
|
{
|
|
GameManager.ResetCurrentSessionState();
|
|
}
|
|
|
|
private void UnlockSkillCommand(string skillName)
|
|
{
|
|
if (!GetSkillManagement()) return;
|
|
|
|
var skill = _skillManager.GetSkillByName(skillName);
|
|
if (skill == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GameManager.UnlockSkill(skill);
|
|
_skillManager.ActivateSkill(skill);
|
|
_skillUnlockerComponent.EmitSignal(SkillUnlockerComponent.SignalName.SkillUnlocked, skill);
|
|
}
|
|
|
|
private bool GetSkillManagement()
|
|
{
|
|
var player = GameManager.Player;
|
|
if (player == null || !IsInstanceValid(player))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_skillUnlockerComponent ??= player.GetNode<SkillUnlockerComponent>("SkillUnlockerComponent");
|
|
|
|
if (_skillManager != null && _skillUnlockerComponent != null) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
private void UnlockAllSkillsCommand()
|
|
{
|
|
if (!GetSkillManagement()) return;
|
|
|
|
_skillUnlockerComponent.UnlockAllSkills();
|
|
}
|
|
|
|
private void RemoveSkillCommand(string skillName)
|
|
{
|
|
if (!GetSkillManagement()) return;
|
|
|
|
var skill = _skillManager.GetSkillByName(skillName);
|
|
if (skill == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GameManager.RemoveSkill(skill.Name);
|
|
_skillManager.DeactivateSkill(skill);
|
|
}
|
|
|
|
private void RemoveAllSkillsCommand()
|
|
{
|
|
if (!GetSkillManagement()) return;
|
|
|
|
foreach (var skill in _skillManager.AvailableSkills)
|
|
{
|
|
GameManager.RemoveSkill(skill.Name);
|
|
_skillManager.DeactivateSkill(skill);
|
|
}
|
|
}
|
|
|
|
private void GoToNextLevelCommand()
|
|
{
|
|
GameManager.OnLevelComplete();
|
|
}
|
|
|
|
private void UnlockAchievementCommand(string achievementId)
|
|
{
|
|
AchievementManager.UnlockAchievement(achievementId);
|
|
}
|
|
|
|
private void ResetAchievementCommand(string achievementId)
|
|
{
|
|
AchievementManager.LockAchievement(achievementId);
|
|
}
|
|
|
|
} |