using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
///
/// Creates an in memory copy of a Collection using a base.
///
///
///
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
public abstract class AtomBaseCollectionInstancer : AtomBaseVariableInstancer
where V : AtomBaseVariable, IWithCollectionEvents
{
///
/// Override to add implementation specific setup on `OnEnable`.
///
protected override void ImplSpecificSetup()
{
var baseCollection = (V)Base;
var inMemoryCopy = (V)_inMemoryCopy;
if (baseCollection.Added != null)
{
inMemoryCopy.Added = Instantiate(baseCollection.Added);
}
if (baseCollection.Removed != null)
{
inMemoryCopy.Removed = Instantiate(baseCollection.Removed);
}
if (baseCollection.Cleared != null)
{
inMemoryCopy.Cleared = Instantiate(baseCollection.Cleared);
}
}
}
}