mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
init: add project
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Assets._Project.Develop.Runtime.Infrastructure;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Logic.Gameplay.Features;
|
||||
using _Project.Develop.Runtime.Utilities.InputManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
|
||||
{
|
||||
public class GameplayBootstrap : SceneBootstrap
|
||||
{
|
||||
[SerializeField] private TestGameplay _testGameplay;
|
||||
|
||||
private DIContainer _container;
|
||||
private EntitiesLifeContext _entitiesLifeContext;
|
||||
private GameplayInputArgs _gameplayArgs;
|
||||
|
||||
private IPlayerInputService _playerInput;
|
||||
|
||||
public override void ProcessRegistrations(DIContainer container, IInputSceneArgs sceneArgs = null)
|
||||
{
|
||||
_container = container;
|
||||
|
||||
if (sceneArgs is not GameplayInputArgs gameplayInputArgs)
|
||||
throw new ArgumentException($"{nameof(sceneArgs)} is not match with {typeof(GameplayInputArgs)} type");
|
||||
|
||||
GameplayContextRegistrations.Process(_container);
|
||||
_gameplayArgs = gameplayInputArgs;
|
||||
}
|
||||
|
||||
public override IEnumerator Initialize()
|
||||
{
|
||||
_entitiesLifeContext = _container.Resolve<EntitiesLifeContext>();
|
||||
|
||||
_testGameplay.Initialize(_container);
|
||||
yield break;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
_testGameplay.Run();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_entitiesLifeContext?.Update(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efb8e9c18c625dd409580386ad527885
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.UI;
|
||||
using _Project.Develop.Runtime.UI.Core;
|
||||
using _Project.Develop.Runtime.UI.Screens.Gameplay;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using Assets._Project.Develop.Runtime.Utilities.AssetsManagement;
|
||||
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
|
||||
{
|
||||
public class GameplayContextRegistrations
|
||||
{
|
||||
public static void Process(DIContainer container)
|
||||
{
|
||||
// container.RegisterAsSingle(CreateGameplayUIRoot).NonLazy();
|
||||
// container.RegisterAsSingle(CreateGameplayScreenPresenter).NonLazy();
|
||||
// container.RegisterAsSingle(CreateGameplayPresentersFactory);
|
||||
// container.RegisterAsSingle(CreateGameplayPopupService);
|
||||
|
||||
container.RegisterAsSingle(CreateEntitiesFactory);
|
||||
container.RegisterAsSingle(CreateEntitiesLifeContext);
|
||||
container.RegisterAsSingle(CreateCollidersRegistryService);
|
||||
container.RegisterAsSingle(CreateMonoEntitiesFactory).NonLazy();
|
||||
}
|
||||
|
||||
private static EntitiesLifeContext CreateEntitiesLifeContext(DIContainer c) => new();
|
||||
|
||||
private static EntitiesFactory CreateEntitiesFactory(DIContainer c) => new(c);
|
||||
|
||||
private static GameplayPresentersFactory CreateGameplayPresentersFactory(DIContainer c) => new(c);
|
||||
|
||||
private static CollidersRegistryService CreateCollidersRegistryService(DIContainer c) => new();
|
||||
|
||||
private static GameplayPopupService CreateGameplayPopupService(DIContainer c)
|
||||
{
|
||||
return new GameplayPopupService(
|
||||
c.Resolve<ViewsFactory>(),
|
||||
c.Resolve<ProjectPresentersFactory>(),
|
||||
c.Resolve<GameplayUIRoot>(),
|
||||
c.Resolve<GameplayPresentersFactory>());
|
||||
}
|
||||
|
||||
private static GameplayUIRoot CreateGameplayUIRoot(DIContainer c)
|
||||
{
|
||||
ResourcesAssetsLoader loader = c.Resolve<ResourcesAssetsLoader>();
|
||||
GameplayUIRoot uiRootPrefab = loader.Load<GameplayUIRoot>(PathToResources.UI.Screens.Gameplay);
|
||||
|
||||
return Object.Instantiate(uiRootPrefab);
|
||||
}
|
||||
|
||||
private static GameplayScreenPresenter CreateGameplayScreenPresenter(DIContainer c)
|
||||
{
|
||||
GameplayUIRoot uiRoot = c.Resolve<GameplayUIRoot>();
|
||||
GameplayScreenView view = c.Resolve<ViewsFactory>().Create<GameplayScreenView>(uiRoot.HUDLayer);
|
||||
|
||||
return c.Resolve<GameplayPresentersFactory>().CreateGameplayScreenPresenter(view);
|
||||
}
|
||||
|
||||
private static MonoEntitiesFactory CreateMonoEntitiesFactory(DIContainer c)
|
||||
{
|
||||
return new MonoEntitiesFactory(
|
||||
c.Resolve<ResourcesAssetsLoader>(),
|
||||
c.Resolve<EntitiesLifeContext>(),
|
||||
c.Resolve<CollidersRegistryService>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d5d417999b691947ad10beefd0c816c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using Assets._Project.Develop.Runtime.Utilities.SceneManagement;
|
||||
|
||||
namespace Assets._Project.Develop.Runtime.Gameplay.Infrastructure
|
||||
{
|
||||
public class GameplayInputArgs : IInputSceneArgs
|
||||
{
|
||||
public int LevelNumber { get; }
|
||||
|
||||
public GameplayInputArgs(int levelNumber)
|
||||
{
|
||||
LevelNumber = levelNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c8e145a7052dda4ba1d15ee516320f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utilities.InputManagement;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features
|
||||
{
|
||||
public class TestGameplay : MonoBehaviour
|
||||
{
|
||||
private DIContainer _container;
|
||||
private EntitiesFactory _entitiesFactory;
|
||||
|
||||
private Entity _entity;
|
||||
|
||||
private bool _isRunning;
|
||||
|
||||
public void Initialize(DIContainer container)
|
||||
{
|
||||
_container = container;
|
||||
|
||||
_entitiesFactory = _container.Resolve<EntitiesFactory>();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
_entity = _entitiesFactory.CreateTestEntity(Vector3.zero);
|
||||
|
||||
_isRunning = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isRunning == false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8be3a7a8111473cbe01d1fabc512e42
|
||||
timeCreated: 1771427485
|
||||
Reference in New Issue
Block a user