Fix Object Instantiating
This commit is contained in:
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Models;
|
||||
using Models.Interfaces;
|
||||
using ScriptableObjects;
|
||||
using Services;
|
||||
using Services.Interfaces;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
using Views;
|
||||
|
||||
namespace Scopes
|
||||
{
|
||||
public class LevelLifetimeScope : LifetimeScope
|
||||
{
|
||||
[SerializeField] private GameVariables gameVariables;
|
||||
[SerializeField] private Transform gemsHolder;
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterInstance(this.gameVariables);
|
||||
builder.RegisterInstance(this.gemsHolder);
|
||||
|
||||
builder.Register<IGameBoard>(c =>
|
||||
new GameBoard(this.gameVariables.width, this.gameVariables.height),
|
||||
Lifetime.Scoped);
|
||||
|
||||
builder.Register<IMatchService, MatchService>(Lifetime.Scoped);
|
||||
builder.Register<IScoreService, ScoreService>(Lifetime.Scoped);
|
||||
|
||||
builder.Register<IObjectPool<GemView>>(c =>
|
||||
new ObjectPoolService(this.gameVariables.gemsPrefabs, this.gemsHolder, this.gameVariables.width * this.gameVariables.height),
|
||||
Lifetime.Scoped);
|
||||
|
||||
builder.Register<IGameBoardService, GameBoardService>(Lifetime.Scoped);
|
||||
|
||||
builder.RegisterEntryPoint<LevelEntryPoint>();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Scopes/LevelLifetimeScope.cs.meta
Normal file
3
Assets/Scripts/Scopes/LevelLifetimeScope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1e22ac45ff5446daf1aaa01329759a9
|
||||
timeCreated: 1765676452
|
||||
@@ -1,10 +1,14 @@
|
||||
using Services;
|
||||
using Services.Interfaces;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Scopes {
|
||||
public class RootLifetimeScope : LifetimeScope {
|
||||
protected override void Configure(IContainerBuilder builder) {
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterComponentInHierarchy<InputService>()
|
||||
.As<IInputService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user