using System; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// This component basically associates a model with a gameobject. This allows to know its location in the world /// (2D or 3D!) for fancy effects, or allows a view to switch between different models as it sees fit. /// The actual model can be anything from a buymodel to an inventorymodel /// public abstract class ModelComponent : MonoBehaviour, IModelContainer { public ShopModel Model { get => model; } //[SerializeField] private ItemFactory factory; [SerializeField] protected InventoryComponent inventory; protected ShopModel model; private void Awake() { Debug.Assert(inventory != null,"Inventory not assigned!",this); CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism! model.inventory = inventory.Inventory; //factory.PopulateInventory(model.inventory); } protected abstract void CreateModel(); }