32 lines
788 B
C#
32 lines
788 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using BITKit.FPS;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITKit.Entities.Player.Feel
|
||
|
{
|
||
|
public sealed class PlayerHitMotion : EntityComponent
|
||
|
{
|
||
|
[SerializeField] private Spring3 spring;
|
||
|
[SerializeField] private LocationAdditive locationAdditive;
|
||
|
[SerializeField] private AnimationCurve damageBasedMotion;
|
||
|
public override void OnStart()
|
||
|
{
|
||
|
entity.AddListener<DamageMessage>(OnDamaged);
|
||
|
}
|
||
|
|
||
|
private void OnDamaged(DamageMessage obj)
|
||
|
{
|
||
|
var damage = damageBasedMotion.Evaluate(obj.damage);
|
||
|
spring.value = new Vector3(damage.Random(), damage.Random(), damage.Random());
|
||
|
}
|
||
|
|
||
|
public override void OnUpdate(float deltaTime)
|
||
|
{
|
||
|
spring.Update(deltaTime,default);
|
||
|
locationAdditive.AddEuler(spring.value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|