A Component that animates a heart model's scale based on a HeartOrgan state. It lerps the GameObject.WorldScale between two float targets when the organ's Lub boolean changes, with an option to reverse the beat behavior.
namespace Sandbox;
public sealed class RudimentaryHeartScaleAnimator : Component
{
[Property, Feature( "Properties" )] public float enlargeTo = 1.2f;
[Property, Feature( "Properties" )] public float relaxTo = 1f;
[Property, Feature( "Properties" )] public bool reverseBeat = true;
[Property, RequireComponent] HeartOrgan Itself { get; set; }
[Property] GameObject ModelObject { get; set; }
protected override void OnUpdate()
{
if(Itself.IsValid())
{
if(ModelObject.IsValid())
{
// frac were 0.2f fixed
if ( reverseBeat )
{
// if ( Itself.Lub ) ModelObject.WorldScale = enlargeTo;
if ( Itself.Lub ) ModelObject.WorldScale = Vector3.Lerp(ModelObject.WorldScale,relaxTo,.2f);
// else ModelObject.WorldScale = relaxTo;
else ModelObject.WorldScale = Vector3.Lerp(ModelObject.WorldScale,enlargeTo,.2f);
}
else{
// if ( Itself.Lub ) ModelObject.WorldScale = enlargeTo;
if ( Itself.Lub ) ModelObject.WorldScale = Vector3.Lerp(ModelObject.WorldScale,enlargeTo,.2f);
// else ModelObject.WorldScale = relaxTo;
else ModelObject.WorldScale = Vector3.Lerp(ModelObject.WorldScale,relaxTo,.2f);
}
//DONE: Lerp!!!
// TODO: Woman 3d model, prioritize furry ones, such as horse thyren or subspecies like pony hasbro
}
}
}
}