namespace VRTK.Prefabs.Pointers
{
using UnityEngine;
using Malimbe.MemberClearanceMethod;
using Malimbe.XmlDocumentationAttribute;
using Malimbe.PropertySerializationAttribute;
using Malimbe.BehaviourStateRequirementMethod;
using Zinnia.Cast;
using Zinnia.Pointer;
using Zinnia.Extension;
using Zinnia.Data.Operation.Extraction;
///
/// Extracts and emits the selected residing from the .
///
public class PointerFacadeComponentGameObjectExtractor : GameObjectExtractor
{
///
/// The Pointer Component to be extracted.
///
public enum PointerComponentType
{
///
/// The pointer .
///
Caster,
///
/// The that represents the Origin.
///
PointerElementOrigin,
///
/// The that represents the Repeated Segment.
///
PointerElementRepeatedSegment,
///
/// The that represents the Destination.
///
PointerElementDestination
}
///
/// The source to extract from.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public PointerFacade Source { get; set; }
///
/// The to extract from the .
///
[Serialized]
[field: DocumentedByXml]
public PointerComponentType PointerComponent { get; set; } = PointerComponentType.Caster;
///
public override GameObject Extract()
{
Result = null;
if (Source == null)
{
return null;
}
switch (PointerComponent)
{
case PointerComponentType.Caster:
Result = Source.Configuration.Caster.gameObject;
break;
case PointerComponentType.PointerElementOrigin:
Result = Source.Configuration.ObjectPointer.Origin.gameObject;
break;
case PointerComponentType.PointerElementRepeatedSegment:
Result = Source.Configuration.ObjectPointer.RepeatedSegment.gameObject;
break;
case PointerComponentType.PointerElementDestination:
Result = Source.Configuration.ObjectPointer.Destination.gameObject;
break;
default:
return null;
}
return base.Extract();
}
///
/// Extracts the from the given data.
///
/// The payload data to extract from.
/// The within the .
public virtual GameObject Extract(PointerFacade facade)
{
Source = facade;
return Extract();
}
///
/// Extracts the from the given data.
///
/// The payload data to extract from.
public virtual void DoExtract(PointerFacade facade)
{
Extract(facade);
}
///
/// Sets the based on a given .
///
/// The data that contains the component.
[RequiresBehaviourState]
public virtual void SetSource(GameObject source)
{
Source = source.TryGetComponent();
}
}
}