using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
///
/// Different types of usages for an Atom Collection Reference.
///
public class AtomCollectionReferenceUsage
{
public const int COLLECTION = 0;
public const int COLLECTION_INSTANCER = 1;
}
///
/// Reference of type `AtomCollection`. Inherits from `AtomBaseReference`.
///
[Serializable]
public class AtomCollectionReference : AtomBaseReference, IGetValue
{
///
/// Get value as an `IAtomCollection`. Needed in order to inject Collection References into the Variable Instancer class.
///
/// The value as an `IAtomList`.
public IAtomCollection GetValue() => Collection != null ? Collection.GetValue() : null;
///
/// Get the value for the Reference.
///
/// The value of type `AtomCollection`.
public AtomCollection Collection
{
get
{
switch (_usage)
{
case (AtomCollectionReferenceUsage.COLLECTION_INSTANCER):
return _instancer == null ? default(AtomCollection) : _instancer.Variable;
case (AtomCollectionReferenceUsage.COLLECTION):
default:
return _collection;
}
}
}
///
/// Variable used if `Usage` is set to `COLLECTION`.
///
[SerializeField]
private AtomCollection _collection = default(AtomCollection);
///
/// Variable Instancer used if `Usage` is set to `COLLECTION_INSTANCER`.
///
[SerializeField]
private AtomCollectionInstancer _instancer = default(AtomCollectionInstancer);
}
}