This commit is contained in:
MrTorex committed 2026-02-18 20:13:09 +03:00
1 parent 0d5e6b6dec
commit c12d653cbc
647 files changed
+194585 -117

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
using Code.Input;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Code.DI
{
public class Bootstrapper : MonoBehaviour
{
[SerializeField] private InputActionAsset inputActionAsset;
private void Awake()
{
var container = new GameObject("DIContainer").AddComponent<DIContainer>();
container.Register<IInputService>(new InputService(inputActionAsset));
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 65859af4acde4a76adb00a20e8f85134
timeCreated: 1771430870
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Code.DI
{
public class DIContainer : MonoBehaviour
{
private readonly Dictionary<Type, object> _services = new();
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
public void Register<T>(T service)
{
var type = typeof(T);
if (!_services.TryAdd(type, service))
{
Debug.LogWarning($"Service {type} is already registered.");
}
}
public T Resolve<T>()
{
var type = typeof(T);
if (_services.TryGetValue(type, out var service))
{
return (T)service;
}
throw new Exception($"Service {type} not found.");
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9af57c4618e949c0a0242ed71006116f
timeCreated: 1771430880