Danro-Jump/Assets/Scripts/Runtime/Debugging/RuntimeDebugSceneInjector.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

61 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zenject;
namespace DanroJump.Debugging
{
/// <summary>
/// Инжектит debug-зависимости в явно помеченные сценовые компоненты.
/// </summary>
public sealed class RuntimeDebugSceneInjector : IInitializable, IDisposable
{
private readonly DiContainer container;
private readonly HashSet<EntityId> injectedEntityIds = new();
public RuntimeDebugSceneInjector(DiContainer container)
{
this.container = container;
}
public void Initialize()
{
InjectLoadedScenes();
SceneManager.sceneLoaded += OnSceneLoaded;
}
public void Dispose()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
injectedEntityIds.Clear();
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
InjectLoadedScenes();
}
private void InjectLoadedScenes()
{
var behaviours = UnityEngine.Object.FindObjectsByType<MonoBehaviour>(FindObjectsInactive.Include);
for (int index = 0; index < behaviours.Length; index++)
{
var behaviour = behaviours[index];
if (behaviour is not IDebugLogConsumer)
{
continue;
}
if (!injectedEntityIds.Add(behaviour.GetEntityId()))
{
continue;
}
container.Inject(behaviour);
}
}
}
}