initial main menu and dependencies

This commit is contained in:
MrTorex committed 2026-03-04 19:58:31 +03:00
1 parent 2cdb2aa43d
commit 61af80957c
834 files changed
+402699

No files matched your search

+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.");
}
}
}