Danro-Jump/Assets/Scripts/Runtime/Settings/Core/ServiceSettingsActions.cs
Danil Iarosh 77186697f8 Prepare v0.1 gameplay and hardware foundation
Подробные изменения:

- Расширен основной gameplay loop: джетпак, новые платформы, оборудование, враги, прогрессия сложности и ограничения взаимодействий игрока.

- Добавлены Bootstrap-сервисы запуска приложения, защита, фокус окна, управление курсором и настройки сервисов через DI.

- Добавлена COM-интеграция с технической схемой Input System, обработкой кнопок/ADC, подсветкой и консольной диагностикой.

- Добавлен отдельный debug/logging модуль с каналами, обработчиками консоли и файловым выводом.

- Добавлены asmdef, link.xml, EditMode/PlayMode тесты и обновлена дорожная карта проекта.

Проверки:

- dotnet build .\\DanroJump.Runtime.csproj --no-restore

- dotnet build .\\DanroJump.Tests.EditMode.csproj --no-restore

- dotnet build .\\DanroJump.Tests.PlayMode.csproj --no-restore
2026-06-08 14:22:48 +03:00

127 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using Zenject;
using DanroJump.SceneFlow;
namespace DanroJump.Settings
{
/// <summary>
/// MonoBehaviour-фасад для вызова действий сервиса настроек из UI/Unity Events.
/// </summary>
public sealed class ServiceSettingsActions : MonoBehaviour
{
private IServiceSettingsService settings;
private ISceneFlowService sceneFlow;
/// <summary>
/// Получает сервис настроек через Extenject.
/// </summary>
[Inject]
public void Construct(
IServiceSettingsService injectedSettings,
[InjectOptional] ISceneFlowService injectedSceneFlow = null)
{
settings = injectedSettings;
sceneFlow = injectedSceneFlow;
}
/// <summary>
/// Вручную назначает сервис настроек, если объект используется вне DI.
/// </summary>
public void Configure(IServiceSettingsService service, ISceneFlowService injectedSceneFlow = null)
{
settings = service;
sceneFlow = injectedSceneFlow ?? sceneFlow;
}
/// <summary>
/// Сохраняет настройки.
/// </summary>
public void Save()
{
settings?.Save();
}
/// <summary>
/// Перечитывает настройки, разрешенные для изменения через внешний JSON.
/// </summary>
public void ReloadExternalChanges()
{
settings?.ReloadExternalChanges();
}
/// <summary>
/// Повторно применяет текущие значения настроек.
/// </summary>
public void ApplyAll()
{
settings?.ApplyAll();
}
/// <summary>
/// Сбрасывает все настройки к значениям по умолчанию.
/// </summary>
public void ResetAllToDefaults()
{
settings?.ResetAllToDefaults();
}
/// <summary>
/// Сбрасывает одну группу настроек к значениям по умолчанию.
/// </summary>
public void ResetGroupToDefaults(string groupName)
{
settings?.ResetGroupToDefaults(groupName);
}
/// <summary>
/// Открывает папку persistentDataPath с внешним JSON настроек.
/// </summary>
public void OpenPersistentDataFolder()
{
Application.OpenURL($"file://{Application.persistentDataPath}");
}
/// <summary>
/// Загружает сцену по имени.
/// </summary>
public void LoadScene(string sceneName)
{
var resolvedSceneFlow = GetSceneFlow();
if (!string.IsNullOrWhiteSpace(sceneName) && resolvedSceneFlow != null)
{
resolvedSceneFlow.LoadScene(sceneName);
}
}
/// <summary>
/// Возвращает приложение в главное меню.
/// </summary>
public void LoadMainMenu()
{
GetSceneFlow()?.OpenMainMenu();
}
private ISceneFlowService GetSceneFlow()
{
if (sceneFlow == null)
{
Debug.LogWarning($"{nameof(ServiceSettingsActions)} requires {nameof(ISceneFlowService)} from DI.", this);
}
return sceneFlow;
}
/// <summary>
/// Завершает приложение или останавливает Play Mode в редакторе.
/// </summary>
public void QuitApplication()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
}