#if GRAPH_DESIGNER /// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Runtime.Tasks.Actions.Conversions { using Opsive.GraphDesigner.Runtime.Variables; using UnityEngine; [Opsive.Shared.Utility.Category("Conversions")] [Opsive.Shared.Utility.Description("Converts an int to a Vector3 by setting X, Y, Z, or all components to the int value.")] public class ConvertIntToVector3 : Action { /// /// Specifies which component(s) to set in the Vector3. /// public enum SetComponent { SetX, // Set only the X component (Y and Z remain 0). SetY, // Set only the Y component (X and Z remain 0). SetZ, // Set only the Z component (X and Y remain 0). SetAll // Set all components (X, Y, Z) to the int value. } [Tooltip("The int to convert.")] [SerializeField] protected SharedVariable m_InputValue; [Tooltip("Specifies which component(s) to set.")] [SerializeField] protected SetComponent m_SetComponent = SetComponent.SetX; [Tooltip("The resulting Vector3 value.")] [SerializeField] [RequireShared] protected SharedVariable m_OutputVector; /// /// Converts the int to a Vector3. /// /// The status of the action. public override TaskStatus OnUpdate() { switch (m_SetComponent) { case SetComponent.SetX: m_OutputVector.Value = new Vector3(m_InputValue.Value, 0f, 0f); break; case SetComponent.SetY: m_OutputVector.Value = new Vector3(0f, m_InputValue.Value, 0f); break; case SetComponent.SetZ: m_OutputVector.Value = new Vector3(0f, 0f, m_InputValue.Value); break; case SetComponent.SetAll: m_OutputVector.Value = new Vector3(m_InputValue.Value, m_InputValue.Value, m_InputValue.Value); break; } return TaskStatus.Success; } /// /// Resets the action values back to their default. /// public override void Reset() { base.Reset(); m_InputValue = null; m_SetComponent = SetComponent.SetX; m_OutputVector = null; } } } #endif