2025-01-03 12:09:23 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Text;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
|
|
|
[Tool]
|
|
|
|
[GlobalClass]
|
|
|
|
public partial class ShakeEffect:Resource
|
|
|
|
{
|
|
|
|
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public AnimationCurve shakeAmountCurve;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public AnimationCurve shakeChangeFPSCurve;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public AnimationCurve shakeChangeFPSRandomCurve;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public TimeLine timeline;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public bool smooth = true;
|
|
|
|
|
|
|
|
[Export( PropertyHint.Range, "0,1" )]
|
|
|
|
public float smoothingStrength = 0;
|
|
|
|
|
|
|
|
public float GetShakeChangeFPSRandomized( float time, RandomEngine random = null )
|
|
|
|
{
|
|
|
|
random = RandomEngine.CreateIfNull( random );
|
|
|
|
var staticChange = shakeChangeFPSCurve == null ? 10 : shakeChangeFPSCurve.Sample( time );
|
|
|
|
var randomChange = shakeChangeFPSRandomCurve == null ? 0 : shakeChangeFPSRandomCurve.Sample( time );
|
|
|
|
return staticChange + random.Polar( randomChange );
|
|
|
|
}
|
2025-01-03 12:09:23 +00:00
|
|
|
|
|
|
|
[Export]
|
|
|
|
public Vector3 positionShake = Vector3.Zero;
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public bool globalPosition = true;
|
|
|
|
[Export]
|
|
|
|
public bool repeatAndFlipFirstPosition = true;
|
2025-01-03 12:09:23 +00:00
|
|
|
|
|
|
|
[Export]
|
|
|
|
public Vector3 rotationShake = Vector3.Zero;
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public bool globalRotation = true;
|
2025-01-03 12:09:23 +00:00
|
|
|
|
|
|
|
[Export]
|
|
|
|
public Vector3 scaleShake = Vector3.Zero;
|
|
|
|
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public bool scaleShakeIsRelative = true;
|
|
|
|
|
|
|
|
public TransformData GetShakeData( float time, Vector3 curveRandomization, RandomEngine random = null )
|
|
|
|
{
|
|
|
|
random = RandomEngine.CreateIfNull( random );
|
|
|
|
|
|
|
|
var shakeAmount = shakeAmountCurve.Sample( time, curveRandomization );
|
|
|
|
|
|
|
|
var transformData = new TransformData();
|
|
|
|
transformData.position = random.IndividualBetween( -positionShake, positionShake ) * shakeAmount;
|
|
|
|
transformData.rotation = random.IndividualBetween( -rotationShake, rotationShake ) * shakeAmount;
|
|
|
|
transformData.scale = random.IndividualBetween( -scaleShake, scaleShake ) * shakeAmount;
|
|
|
|
|
|
|
|
return transformData;
|
|
|
|
|
|
|
|
}
|
2025-01-03 12:09:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|