Files
match3-unity/Assets/Scripts/Scopes/LevelLifetimeScope.cs
2025-12-17 00:55:30 +08:00

44 lines
1.5 KiB
C#

using Models.Interfaces;
using Presenter;
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.RegisterComponentInHierarchy<ScoreView>();
builder.Register<IGameBoard>(_ =>
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>>(_ =>
new ObjectPoolService(this.gameVariables.gemsPrefabs, this.gemsHolder),
Lifetime.Scoped);
builder.Register<IBombService, BombService>(Lifetime.Scoped);
builder.Register<ScorePresenter>(Lifetime.Scoped);
builder.Register<IGameBoardService, GameBoardService>(Lifetime.Scoped).AsImplementedInterfaces();
builder.RegisterEntryPoint<LevelEntryPoint>();
}
}
}