using UnityEngine;

[CreateAssetMenu(fileName = "Units Factory", menuName = "Units Factory")]
public sealed class UnitFactory : ScriptableObject
{
    [SerializeField]
    private Officer armyPrefab = null;

    [SerializeField]
    private Base mainBasePrefab = null;

    [SerializeField]
    private Base outpostPrefab = null;

    [SerializeField]
    private OutpostAssemblyUnit outpostAssemblyUnitPrefab = null;

    public Officer CreateArmy(Faction faction, Vector3 position)
    {
        var newArmy = Instantiate(armyPrefab, position, Quaternion.identity);
        newArmy.Init(faction);
        return newArmy;
    }

    public OutpostAssemblyUnit CreateOutpostAssembler(Faction faction, Vector3 position, ControlPoint point)
    {
        var newAssembler = Instantiate(outpostAssemblyUnitPrefab, position, Quaternion.identity);
        newAssembler.Init(faction, point);
        return newAssembler;
    }

    public Base CreateMainBase(Faction faction, ControlPoint point)
    {
        var newBase = Instantiate(mainBasePrefab, point.transform.position, Quaternion.identity);
        newBase.Init(faction);
        point.PlaceBase(newBase);
        return newBase;
    }

    public Base CreateOutpost(Faction faction, ControlPoint point)
    {
        var newBase = Instantiate(outpostPrefab, point.transform.position, Quaternion.identity);
        newBase.Init(faction);
        point.PlaceBase(newBase);
        return newBase;
    }
}
