godot-plateformer/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs

76 lines
1.7 KiB
C#
Raw Normal View History

2025-12-29 11:54:31 +08:00
using Godot;
namespace PhantomCamera;
public enum TransitionType
{
Linear,
Sine,
Quint,
Quart,
Quad,
Expo,
Elastic,
Cubic,
Circ,
Bounce,
Back
}
public enum EaseType
{
EaseIn,
EaseOut,
EaseInOut,
EaseOutIn
}
public static class PhantomCameraTweenExtensions
{
public static PhantomCameraTween AsPhantomCameraTween(this Resource resource)
{
return new PhantomCameraTween(resource);
}
}
public class PhantomCameraTween(Resource tweenResource)
{
public Resource Resource { get; } = tweenResource;
public float Duration
{
get => (float)Resource.Get(PropertyName.Duration);
set => Resource.Set(PropertyName.Duration, value);
}
public TransitionType Transition
{
get => (TransitionType)(int)Resource.Get(PropertyName.Transition);
set => Resource.Set(PropertyName.Transition, (int)value);
}
public EaseType Ease
{
get => (EaseType)(int)Resource.Get(PropertyName.Ease);
set => Resource.Set(PropertyName.Ease, (int)value);
}
2025-12-31 13:07:31 +08:00
public static PhantomCameraTween New()
{
Resource resource = new();
#if GODOT4_4_OR_GREATER
resource.SetScript(GD.Load<GDScript>("uid://8umksf8e80fw"));
#else
resource.SetScript(GD.Load<GDScript>("res://addons/phantom_camera/scripts/resources/tween_resource.gd"));
#endif
return new PhantomCameraTween(resource);
}
2025-12-29 11:54:31 +08:00
public static class PropertyName
{
2025-12-31 13:07:31 +08:00
public static readonly StringName Duration = new("duration");
public static readonly StringName Transition = new("transition");
public static readonly StringName Ease = new("ease");
2025-12-29 11:54:31 +08:00
}
}