riversong code showcase
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user