You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
946 B
25 lines
946 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/// <summary>
|
|
/// 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
|
|
/// </summary>
|
|
public abstract class ModelComponent : MonoBehaviour, IModelContainer
|
|
{
|
|
public ShopModel Model { get => model; }
|
|
[SerializeField] private ItemFactory factory;
|
|
|
|
protected ShopModel model;
|
|
|
|
private void Awake()
|
|
{
|
|
Debug.Assert(factory != null,"Item factory not assigned!",this);
|
|
CreateModel(); // Of course, a generic model component can't select which type of model to use. So we use polymorphism!
|
|
factory.PopulateModel(model);
|
|
}
|
|
|
|
protected abstract void CreateModel();
|
|
}
|
|
|