init: add project

This commit is contained in:
Bragin Stepan
2026-02-18 23:02:28 +05:00
commit 4f01e66894
620 changed files with 52253 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
namespace Assets._Project.Develop.Runtime.Utilities.ConfigsManagement
{
public class ConfigsProviderService
{
private readonly Dictionary<Type, object> _configs = new();
private readonly IConfigsLoader[] _loaders;
public ConfigsProviderService(params IConfigsLoader[] loaders)
{
_loaders = loaders;
}
public IEnumerator LoadAsync()
{
_configs.Clear();
foreach (IConfigsLoader loader in _loaders)
yield return loader.LoadAsync(loadedConfigs => _configs.AddRange(loadedConfigs));
}
public T GetConfig<T>() where T : class
{
if (_configs.ContainsKey(typeof(T)) == false)
throw new InvalidOperationException($"Not found config by {typeof(T)}");
return (T)_configs[typeof(T)];
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91110ad324dd6984a996ba9e842f00d1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Assets._Project.Develop.Runtime.Utilities.ConfigsManagement
{
public interface IConfigsLoader
{
IEnumerator LoadAsync(Action<Dictionary<Type, object>> onConfigsLoaded);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3fdc549c53a2ce342b7735b0d0a1fd1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
using System;
using System.Collections;
using System.Collections.Generic;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Utilities.ConfigsManagement
{
public class ResourcesConfigsLoader : IConfigsLoader
{
private readonly ResourcesAssetsLoader _resources;
private readonly Dictionary<Type, string> _configsResourcesPaths = new (PathToResources.ScriptableObject);
public ResourcesConfigsLoader(ResourcesAssetsLoader resources)
{
_resources = resources;
}
public IEnumerator LoadAsync(Action<Dictionary<Type, object>> onConfigsLoaded)
{
Dictionary<Type, object> loadedConfigs = new();
foreach (KeyValuePair<Type, string> configResourcesPath in _configsResourcesPaths)
{
ScriptableObject config = _resources.Load<ScriptableObject>(configResourcesPath.Value);
loadedConfigs.Add(configResourcesPath.Key, config);
yield return null;
}
onConfigsLoaded?.Invoke(loadedConfigs);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a5f12d91469c594f9809cd92473593c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: