Scriptum/Assets/Scripts/REFACTORING/Models/Mission/Condition/MissionConditionData.cs
2023-01-03 22:44:24 +01:00

64 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
[Serializable]
//abstract - changed for Unity Inspector visualisation requirements
public class MissionConditionData : IModelMapper<MissionCondition>
{
[SerializeField]
public MissionTypeEnum Type;
[SerializeField]
public List<RequiredSubjectData> RequiredElements = new List<RequiredSubjectData>();
/// <summary>
/// Constructor implemented to create object in children classes in main purpose
///
/// We DON'T implement 'RequiredElements' list here because its MUST be FILLED by objects in specific subtyped (not base one) !!!
/// </summary>
/// <param name="type"></param>
protected MissionConditionData(MissionTypeEnum type)
{
Type = type;
}
// abstract
public virtual MissionCondition MapDataToObject(string prefarbAssetName) { return new MissionCondition(Type); }
// abstract
public virtual MissionCondition MapDataToObject() { return new MissionCondition(Type); }
/// <summary>
/// Function copied from MissionCondition::Build()
/// </summary>
//public abstract MissionConditionData<T, V, E> Build(T missionCondition);
//
public static MissionConditionData Build(MissionCondition missionCondition)
{
switch (missionCondition.Type)
{
case MissionTypeEnum.Kill:
{
Debug.Log("Build - KillMissionCondionData");
return new KillMissionConditionData(missionCondition);
}
case MissionTypeEnum.Collect:
{
Debug.Log("Build - CollectMissionConditionData");
return new CollectMissionConditionData(missionCondition);
}
default:
{
throw new NotImplementedException("Mission Collection data - constructor");
}
}
}
}