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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user