Extend VContainer DI: eliminate manual composition and duplicate references

- Register InventoryModel, ShopModel as container-managed singletons
- Register GameController, ShopController, InventoryController via RegisterComponent
- Replace [SerializeField] with [Inject] for service dependencies in controllers
- Move maxActiveModifierSlots config to GameLifetimeScope (composition root)
- Remove manual model creation and Initialize() calls from GameController
- Add ToggleVisibility() to ShopController/InventoryController, removing GetComponentInChildren
- Move event subscriptions from Awake to Start for safe VContainer injection order
- Transfer game startup orchestration to GameController.Start()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 16:14:44 +07:00
parent 6c10a35bf9
commit 3c50415111
5 changed files with 116 additions and 98 deletions
+8 -6
View File
@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using VContainer;
using YachtDice.Categories;
using YachtDice.Scoring;
@@ -7,13 +8,12 @@ namespace YachtDice.Game
{
public class GameManager : MonoBehaviour
{
[Header("References")]
[SerializeField] private DiceManager diceManager;
[SerializeField] private ScoringSystem scoringSystem;
[Header("Settings")]
[SerializeField] private int maxRollsPerTurn = 3;
private DiceManager diceManager;
private ScoringSystem scoringSystem;
public int CurrentRoll { get; private set; }
public int CurrentTurn { get; private set; }
@@ -26,9 +26,11 @@ namespace YachtDice.Game
public event Action<CategoryDefinition, int> OnScored;
public event Action<int> OnGameOver;
private void Start()
[Inject]
public void Construct(DiceManager diceManager, ScoringSystem scoringSystem)
{
StartNewGame();
this.diceManager = diceManager;
this.scoringSystem = scoringSystem;
}
public void StartNewGame()