55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace DanieleMarotta.RiversongCodeShowcase
|
|
{
|
|
public class AgentCarriedProductVisualization : MonoBehaviour
|
|
{
|
|
private const string CarryingProductLayer = "CarryingProduct";
|
|
|
|
[Required]
|
|
[SerializeField]
|
|
private Animator _animator;
|
|
|
|
[Required]
|
|
[SerializeField]
|
|
private Transform _carriedProductAnchor;
|
|
|
|
private int _carryingProductLayerIndex;
|
|
|
|
private GameObject _carriedProductVisualization;
|
|
|
|
private void Awake()
|
|
{
|
|
_carryingProductLayerIndex = _animator.GetLayerIndex(CarryingProductLayer);
|
|
}
|
|
|
|
public float GetAnimatorLayerWeight()
|
|
{
|
|
return _animator.GetLayerWeight(_carryingProductLayerIndex);
|
|
}
|
|
|
|
public void SetAnimatorLayerWeight(float weight)
|
|
{
|
|
_animator.SetLayerWeight(_carryingProductLayerIndex, weight);
|
|
}
|
|
|
|
public void SetProductVisualization(GameObject visualization)
|
|
{
|
|
_carriedProductVisualization = visualization;
|
|
visualization.transform.SetParent(_carriedProductAnchor, false);
|
|
}
|
|
|
|
public bool ClearProductVisualization(out GameObject visualization)
|
|
{
|
|
visualization = _carriedProductVisualization;
|
|
_carriedProductVisualization = null;
|
|
return visualization;
|
|
}
|
|
|
|
public bool IsShowingCarriedProduct()
|
|
{
|
|
return _carriedProductVisualization;
|
|
}
|
|
}
|
|
} |