Fix Object Instantiating

This commit is contained in:
2025-12-14 10:59:21 +08:00
parent 6fe70bd113
commit 6abccbe6d8
21 changed files with 371 additions and 180 deletions

View 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>();
}
}
}