namespace Tilia.Interactions.Interactables.Interactors
{
using UnityEngine;
using Zinnia.Action;
using Zinnia.Data.Attribute;
using Zinnia.Extension;
///
/// The public interface into the Interactor Action Publisher Prefab.
///
public class InteractorActionPublisherFacade : MonoBehaviour
{
#region Action Settings
[Header("Action Settings")]
[Tooltip("The Action to be monitored to control the interaction.")]
[SerializeField]
private Action sourceAction;
///
/// The to be monitored to control the interaction.
///
public Action SourceAction
{
get
{
return sourceAction;
}
set
{
sourceAction = value;
if (this.IsMemberChangeAllowed())
{
OnAfterSourceActionChange();
}
}
}
[Tooltip("The source InteractorFacade that the action will be processed through.")]
[SerializeField]
private InteractorFacade sourceInteractor;
///
/// The source that the action will be processed through.
///
public InteractorFacade SourceInteractor
{
get
{
return sourceInteractor;
}
set
{
if (this.IsMemberChangeAllowed())
{
OnBeforeSourceInteractorChange();
}
sourceInteractor = value;
if (this.IsMemberChangeAllowed())
{
OnAfterSourceInteractorChange();
}
}
}
#endregion
#region Reference Settings
[Header("Reference Settings")]
[Tooltip("The Action that will be linked to the SourceAction.")]
[SerializeField]
[Restricted]
private InteractorActionPublisherConfigurator configuration;
///
/// The that will be linked to the .
///
public InteractorActionPublisherConfigurator Configuration
{
get
{
return configuration;
}
set
{
configuration = value;
}
}
#endregion
///
/// The current active .
///
public virtual Action ActiveAction => Configuration.ActiveAction;
///
/// Clears .
///
public virtual void ClearSourceAction()
{
if (!this.IsValidState())
{
return;
}
SourceAction = default;
}
///
/// Clears .
///
public virtual void ClearSourceInteractor()
{
if (!this.IsValidState())
{
return;
}
SourceInteractor = default;
}
///
/// Called after has been changed.
///
protected virtual void OnAfterSourceActionChange()
{
Configuration.LinkSourceActionToTargetAction();
}
///
/// Called before has been changed.
///
protected virtual void OnBeforeSourceInteractorChange()
{
Configuration.UnlinkActiveCollisions();
}
///
/// Called after has been changed.
///
protected virtual void OnAfterSourceInteractorChange()
{
Configuration.LinkSourceContainerToPublishers();
Configuration.LinkActiveCollisions();
}
}
}