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,3 @@
fileFormatVersion: 2
guid: 75a00006b1b04f288b29fe2cd77e9b5b
timeCreated: 1770310913

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 09469fa4089d4337a6f15c97e8de91d1
timeCreated: 1770310930

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 42a7ac9b4d0546bb953736e362f57d18
timeCreated: 1770317233

View File

@@ -0,0 +1,10 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Levels
{
[CreateAssetMenu(menuName = "Configs/Gameplay/Levels/NewLevelConfig", fileName = "LevelConfig")]
public class LevelConfigSO : ScriptableObject
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 92b0407d77114e269e933958033e5582
timeCreated: 1771426563

View File

@@ -0,0 +1,20 @@
using System.Collections.Generic;
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Gameplay.Levels
{
[CreateAssetMenu(menuName = "Configs/Gameplay/Levels/LevelsListConfig", fileName = "LevelsListConfig")]
public class LevelsListConfigSO : ScriptableObject
{
[SerializeField] private List<LevelConfigSO> _levels;
public IReadOnlyList<LevelConfigSO> Levels => _levels;
public LevelConfigSO GetBy(int levelNumber)
{
int levelIndex = levelNumber - 1;
return _levels[levelIndex];
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6d98a268b1d14e748199df00442f0142
timeCreated: 1770317333

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0699768783a644f9842f4fca57c22176
timeCreated: 1770822727

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using _Project.Develop.Runtime.Logic.Meta.Features.Wallet;
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Meta
{
[CreateAssetMenu(menuName = "Configs/Meta/Wallet/NewCurrencyIconsConfig", fileName = "CurrencyIconsConfig")]
public class CurrencyIconsConfigSO : ScriptableObject
{
[SerializeField] private List<CurrencyConfig> _configs;
public Sprite GetSpriteFor(CurrencyTypes currencyType)
=> _configs.First(config => config.Type == currencyType).Sprite;
[Serializable]
private class CurrencyConfig
{
[field: SerializeField] public CurrencyTypes Type { get; private set; }
[field: SerializeField] public Sprite Sprite { get; private set; }
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2878946a8cb24cbcb7234ea84d8630c8
timeCreated: 1770822736

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using _Project.Develop.Runtime.Logic.Meta.Features.Wallet;
using UnityEngine;
namespace _Project.Develop.Runtime.Configs.Meta
{
[CreateAssetMenu(menuName = "Configs/Meta/Wallet/NewStartWalletConfig", fileName = "StartWalletConfig")]
public class StartWalletConfigSO : ScriptableObject
{
[SerializeField] private List<CurrencyConfig> _values;
public int GetValueFor(CurrencyTypes currencyType)
=> _values.First(config => config.Type == currencyType).Value;
[Serializable]
private class CurrencyConfig
{
[field: SerializeField] public CurrencyTypes Type { get; private set; }
[field: SerializeField] public int Value { get; private set; }
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 49fdd27f59754c9b9eea8145306d4d61
timeCreated: 1770822736

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 815fb587aee940d8ae4927577f5dfee4
timeCreated: 1770311166

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using Assets._Project.Develop.Runtime.Utilities.DataManagement;
namespace Assets._Project.Develop.Runtime.Utilities.SceneManagement
{
public static class MapDataKeys
{
public static readonly IReadOnlyDictionary<Type, string> Dictionary = new Dictionary<Type, string>()
{
// { typeof(GameData), "GameData" },
{ typeof(PlayerData), "PlayerData" },
// { typeof(SettingsData), "SettingsData" }
};
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5b67d847e9954f08afe7f7b88639938a
timeCreated: 1770822535

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using _Project.Develop.Runtime.Configs.Meta;
using _Project.Develop.Runtime.UI.Common;
using _Project.Develop.Runtime.UI.Features.LevelsMenuPopup;
using _Project.Develop.Runtime.UI.Screens.Gameplay;
using _Project.Develop.Runtime.UI.Screens.MainMenu;
namespace Assets._Project.Develop.Runtime.Utilities.SceneManagement
{
public static class PathToResources
{
public static IReadOnlyDictionary<Type, string> ScriptableObject => _scriptableObject;
public static IReadOnlyDictionary<Type, string> UIPaths => _uiPaths;
public static class Util
{
public const string Coroutine = "Utilities/CoroutinesPerformer";
}
public static class UI
{
public static class LoadingScreen
{
public const string Standard = "Utilities/StandardLoadingScreen";
}
public static class Screens
{
public const string MainMenu = "UI/Screens/MainMenu/MainMenuUIRoot";
public const string Gameplay = "UI/Screens/Gameplay/GameplayUIRoot";
}
}
public static class Entity
{
public const string TestEntity = "Entities/TestEntity";
}
private static readonly Dictionary<Type, string> _scriptableObject = new()
{
{ typeof(StartWalletConfigSO), "Configs/Meta/Wallet/StartWalletConfig" },
{ typeof(CurrencyIconsConfigSO), "Configs/Meta/Wallet/CurrencyIconsConfig" },
};
private static readonly Dictionary<Type, string> _uiPaths = new()
{
{typeof(MainMenuScreenView), "UI/Screens/MainMenu/MainMenuScreenView" },
{typeof(GameplayScreenView), "UI/Screens/Gameplay/GameplayScreenView" },
{typeof(IconTextView), "UI/Common/IconTextView" },
{typeof(LevelTileView), "UI/LevelsMenuPopup/LevelTile" },
{typeof(LevelsMenuPopupView), "UI/LevelsMenuPopup/LevelsMenuPopup" },
};
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f17768504c02414396ce50a5b7abb788
timeCreated: 1770311252

View File

@@ -0,0 +1,10 @@
namespace Assets._Project.Develop.Runtime.Utilities.SceneManagement
{
public static class Scenes
{
public const string GameEntryPoint = "GameEntryPoint";
public const string Empty = "Empty";
public const string MainMenu = "MainMenu";
public const string Gameplay = "Gameplay";
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7c4e472e63f246f44b4b9ecf77003034
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e4eaab4c72c3874d9d069afed49278e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
namespace Assets._Project.Develop.Runtime.Infrastructure.DI
{
public class DIContainer
{
private readonly Dictionary<Type, Registration> _container = new();
private readonly List<Type> _requests = new();
private readonly DIContainer _parent;
public DIContainer() { }
public DIContainer(DIContainer parent) => _parent = parent;
public IRegistrationOptions RegisterAsSingle<T>(Func<DIContainer, T> creator)
{
if (IsAlreadyRegister<T>())
throw new InvalidOperationException($"{typeof(T)} already register");
Registration registration = new Registration(container => creator.Invoke(container));
_container.Add(typeof(T), registration);
return registration;
}
public bool IsAlreadyRegister<T>()
{
if (_container.ContainsKey(typeof(T)))
return true;
if (_parent != null)
return _parent.IsAlreadyRegister<T>();
return false;
}
public T Resolve<T>()
{
if (_requests.Contains(typeof(T)))
throw new InvalidOperationException($"Cycle resolve for {typeof(T)}");
_requests.Add(typeof(T));
try
{
if (_container.TryGetValue(typeof(T), out Registration registration))
return (T)registration.CreateInstanceFrom(this);
if (_parent != null)
return _parent.Resolve<T>();
}
finally
{
_requests.Remove(typeof(T));
}
throw new InvalidOperationException($"Registration for {typeof(T)} not exists");
}
public void Initialize()
{
foreach (Registration registration in _container.Values)
{
if (registration.IsNonLazy)
registration.CreateInstanceFrom(this);
registration.OnInitialize();
}
}
public void Dispose()
{
foreach (Registration registration in _container.Values)
registration.OnDispose();
}
}
}

View File

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

View File

@@ -0,0 +1,7 @@
namespace Assets._Project.Develop.Runtime.Infrastructure.DI
{
public interface IInitializable
{
void Initialize();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d11727eaee46452e981b458b50cf78ff
timeCreated: 1770823156

View File

@@ -0,0 +1,7 @@
namespace Assets._Project.Develop.Runtime.Infrastructure.DI
{
public interface IRegistrationOptions
{
void NonLazy();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b9015cc75cdb4bb4b853d2da12436925
timeCreated: 1770823170

View File

@@ -0,0 +1,43 @@
using System;
namespace Assets._Project.Develop.Runtime.Infrastructure.DI
{
public class Registration : IRegistrationOptions
{
private Func<DIContainer, object> _creator;
private object _cachedInstance;
public bool IsNonLazy { get; private set; }
public Registration(Func<DIContainer, object> creator) => _creator = creator;
public object CreateInstanceFrom(DIContainer container)
{
if (_cachedInstance != null)
return _cachedInstance;
if (_creator == null)
throw new InvalidOperationException("Not has instance or creator");
_cachedInstance = _creator.Invoke(container);
return _cachedInstance;
}
public void OnInitialize()
{
if (_cachedInstance != null)
if (_cachedInstance is IInitializable initializable)
initializable.Initialize();
}
public void OnDispose()
{
if (_cachedInstance != null)
if (_cachedInstance is IDisposable disposable)
disposable.Dispose();
}
public void NonLazy() => IsNonLazy = true;
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b3ad35e69ad17294cab44a1eca18420f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
using Assets._Project.Develop.Runtime.Utilities.CoroutinesManagement;
using Assets._Project.Develop.Runtime.Utilities.LoadingScreen;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
using System.Collections;
using _Project.Develop.Runtime.Utilities.DataManagement;
using Assets._Project.Develop.Runtime.Gameplay.Infrastructure;
using Assets._Project.Develop.Runtime.Utilities.DataManagement.DataProviders;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Infrastructure.EntryPoint
{
public class GameEntryPoint : MonoBehaviour
{
private void Awake()
{
SetupAppSettings();
DIContainer projectContainer = new();
ProjectContextRegistrations.Process(projectContainer);
projectContainer.Initialize();
projectContainer.Resolve<ICoroutinesPerformer>().StartPerform(Initialize(projectContainer));
}
private void SetupAppSettings()
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 60;
}
private IEnumerator Initialize(DIContainer container)
{
ILoadingScreen loadingScreen = container.Resolve<ILoadingScreen>();
SceneSwitcherService sceneSwitcherService = container.Resolve<SceneSwitcherService>();
PlayerDataProvider playerDataProvider = container.Resolve<PlayerDataProvider>();
loadingScreen.Show();
yield return container.Resolve<ConfigsProviderService>().LoadAsync();
yield return DataUtils.LoadProviderAsync(playerDataProvider);
// yield return DataUtils.LoadProviderAsync(SettingsDataProvider);
yield return new WaitForSeconds(0.5f);
loadingScreen.Hide();
yield return sceneSwitcherService.ProcessSwitchTo(Scenes.Gameplay, new GameplayInputArgs(1));
// yield return sceneSwitcherService.ProcessSwitchTo(Scenes.MainMenu);
}
}
}

View File

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

View File

@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using _Project.Develop.Runtime.Logic.Meta.Features.Wallet;
using _Project.Develop.Runtime.UI;
using _Project.Develop.Runtime.UI.Core;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Meta.Features.Wallet;
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
using Assets._Project.Develop.Runtime.Utilities.CoroutinesManagement;
using Assets._Project.Develop.Runtime.Utilities.DataManagement;
using Assets._Project.Develop.Runtime.Utilities.DataManagement.DataProviders;
using Assets._Project.Develop.Runtime.Utilities.LoadingScreen;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
using Object = UnityEngine.Object;
namespace Assets._Project.Develop.Runtime.Infrastructure.EntryPoint
{
public class ProjectContextRegistrations
{
public static void Process(DIContainer container)
{
container.RegisterAsSingle<ICoroutinesPerformer>(CreateCoroutinesPerformer);
container.RegisterAsSingle(CreateConfigsProviderService);
container.RegisterAsSingle(CreateResourcesAssetsLoader);
container.RegisterAsSingle(CreateSceneLoaderService);
container.RegisterAsSingle(CreateSceneSwitcherService);
container.RegisterAsSingle<IPlayerInputService>(CreateDesktopPlayerInputService);
container.RegisterAsSingle(CreateSaveLoadFactory);
container.RegisterAsSingle<ISaveLoadService>(CreateSaveLoadService);
container.RegisterAsSingle(CreatePlayerDataProvider);
container.RegisterAsSingle(CreateWalletService).NonLazy();
container.RegisterAsSingle(CreateProjectPresentersFactory);
container.RegisterAsSingle(CreateViewsFactory);
container.RegisterAsSingle<ILoadingScreen>(CreateLoadingScreen);
}
private static ConfigsProviderService CreateConfigsProviderService(DIContainer c)
{
ResourcesAssetsLoader resourcesAssetsLoader = c.Resolve<ResourcesAssetsLoader>();
ResourcesConfigsLoader resourcesConfigsLoader = new(resourcesAssetsLoader);
return new ConfigsProviderService(resourcesConfigsLoader);
}
private static SceneSwitcherService CreateSceneSwitcherService(DIContainer c)
=> new(
c.Resolve<SceneLoaderService>(),
c.Resolve<ILoadingScreen>(),
c);
private static SceneLoaderService CreateSceneLoaderService(DIContainer c)
=> new();
private static ResourcesAssetsLoader CreateResourcesAssetsLoader(DIContainer c)
=> new();
private static DesktopPlayerInputService CreateDesktopPlayerInputService(DIContainer c)
=> new();
private static SaveLoadFactory CreateSaveLoadFactory(DIContainer c)
=> new();
private static PlayerDataProvider CreatePlayerDataProvider(DIContainer c)
=> new(c.Resolve<ISaveLoadService>(), c.Resolve<ConfigsProviderService>());
private static ProjectPresentersFactory CreateProjectPresentersFactory(DIContainer c)
=> new(c);
private static ViewsFactory CreateViewsFactory(DIContainer c)
=> new(c.Resolve<ResourcesAssetsLoader>());
private static SaveLoadService CreateSaveLoadService(DIContainer c)
=> c.Resolve<SaveLoadFactory>().CreateDefaultSaveLoad();
private static CoroutinesPerformer CreateCoroutinesPerformer(DIContainer c)
{
ResourcesAssetsLoader resourcesAssetsLoader = c.Resolve<ResourcesAssetsLoader>();
CoroutinesPerformer coroutinesPerformerPrefab = resourcesAssetsLoader
.Load<CoroutinesPerformer>(PathToResources.Util.Coroutine);
return Object.Instantiate(coroutinesPerformerPrefab);
}
private static StandardLoadingScreen CreateLoadingScreen(DIContainer c)
{
ResourcesAssetsLoader resourcesAssetsLoader = c.Resolve<ResourcesAssetsLoader>();
StandardLoadingScreen standardLoadingScreenPrefab = resourcesAssetsLoader
.Load<StandardLoadingScreen>(PathToResources.UI.LoadingScreen.Standard);
return Object.Instantiate(standardLoadingScreenPrefab);
}
private static WalletService CreateWalletService(DIContainer c)
{
Dictionary<CurrencyTypes, ReactiveVariable<int>> currencies = new();
foreach (CurrencyTypes currencyType in Enum.GetValues(typeof(CurrencyTypes)))
currencies[currencyType] = new ReactiveVariable<int>();
return new WalletService(currencies, c.Resolve<PlayerDataProvider>());
}
}
}

View File

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

View File

@@ -0,0 +1,16 @@
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
using System.Collections;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Infrastructure
{
public abstract class SceneBootstrap : MonoBehaviour
{
public abstract void ProcessRegistrations(DIContainer container, IInputSceneArgs sceneArgs = null);
public abstract IEnumerator Initialize();
public abstract void Run();
}
}

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d6588f528c544e14b6eaeee568a976ec
timeCreated: 1770306321

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fae46e531ec7787489113ce181c37e8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8729b2af024848039cd2435e34826f40
timeCreated: 1771427180

View File

@@ -0,0 +1,13 @@
using _Project.Develop.Runtime.Entities;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Gameplay.Common
{
public class CharacterControllerEntityRegistrator : MonoEntityRegistrator
{
public override void Register(Entity entity)
{
entity.AddCharacterController(GetComponent<CharacterController>());
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 901d0931c1074853a656db4b4364f490
timeCreated: 1771433328

View File

@@ -0,0 +1,11 @@
using _Project.Develop.Runtime.Entities;
using UnityEngine;
using UnityEngine.AI;
namespace Assets._Project.Develop.Runtime.Gameplay.Common
{
public class RigidbodyComponent : IEntityComponent { public Rigidbody Value; }
public class TransformComponent : IEntityComponent { public Transform Value; }
public class CharacterControllerComponent : IEntityComponent { public CharacterController Value; }
public class NavMeshAgentComponent : IEntityComponent { public NavMeshAgent Value; }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29b78ec58e4a493fbc73c343aa2e9144
timeCreated: 1771427186

View File

@@ -0,0 +1,13 @@
using _Project.Develop.Runtime.Entities;
using UnityEngine.AI;
namespace Assets._Project.Develop.Runtime.Gameplay.Common
{
public class NavMeshAgentEntityRegistrator : MonoEntityRegistrator
{
public override void Register(Entity entity)
{
entity.AddNavMeshAgent(GetComponent<NavMeshAgent>());
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8fec398824640aba90f8183ba2b5985
timeCreated: 1771435813

View File

@@ -0,0 +1,13 @@
using _Project.Develop.Runtime.Entities;
using UnityEngine;
namespace Assets._Project.Develop.Runtime.Gameplay.Common
{
public class RigidbodyEntityRegistrator : MonoEntityRegistrator
{
public override void Register(Entity entity)
{
entity.AddRigidbody(GetComponent<Rigidbody>());
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b7fdeece4c60497ea61a1006e47bfbc5
timeCreated: 1771427186

View File

@@ -0,0 +1,12 @@
using _Project.Develop.Runtime.Entities;
namespace Assets._Project.Develop.Runtime.Gameplay.Common
{
public class TransformEntityRegistrator : MonoEntityRegistrator
{
public override void Register(Entity entity)
{
entity.AddTransform(transform);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b3d77209b50f4ecf9185ae250a76b909
timeCreated: 1771433629

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2c87b54b768645cda0de4e1f0e97ed51
timeCreated: 1771425395

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using UnityEngine;
namespace _Project.Develop.Runtime.Entities
{
public class CollidersRegistryService
{
private readonly Dictionary<Collider, Entity> _colliderToEntity = new();
public void Register(Collider collider, Entity entity)
{
_colliderToEntity.Add(collider, entity);
}
public void Unregister(Collider collider)
{
_colliderToEntity.Remove(collider);
}
public Entity GetBy(Collider collider)
{
if (_colliderToEntity.TryGetValue(collider, out Entity entity))
return entity;
return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e43e968a40dc46699c23f272909cf9cb
timeCreated: 1771425427

View File

@@ -0,0 +1,50 @@
using _Project.Develop.Runtime.Logic.Gameplay.Features.Movement;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Entities
{
public class EntitiesFactory
{
private readonly EntitiesLifeContext _entitiesLifeContext;
private readonly MonoEntitiesFactory _monoEntitiesFactory;
private readonly IPlayerInputService _playerInput;
public EntitiesFactory(DIContainer container)
{
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
_monoEntitiesFactory = container.Resolve<MonoEntitiesFactory>();
_playerInput = container.Resolve<IPlayerInputService>();
}
public Entity CreateTestEntity(Vector3 position)
{
Entity entity = CreateEmpty();
_monoEntitiesFactory.Create(entity, position, PathToResources.Entity.TestEntity);
entity
.AddMoveDirection()
.AddRotateDirection()
.AddMoveSpeed(new ReactiveVariable<float>(10))
.AddRotationSpeed(new ReactiveVariable<float>(800));
entity
.AddSystem(new CharacterControllerMovementSystem())
.AddSystem(new TransformRotationSystem())
// .AddSystem(new RigidbodyMovementSystem())
// .AddSystem(new RigidbodyRotationSystem())
.AddSystem(new MoveDirectionByInputSystem(_playerInput))
.AddSystem(new RotateDirectionByInputSystem(_playerInput));
_entitiesLifeContext.Add(entity);
return entity;
}
private Entity CreateEmpty() => new();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: af347dbf800d4edfadf180cf91c44b1a
timeCreated: 1771427064

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
namespace _Project.Develop.Runtime.Entities
{
public class EntitiesLifeContext : IDisposable
{
public event Action<Entity> Added;
public event Action<Entity> Released;
private readonly List<Entity> _entities = new();
private readonly List<Entity> _releaseRequests = new();
public IReadOnlyList<Entity> Entities => _entities;
public void Add(Entity entity)
{
_entities.Add(entity);
entity.Initialize();
Added?.Invoke(entity);
}
public void Update(float deltaTime)
{
for (int i = 0; i < _entities.Count; i++)
_entities[i].OnUpdate(deltaTime);
foreach (Entity entity in _releaseRequests)
{
_entities.Remove(entity);
entity.Dispose();
Released?.Invoke(entity);
}
_releaseRequests.Clear();
}
public void Release(Entity entity)
{
_releaseRequests.Add(entity);
}
public void Dispose()
{
foreach (Entity entity in _entities)
entity.Dispose();
_entities.Clear();
_releaseRequests.Clear();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6cee7e44950c49d180ae94ab120fad37
timeCreated: 1771425427

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
namespace _Project.Develop.Runtime.Entities
{
public partial class Entity : IDisposable
{
public event Action<Entity> Initialized;
private readonly Dictionary<Type, IEntityComponent> _components = new();
private readonly List<IEntitySystem> _systems = new();
private readonly List<IInitializableSystem> _initializables = new();
private readonly List<IUpdatableSystem> _updatables = new();
private readonly List<IDisposableSystem> _disposables = new();
private bool _isInit;
public bool IsInit => _isInit;
public void Initialize()
{
foreach (IInitializableSystem initializable in _initializables)
initializable.OnInit(this);
_isInit = true;
Initialized?.Invoke(this);
}
public void OnUpdate(float deltaTime)
{
if (_isInit == false)
return;
foreach (IUpdatableSystem updatable in _updatables)
updatable.OnUpdate(deltaTime);
}
public void Dispose()
{
foreach (IDisposableSystem disposable in _disposables)
disposable.OnDispose();
_isInit = false;
}
public Entity AddComponent<TComponent>(TComponent component) where TComponent : class, IEntityComponent
{
_components.Add(typeof(TComponent), component);
return this;
}
public bool HasComponent<TComponent>() where TComponent : class, IEntityComponent
{
return _components.ContainsKey(typeof(TComponent));
}
public bool TryGetComponent<TComponent>(out TComponent component) where TComponent : class, IEntityComponent
{
if(_components.TryGetValue(typeof(TComponent), out IEntityComponent findedObject))
{
component = (TComponent)findedObject;
return true;
}
component = null;
return false;
}
public TComponent GetComponent<TComponent>() where TComponent : class, IEntityComponent
{
if (TryGetComponent(out TComponent component) == false)
throw new ArgumentException($"Entity not exist {typeof(TComponent)}");
return component;
}
public Entity AddSystem(IEntitySystem system)
{
if (_systems.Contains(system))
throw new ArgumentException(system.GetType().ToString());
_systems.Add(system);
if (system is IInitializableSystem initializable)
{
_initializables.Add(initializable);
if (_isInit)
initializable.OnInit(this);
}
if (system is IUpdatableSystem updatable)
_updatables.Add(updatable);
if (system is IDisposableSystem disposable)
_disposables.Add(disposable);
return this;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9cae313f27754e89bf5ad980839b9e41
timeCreated: 1771425427

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 658341c858324417b69890cb508b580b
timeCreated: 1771428293

View File

@@ -0,0 +1,202 @@
namespace _Project.Develop.Runtime.Entities
{
public partial class Entity
{
public Assets._Project.Develop.Runtime.Gameplay.Common.RigidbodyComponent RigidbodyC => GetComponent<Assets._Project.Develop.Runtime.Gameplay.Common.RigidbodyComponent>();
public UnityEngine.Rigidbody Rigidbody => RigidbodyC.Value;
public bool TryGetRigidbody(out UnityEngine.Rigidbody value)
{
bool result = TryGetComponent(out Assets._Project.Develop.Runtime.Gameplay.Common.RigidbodyComponent component);
if(result)
value = component.Value;
else
value = default(UnityEngine.Rigidbody);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddRigidbody(UnityEngine.Rigidbody value)
{
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.RigidbodyComponent() {Value = value});
}
public Assets._Project.Develop.Runtime.Gameplay.Common.TransformComponent TransformC => GetComponent<Assets._Project.Develop.Runtime.Gameplay.Common.TransformComponent>();
public UnityEngine.Transform Transform => TransformC.Value;
public bool TryGetTransform(out UnityEngine.Transform value)
{
bool result = TryGetComponent(out Assets._Project.Develop.Runtime.Gameplay.Common.TransformComponent component);
if(result)
value = component.Value;
else
value = default(UnityEngine.Transform);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddTransform(UnityEngine.Transform value)
{
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.TransformComponent() {Value = value});
}
public Assets._Project.Develop.Runtime.Gameplay.Common.CharacterControllerComponent CharacterControllerC => GetComponent<Assets._Project.Develop.Runtime.Gameplay.Common.CharacterControllerComponent>();
public UnityEngine.CharacterController CharacterController => CharacterControllerC.Value;
public bool TryGetCharacterController(out UnityEngine.CharacterController value)
{
bool result = TryGetComponent(out Assets._Project.Develop.Runtime.Gameplay.Common.CharacterControllerComponent component);
if(result)
value = component.Value;
else
value = default(UnityEngine.CharacterController);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddCharacterController(UnityEngine.CharacterController value)
{
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.CharacterControllerComponent() {Value = value});
}
public Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent NavMeshAgentC => GetComponent<Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent>();
public UnityEngine.AI.NavMeshAgent NavMeshAgent => NavMeshAgentC.Value;
public bool TryGetNavMeshAgent(out UnityEngine.AI.NavMeshAgent value)
{
bool result = TryGetComponent(out Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent component);
if(result)
value = component.Value;
else
value = default(UnityEngine.AI.NavMeshAgent);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddNavMeshAgent(UnityEngine.AI.NavMeshAgent value)
{
return AddComponent(new Assets._Project.Develop.Runtime.Gameplay.Common.NavMeshAgentComponent() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection MoveDirectionC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> MoveDirection => MoveDirectionC.Value;
public bool TryGetMoveDirection(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddMoveDirection()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3>() });
}
public _Project.Develop.Runtime.Entities.Entity AddMoveDirection(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveDirection() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed MoveSpeedC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> MoveSpeed => MoveSpeedC.Value;
public bool TryGetMoveSpeed(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddMoveSpeed()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddMoveSpeed(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.MoveSpeed() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection RotateDirectionC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> RotateDirection => RotateDirectionC.Value;
public bool TryGetRotateDirection(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddRotateDirection()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3>() });
}
public _Project.Develop.Runtime.Entities.Entity AddRotateDirection(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<UnityEngine.Vector3> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotateDirection() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed RotationSpeedC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> RotationSpeed => RotationSpeedC.Value;
public bool TryGetRotationSpeed(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddRotationSpeed()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddRotationSpeed(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.RotationSpeed() {Value = value});
}
public _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce JumpForceC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce>();
public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> JumpForce => JumpForceC.Value;
public bool TryGetJumpForce(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce component);
if(result)
value = component.Value;
else
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>);
return result;
}
public _Project.Develop.Runtime.Entities.Entity AddJumpForce()
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single>() });
}
public _Project.Develop.Runtime.Entities.Entity AddJumpForce(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable<System.Single> value)
{
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Movement.JumpForce() {Value = value});
}
}
}

View File

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

View File

@@ -0,0 +1,6 @@
namespace _Project.Develop.Runtime.Entities
{
public interface IEntityComponent
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d243cc104e0d40f2959cfce43b78afb3
timeCreated: 1771425427

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4369817573164b8b8612e797f7d47fb9
timeCreated: 1771425427

View File

@@ -0,0 +1,19 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Entities
{
public abstract class EntityView : MonoBehaviour
{
public void Link(Entity entity)
{
entity.Initialized += OnEntityStartedWork;
}
public virtual void Cleanup(Entity entity)
{
entity.Initialized -= OnEntityStartedWork;
}
protected abstract void OnEntityStartedWork(Entity entity);
}
}

View File

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

View File

@@ -0,0 +1,72 @@
using Assets._Project.Develop.Runtime.Infrastructure.DI;
using System;
using System.Collections.Generic;
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
using UnityEngine;
using Object = UnityEngine.Object;
namespace _Project.Develop.Runtime.Entities
{
public class MonoEntitiesFactory : IInitializable, IDisposable
{
private readonly ResourcesAssetsLoader _resources;
private readonly EntitiesLifeContext _entitiesLifeContext;
private readonly CollidersRegistryService _collidersRegistryService;
private readonly Dictionary<Entity, MonoEntity> _entityToMono = new();
public MonoEntitiesFactory(
ResourcesAssetsLoader resources,
EntitiesLifeContext entitiesLifeContext,
CollidersRegistryService collidersRegistryService)
{
_resources = resources;
_entitiesLifeContext = entitiesLifeContext;
_collidersRegistryService = collidersRegistryService;
}
public MonoEntity Create(Entity entity, Vector3 position, string path)
{
MonoEntity prefab = _resources.Load<MonoEntity>(path);
MonoEntity viewInstance = Object.Instantiate(prefab, position, Quaternion.identity, null);
viewInstance.Initialize(_collidersRegistryService);
viewInstance.Link(entity);
_entityToMono.Add(entity, viewInstance);
return viewInstance;
}
public void Initialize()
{
_entitiesLifeContext.Released += OnEntityReleased;
}
public void Dispose()
{
_entitiesLifeContext.Released -= OnEntityReleased;
foreach (Entity entity in _entityToMono.Keys)
CleanupFor(entity);
_entityToMono.Clear();
}
private void OnEntityReleased(Entity entity)
{
CleanupFor(entity);
_entityToMono.Remove(entity);
}
private void CleanupFor(Entity entity)
{
MonoEntity monoEntity = _entityToMono[entity];
monoEntity.Cleanup(entity);
Object.Destroy(monoEntity.gameObject);
}
}
}

View File

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

View File

@@ -0,0 +1,52 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Entities
{
public class MonoEntity : MonoBehaviour
{
private CollidersRegistryService _collidersRegistryService;
private Entity _linkedEntity;
public Entity LinkedEntity => _linkedEntity;
public void Initialize(CollidersRegistryService collidersRegistryService)
{
_collidersRegistryService = collidersRegistryService;
}
public void Link(Entity entity)
{
_linkedEntity = entity;
MonoEntityRegistrator[] registrators = GetComponentsInChildren<MonoEntityRegistrator>();
if (registrators != null)
foreach (MonoEntityRegistrator registrator in registrators)
registrator.Register(entity);
EntityView[] views = GetComponentsInChildren<EntityView>();
if (views != null)
foreach (EntityView view in views)
view.Link(entity);
foreach (Collider collider in GetComponentsInChildren<Collider>())
_collidersRegistryService.Register(collider, entity);
}
public void Cleanup(Entity entity)
{
EntityView[] views = GetComponentsInChildren<EntityView>();
if (views != null)
foreach (EntityView view in views)
view.Cleanup(entity);
foreach (Collider collider in GetComponentsInChildren<Collider>())
_collidersRegistryService.Unregister(collider);
_linkedEntity = null;
}
}
}

View File

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

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace _Project.Develop.Runtime.Entities
{
public abstract class MonoEntityRegistrator : MonoBehaviour
{
public abstract void Register(Entity entity);
}
}

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 96088c9d645e452fbcaf26ca7c50a420
timeCreated: 1771425427

View File

@@ -0,0 +1,7 @@
namespace _Project.Develop.Runtime.Entities
{
public interface IDisposableSystem : IEntitySystem
{
void OnDispose();
}
}

View File

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

View File

@@ -0,0 +1,6 @@
namespace _Project.Develop.Runtime.Entities
{
public interface IEntitySystem
{
}
}

View File

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

View File

@@ -0,0 +1,7 @@
namespace _Project.Develop.Runtime.Entities
{
public interface IInitializableSystem: IEntitySystem
{
void OnInit(Entity entity);
}
}

View File

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

View File

@@ -0,0 +1,7 @@
namespace _Project.Develop.Runtime.Entities
{
public interface IUpdatableSystem : IEntitySystem
{
void OnUpdate(float deltaTime);
}
}

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 527131188a494fb8aa36b03631dfb201
timeCreated: 1770306345

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a4400c1c289f4486836ea29e45c9f9da
timeCreated: 1771435325

View File

@@ -0,0 +1,29 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class MoveDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
{
private readonly IPlayerInputService _playerInput;
private ReactiveVariable<Vector3> _moveDirection;
public MoveDirectionByInputSystem(IPlayerInputService playerInput)
{
_playerInput = playerInput;
}
public void OnInit(Entity entity)
{
_moveDirection = entity.MoveDirection;
}
public void OnUpdate(float deltaTime)
{
_moveDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ead925d5e3184e6882ddb0c3bf60749a
timeCreated: 1771432720

View File

@@ -0,0 +1,29 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utilities.InputManagement;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class RotateDirectionByInputSystem : IInitializableSystem, IUpdatableSystem
{
private readonly IPlayerInputService _playerInput;
private ReactiveVariable<Vector3> _rotateDirection;
public RotateDirectionByInputSystem(IPlayerInputService playerInput)
{
_playerInput = playerInput;
}
public void OnInit(Entity entity)
{
_rotateDirection = entity.RotateDirection;
}
public void OnUpdate(float deltaTime)
{
_rotateDirection.Value = new Vector3(_playerInput.Move.x, 0, _playerInput.Move.y);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8cefa96e10a40cfa0c17a4fc93112cf
timeCreated: 1771432904

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 132a224c65af417fa7d0ff6c47dc9e21
timeCreated: 1771427534

View File

@@ -0,0 +1,14 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class MoveDirection : IEntityComponent { public ReactiveVariable<Vector3> Value; }
public class MoveSpeed : IEntityComponent { public ReactiveVariable<float> Value; }
public class RotateDirection : IEntityComponent { public ReactiveVariable<Vector3> Value; }
public class RotationSpeed : IEntityComponent { public ReactiveVariable<float> Value; }
public class JumpForce : IEntityComponent { public ReactiveVariable<float> Value; }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cbe915c5b653410585247c01d9590343
timeCreated: 1771427563

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d5a20169d346473281e2c2fe29323264
timeCreated: 1771433138

View File

@@ -0,0 +1,31 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
using UnityEngine.AI;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class AgentMovementSystem : IInitializableSystem, IUpdatableSystem
{
private ReactiveVariable<float> _moveSpeed;
private NavMeshAgent _agent;
private Vector3 _position;
public void OnInit(Entity entity)
{
_moveSpeed = entity.MoveSpeed;
_agent = entity.NavMeshAgent;
// _position получить позицию
_agent.acceleration = 999;
}
public void OnUpdate(float deltaTime)
{
_agent.speed = _moveSpeed.Value;
// _agent.SetDestination(_position);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: da364e91e1ad4ac8911a602290e65656
timeCreated: 1771435874

View File

@@ -0,0 +1,27 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class CharacterControllerMovementSystem : IInitializableSystem, IUpdatableSystem
{
private ReactiveVariable<Vector3> _moveDirection;
private ReactiveVariable<float> _moveSpeed;
private CharacterController _controller;
public void OnInit(Entity entity)
{
_moveDirection = entity.MoveDirection;
_moveSpeed = entity.MoveSpeed;
_controller = entity.CharacterController;
}
public void OnUpdate(float deltaTime)
{
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
_controller.Move(velocity * deltaTime);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f947fab22c9b447aaca17e5b9118bbfc
timeCreated: 1771434334

View File

@@ -0,0 +1,23 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class RigidbodyJumpSystem : IInitializableSystem, IUpdatableSystem
{
private ReactiveVariable<float> _jumpForce;
private Rigidbody _rigidbody;
public void OnInit(Entity entity)
{
_jumpForce = entity.JumpForce;
_rigidbody = entity.Rigidbody;
}
public void OnUpdate(float deltaTime)
{
_rigidbody.AddForce(Vector3.up * _jumpForce.Value, ForceMode.Impulse);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2b7c856150e8421080f58737e14efef4
timeCreated: 1771435167

View File

@@ -0,0 +1,27 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class RigidbodyMovementSystem : IInitializableSystem, IUpdatableSystem
{
private ReactiveVariable<Vector3> _moveDirection;
private ReactiveVariable<float> _moveSpeed;
private Rigidbody _rigidbody;
public void OnInit(Entity entity)
{
_moveDirection = entity.MoveDirection;
_moveSpeed = entity.MoveSpeed;
_rigidbody = entity.Rigidbody;
}
public void OnUpdate(float deltaTime)
{
Vector3 velocity = _moveDirection.Value.normalized * _moveSpeed.Value;
_rigidbody.velocity = velocity;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 47ee3c1077054ccda0eac26a6ba5c4ff
timeCreated: 1771427601

View File

@@ -0,0 +1,33 @@
using _Project.Develop.Runtime.Entities;
using _Project.Develop.Runtime.Utils.ReactiveManagement;
using UnityEngine;
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Movement
{
public class RigidbodyRotationSystem : IInitializableSystem, IUpdatableSystem
{
private Rigidbody _rigidbody;
private ReactiveVariable<float> _speed;
private ReactiveVariable<Vector3> _direction;
public void OnInit(Entity entity)
{
_rigidbody = entity.Rigidbody;
_speed = entity.RotationSpeed;
_direction = entity.RotateDirection;
}
public void OnUpdate(float deltaTime)
{
if (_direction.Value == Vector3.zero)
return;
Quaternion lookRotation = Quaternion.LookRotation(_direction.Value.normalized);
float step = _speed.Value * deltaTime;
Quaternion rotation = Quaternion.RotateTowards(_rigidbody.rotation, lookRotation, step);
_rigidbody.MoveRotation(rotation);
}
}
}

Some files were not shown because too many files have changed in this diff Show More