Files
BABA_YAGA/Assets/Opsive/UltimateCharacterController/Scripts/Items/ItemPerspectiveProperties.cs
2026-06-09 02:05:00 +07:00

52 lines
1.8 KiB
C#

/// ---------------------------------------------
/// Ultimate Character Controller
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Items
{
using Opsive.Shared.Game;
using Opsive.Shared.Utility;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.StateSystem;
using UnityEngine;
/// <summary>
/// Describes any perspective dependent properties for the ItemAction.
/// </summary>
public abstract class ItemPerspectiveProperties : StateBehavior
{
[Tooltip("The corresponding ID of the action component that this object belongs to.")]
[SerializeField] protected int m_ActionID;
[NonSerialized] public int ActionID { get { return m_ActionID; } set { m_ActionID = value; } }
protected GameObject m_Object;
protected GameObject m_Character;
protected UltimateCharacterLocomotion m_CharacterLocomotion;
protected Transform m_CharacterTransform;
public abstract bool FirstPersonItem { get; }
/// <summary>
/// Initialize the default values.
/// </summary>
protected override void Awake()
{
base.Awake();
var perspectiveItems = GetComponents<PerspectiveItem>();
for (int i = 0; i < perspectiveItems.Length; ++i) {
if (perspectiveItems[i].FirstPersonItem == FirstPersonItem) {
m_Object = perspectiveItems[i].Object;
break;
}
}
m_CharacterLocomotion = gameObject.GetCachedParentComponent<UltimateCharacterLocomotion>();
m_Character = m_CharacterLocomotion.gameObject;
m_CharacterTransform = m_Character.transform;
}
}
}