mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-17 12:03:47 +00:00
Added GTWeen
This commit is contained in:
parent
457998788e
commit
2036e4e748
152 changed files with 5889 additions and 7 deletions
56
GTweensGodot/Godot/Source/Extensions/AngleExtensions.cs
Normal file
56
GTweensGodot/Godot/Source/Extensions/AngleExtensions.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using Godot;
|
||||
using GTweens.Enums;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class AngleExtensions
|
||||
{
|
||||
public static Vector3 Clamp360(Vector3 eulerAngles)
|
||||
{
|
||||
return new Vector3(
|
||||
GTweens.Extensions.AngleExtensions.Clamp360(eulerAngles.X),
|
||||
GTweens.Extensions.AngleExtensions.Clamp360(eulerAngles.Y),
|
||||
GTweens.Extensions.AngleExtensions.Clamp360(eulerAngles.Z)
|
||||
);
|
||||
}
|
||||
|
||||
public static Vector3 DeltaAngle(Vector3 current, Vector3 target)
|
||||
{
|
||||
return new Vector3(
|
||||
GTweens.Extensions.AngleExtensions.DeltaAngle(current.X, target.X),
|
||||
GTweens.Extensions.AngleExtensions.DeltaAngle(current.Y, target.Y),
|
||||
GTweens.Extensions.AngleExtensions.DeltaAngle(current.Z, target.Z)
|
||||
);
|
||||
}
|
||||
|
||||
public static Vector3 GetDestinationAngleDegrees(Vector3 origin, Vector3 destination, RotationMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case RotationMode.ShortestDistance:
|
||||
{
|
||||
Vector3 clampedOrigin = Clamp360(origin);
|
||||
Vector3 clampedDestination = Clamp360(destination);
|
||||
|
||||
Vector3 deltaAngle = DeltaAngle(clampedOrigin, clampedDestination);
|
||||
|
||||
return origin + deltaAngle;
|
||||
}
|
||||
|
||||
default:
|
||||
case RotationMode.TotalDistance:
|
||||
{
|
||||
return destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 GetDestinationAngleRadiants(Vector3 origin, Vector3 destination, RotationMode mode)
|
||||
{
|
||||
return GetDestinationAngleDegrees(
|
||||
origin * MathExtensions.Rad2Deg,
|
||||
destination * MathExtensions.Rad2Deg,
|
||||
mode
|
||||
) * MathExtensions.Deg2Rad;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ctryd158yesn6
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class AudioStreamPlayer2DExtensions
|
||||
{
|
||||
public static GTween TweenVolumeDb(this AudioStreamPlayer2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.VolumeDb,
|
||||
current => target.VolumeDb = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPitchScale(this AudioStreamPlayer2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.PitchScale,
|
||||
current => target.PitchScale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ecwl3ubgr054
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class AudioStreamPlayer3DExtensions
|
||||
{
|
||||
public static GTween TweenVolumeDb(this AudioStreamPlayer3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.VolumeDb,
|
||||
current => target.VolumeDb = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPitchScale(this AudioStreamPlayer3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.PitchScale,
|
||||
current => target.PitchScale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenAttenuationFilterDb(this AudioStreamPlayer3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.AttenuationFilterDb,
|
||||
current => target.AttenuationFilterDb = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenAttenuationFilterCutoffHz(this AudioStreamPlayer3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.AttenuationFilterCutoffHz,
|
||||
current => target.AttenuationFilterCutoffHz = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b6hmb83ornmiv
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class BaseMaterial3DExtensions
|
||||
{
|
||||
public static GTween TweenAlbedoColor(this BaseMaterial3D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.AlbedoColor,
|
||||
current => target.AlbedoColor = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenAlbedoColorRgb(this BaseMaterial3D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.AlbedoColor,
|
||||
current => target.AlbedoColor = new Color(current.R, current.G, current.B, target.AlbedoColor.A),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenAlbedoColorAlpha(this BaseMaterial3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.AlbedoColor.A,
|
||||
current => target.AlbedoColor = new Color(target.AlbedoColor.R, target.AlbedoColor.G, target.AlbedoColor.B, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenMetallic(this BaseMaterial3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Metallic,
|
||||
current => target.Metallic = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenMetallicSpecular(this BaseMaterial3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.MetallicSpecular,
|
||||
current => target.MetallicSpecular = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRoughness(this BaseMaterial3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Roughness,
|
||||
current => target.Roughness = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cbrinkf16qyff
|
||||
74
GTweensGodot/Godot/Source/Extensions/Camera2DExtensions.cs
Normal file
74
GTweensGodot/Godot/Source/Extensions/Camera2DExtensions.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Camera2DExtensions
|
||||
{
|
||||
public static GTween TweenOffset(this Camera2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Offset,
|
||||
current => target.Offset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetX(this Camera2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.X,
|
||||
current => target.Offset = new Vector2(current, target.Offset.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetY(this Camera2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.Y,
|
||||
current => target.Offset = new Vector2(target.Offset.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenZoom(this Camera2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Zoom,
|
||||
current => target.Zoom = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenZoomX(this Camera2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Zoom.X,
|
||||
current => target.Zoom = new Vector2(current, target.Zoom.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenZoomY(this Camera2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Zoom.Y,
|
||||
current => target.Zoom = new Vector2(target.Zoom.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://rsvu3cctnr2k
|
||||
41
GTweensGodot/Godot/Source/Extensions/Camera3DExtensions.cs
Normal file
41
GTweensGodot/Godot/Source/Extensions/Camera3DExtensions.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Camera3DExtensions
|
||||
{
|
||||
public static GTween TweenHOffset(this Camera3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.HOffset,
|
||||
current => target.HOffset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenVOffset(this Camera3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.VOffset,
|
||||
current => target.VOffset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenFov(this Camera3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Fov,
|
||||
current => target.Fov = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ckmn5xp6nf40u
|
||||
74
GTweensGodot/Godot/Source/Extensions/CanvasItemExtensions.cs
Normal file
74
GTweensGodot/Godot/Source/Extensions/CanvasItemExtensions.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class CanvasItemExtensions
|
||||
{
|
||||
public static GTween TweenModulate(this CanvasItem target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Modulate,
|
||||
current => target.Modulate = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenModulateRgb(this CanvasItem target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Modulate,
|
||||
current => target.Modulate = new Color(current.R, current.G, current.B, target.Modulate.A),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenModulateAlpha(this CanvasItem target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Modulate.A,
|
||||
current => target.Modulate = new Color(target.Modulate.R, target.Modulate.G, target.Modulate.B, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSelfModulate(this CanvasItem target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.SelfModulate,
|
||||
current => target.SelfModulate = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSelfModulateRgb(this CanvasItem target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.SelfModulate,
|
||||
current => target.SelfModulate = new Color(current.R, current.G, current.B, target.SelfModulate.A),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSelfModulateAlpha(this CanvasItem target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.SelfModulate.A,
|
||||
current => target.SelfModulate = new Color(target.SelfModulate.R, target.SelfModulate.G, target.SelfModulate.B, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bl6m35eo2x84k
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class CanvasModulateExtensions
|
||||
{
|
||||
public static GTween TweenColor(this CanvasModulate target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Color,
|
||||
current => target.Color = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenColorRgb(this CanvasModulate target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Color,
|
||||
current => target.Color = new Color(current.R, current.G, current.B, target.Color.A),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenColorAlpha(this CanvasModulate target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Color.A,
|
||||
current => target.Color = new Color(target.Color.R, target.Color.G, target.Color.B, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://iuhveeivk72w
|
||||
196
GTweensGodot/Godot/Source/Extensions/ControlExtensions.cs
Normal file
196
GTweensGodot/Godot/Source/Extensions/ControlExtensions.cs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
using Godot;
|
||||
using GTweens.Enums;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class ControlExtensions
|
||||
{
|
||||
public static GTween TweenGlobalPosition(this Control target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalPosition,
|
||||
current => target.GlobalPosition = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionX(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.X,
|
||||
current => target.GlobalPosition = new Vector2(current, target.GlobalPosition.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionY(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.Y,
|
||||
current => target.GlobalPosition = new Vector2(target.GlobalPosition.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPosition(this Control target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Position,
|
||||
current => target.Position = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionX(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.X,
|
||||
current => target.Position = new Vector2(current, target.Position.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionY(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.Y,
|
||||
current => target.Position = new Vector2(target.Position.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotation(this Control target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Rotation,
|
||||
current => target.Rotation = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.Rotation, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegrees(this Control target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.RotationDegrees,
|
||||
current => target.RotationDegrees = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScale(this Control target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Scale,
|
||||
current => target.Scale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleX(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.X,
|
||||
current => target.Scale = new Vector2(current, target.Scale.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleY(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.Y,
|
||||
current => target.Scale = new Vector2(target.Scale.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSize(this Control target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Size,
|
||||
current => target.Size = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSizeX(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Size.X,
|
||||
current => target.Size = new Vector2(current, target.Size.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSizeY(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Size.Y,
|
||||
current => target.Size = new Vector2(target.Size.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPivotOffset(this Control target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.PivotOffset,
|
||||
current => target.PivotOffset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPivotOffsetX(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.PivotOffset.X,
|
||||
current => target.PivotOffset = new Vector2(current, target.PivotOffset.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPivotOffsetY(this Control target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.PivotOffset.Y,
|
||||
current => target.PivotOffset = new Vector2(target.PivotOffset.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cc57owpk8jiyg
|
||||
19
GTweensGodot/Godot/Source/Extensions/CurveExtensions.cs
Normal file
19
GTweensGodot/Godot/Source/Extensions/CurveExtensions.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using Godot;
|
||||
using GTweens.Easings;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class CurveExtensions
|
||||
{
|
||||
public static EasingDelegate ToEasingDelegate(this Curve curve)
|
||||
{
|
||||
float Result(float a, float b, float t)
|
||||
{
|
||||
float newT = curve.Sample(t);
|
||||
|
||||
return a + ((b - a) * newT);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ccquxii7a7i11
|
||||
311
GTweensGodot/Godot/Source/Extensions/GTweenGodotExtensions.cs
Normal file
311
GTweensGodot/Godot/Source/Extensions/GTweenGodotExtensions.cs
Normal file
|
|
@ -0,0 +1,311 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
using GTweens.Delegates;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.TweenBehaviours;
|
||||
using GTweens.Tweeners;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Contexts;
|
||||
using GTweensGodot.Tweeners;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class GTweenGodotExtensions
|
||||
{
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2>.Getter getter,
|
||||
Tweener<Vector2>.Setter setter,
|
||||
Tweener<Vector2>.Getter to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
)
|
||||
{
|
||||
InterpolationTweenBehaviour tweenBehaviour = new InterpolationTweenBehaviour();
|
||||
tweenBehaviour.Add(new GodotVector2Tweener(getter, setter, to, duration, validation));
|
||||
return new GTween(tweenBehaviour);
|
||||
}
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2>.Getter getter,
|
||||
Tweener<Vector2>.Setter setter,
|
||||
Vector2 to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
) => Tween(getter, setter, () => to, duration, validation);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2>.Getter getter,
|
||||
Tweener<Vector2>.Setter setter,
|
||||
Vector2 to,
|
||||
float duration
|
||||
) => Tween(getter, setter, to, duration, ValidationExtensions.AlwaysValid);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2I>.Getter getter,
|
||||
Tweener<Vector2I>.Setter setter,
|
||||
Tweener<Vector2I>.Getter to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
)
|
||||
{
|
||||
InterpolationTweenBehaviour tweenBehaviour = new InterpolationTweenBehaviour();
|
||||
tweenBehaviour.Add(new GodotVector2ITweener(getter, setter, to, duration, validation));
|
||||
return new GTween(tweenBehaviour);
|
||||
}
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2I>.Getter getter,
|
||||
Tweener<Vector2I>.Setter setter,
|
||||
Vector2I to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
) => Tween(getter, setter, () => to, duration, validation);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector2I>.Getter getter,
|
||||
Tweener<Vector2I>.Setter setter,
|
||||
Vector2I to,
|
||||
float duration
|
||||
) => Tween(getter, setter, to, duration, ValidationExtensions.AlwaysValid);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector3>.Getter getter,
|
||||
Tweener<Vector3>.Setter setter,
|
||||
Tweener<Vector3>.Getter to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
)
|
||||
{
|
||||
InterpolationTweenBehaviour tweenBehaviour = new InterpolationTweenBehaviour();
|
||||
tweenBehaviour.Add(new GodotVector3Tweener(getter, setter, to, duration, validation));
|
||||
return new GTween(tweenBehaviour);
|
||||
}
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector3>.Getter getter,
|
||||
Tweener<Vector3>.Setter setter,
|
||||
Vector3 to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
) => Tween(getter, setter, () => to, duration, validation);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Vector3>.Getter getter,
|
||||
Tweener<Vector3>.Setter setter,
|
||||
Vector3 to,
|
||||
float duration
|
||||
) => Tween(getter, setter, to, duration, ValidationExtensions.AlwaysValid);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Color>.Getter getter,
|
||||
Tweener<Color>.Setter setter,
|
||||
Tweener<Color>.Getter to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
)
|
||||
{
|
||||
InterpolationTweenBehaviour tweenBehaviour = new InterpolationTweenBehaviour();
|
||||
tweenBehaviour.Add(new GodotColorTweener(getter, setter, to, duration, validation));
|
||||
return new GTween(tweenBehaviour);
|
||||
}
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Color>.Getter getter,
|
||||
Tweener<Color>.Setter setter,
|
||||
Color to,
|
||||
float duration,
|
||||
ValidationDelegates.Validation validation
|
||||
) => Tween(getter, setter, () => to, duration, validation);
|
||||
|
||||
public static GTween Tween(
|
||||
Tweener<Color>.Getter getter,
|
||||
Tweener<Color>.Setter setter,
|
||||
Color to,
|
||||
float duration
|
||||
) => Tween(getter, setter, to, duration, ValidationExtensions.AlwaysValid);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the easing function for a GTween using a specified Curve.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to set the easing function for.</param>
|
||||
/// <param name="curve">The Curve representing the desired easing behavior.</param>
|
||||
/// <returns>The modified GTween with the specified easing function.</returns>
|
||||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="curve"/> is null.</exception>
|
||||
public static GTween SetEasing(this GTween gTween, Curve curve)
|
||||
{
|
||||
if (curve == null)
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
$"Tried to {nameof(SetEasing)} on a {nameof(GTween)} with a null {nameof(Curve)}"
|
||||
);
|
||||
}
|
||||
|
||||
return gTween.SetEasing(curve.ToEasingDelegate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays a GTween. This tween will be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="tween">The GTween to play.</param>
|
||||
public static void Play(this GTween tween)
|
||||
{
|
||||
GodotGTweensContext.Instance.PausableContext.Play(tween);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays a GTween. This tween will not be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="tween">The GTween to play.</param>
|
||||
public static void PlayUnpausable(this GTween tween)
|
||||
{
|
||||
GodotGTweensContext.Instance.UnpausableContext.Play(tween);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays a GTween. This tween will be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="tween">The GTween to play.</param>
|
||||
/// <param name="instantly">If set to true, sets the tween as completed after playing, making it reach the end instantly.</param>
|
||||
public static void Play(this GTween tween, bool instantly)
|
||||
{
|
||||
tween.Play();
|
||||
|
||||
if (instantly)
|
||||
{
|
||||
tween.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plays a GTween. This tween will not be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="tween">The GTween to play.</param>
|
||||
/// <param name="instantly">If set to true, sets the tween as completed after playing, making it reach the end instantly.</param>
|
||||
public static void PlayUnpausable(this GTween tween, bool instantly)
|
||||
{
|
||||
tween.PlayUnpausable();
|
||||
|
||||
if (instantly)
|
||||
{
|
||||
tween.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayAsync(this GTween gTween, CancellationToken cancellationToken)
|
||||
{
|
||||
gTween.Play();
|
||||
|
||||
cancellationToken.Register(gTween.Kill);
|
||||
|
||||
return gTween.AwaitCompleteOrKill(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will not be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayUnpausableAsync(this GTween gTween, CancellationToken cancellationToken)
|
||||
{
|
||||
gTween.PlayUnpausable();
|
||||
|
||||
cancellationToken.Register(gTween.Kill);
|
||||
|
||||
return gTween.AwaitCompleteOrKill(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="instantly">If set to true, sets the tween as completed after playing, making it reach the end instantly.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayAsync(this GTween gTween, bool instantly, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!instantly)
|
||||
{
|
||||
return gTween.PlayAsync(cancellationToken);
|
||||
}
|
||||
|
||||
gTween.Play();
|
||||
gTween.Complete();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will not be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="instantly">If set to true, sets the tween as completed after playing, making it reach the end instantly.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayUnpausableAsync(this GTween gTween, bool instantly, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!instantly)
|
||||
{
|
||||
return gTween.PlayUnpausableAsync(cancellationToken);
|
||||
}
|
||||
|
||||
gTween.Play();
|
||||
gTween.Complete();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="completeToken">A token to complete the GTween's execution.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayAsync(this GTween gTween, CancellationToken completeToken, CancellationToken cancellationToken)
|
||||
{
|
||||
gTween.Play();
|
||||
|
||||
cancellationToken.Register(gTween.Kill);
|
||||
completeToken.Register(gTween.Complete);
|
||||
|
||||
return gTween.AwaitCompleteOrKill(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously plays a GTween and awaits its completion or cancellation.
|
||||
/// If the cancellationToken cancellation is requested, the tween will be killed.
|
||||
/// This tween will not be paused when GetTree().Paused is set to true.
|
||||
/// </summary>
|
||||
/// <param name="gTween">The GTween to play.</param>
|
||||
/// <param name="completeToken">A token to complete the GTween's execution.</param>
|
||||
/// <param name="cancellationToken">A token to cancel the GTween's execution.</param>
|
||||
/// <returns>A Task representing the asynchronous operation.</returns>
|
||||
public static Task PlayUnpausableAsync(this GTween gTween, CancellationToken completeToken, CancellationToken cancellationToken)
|
||||
{
|
||||
gTween.PlayUnpausable();
|
||||
|
||||
cancellationToken.Register(gTween.Kill);
|
||||
completeToken.Register(gTween.Complete);
|
||||
|
||||
return gTween.AwaitCompleteOrKill(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://be37qu6xx7nd3
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using Godot;
|
||||
using GTweens.Delegates;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class GodotObjectExtensions
|
||||
{
|
||||
public static ValidationDelegates.Validation GetGodotObjectValidationFunction(GodotObject godotObject)
|
||||
=> () => GodotObject.IsInstanceValid(godotObject);
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d2ii15vsgypsg
|
||||
19
GTweensGodot/Godot/Source/Extensions/LabelExtensions.cs
Normal file
19
GTweensGodot/Godot/Source/Extensions/LabelExtensions.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class LabelExtensions
|
||||
{
|
||||
public static GTween TweenDisplayedTextVisibleRatio(this Label target, float value, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.VisibleRatio,
|
||||
current => target.VisibleRatio = current,
|
||||
value,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://daxhcgsex5bt6
|
||||
41
GTweensGodot/Godot/Source/Extensions/Light2DExtensions.cs
Normal file
41
GTweensGodot/Godot/Source/Extensions/Light2DExtensions.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Light2DExtensions
|
||||
{
|
||||
public static GTween TweenColor(this Light2D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Color,
|
||||
current => target.Color = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenEnergy(this Light2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Energy,
|
||||
current => target.Energy = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowColor(this Light2D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.ShadowColor,
|
||||
current => target.ShadowColor = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cnxrvox30dnul
|
||||
118
GTweensGodot/Godot/Source/Extensions/Light3DExtensions.cs
Normal file
118
GTweensGodot/Godot/Source/Extensions/Light3DExtensions.cs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Light3DExtensions
|
||||
{
|
||||
public static GTween TweenLightColor(this Light3D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.LightColor,
|
||||
current => target.LightColor = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenLightEnergy(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.LightEnergy,
|
||||
current => target.LightEnergy = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenLightIndirectEnergy(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.LightIndirectEnergy,
|
||||
current => target.LightIndirectEnergy = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenLightVolumetricFogEnergy(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.LightVolumetricFogEnergy,
|
||||
current => target.LightVolumetricFogEnergy = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenLightAngularDistance(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.LightAngularDistance,
|
||||
current => target.LightAngularDistance = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowBias(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.ShadowBias,
|
||||
current => target.ShadowBias = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowNormalBias(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.ShadowNormalBias,
|
||||
current => target.ShadowNormalBias = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowTransmittanceBias(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.ShadowTransmittanceBias,
|
||||
current => target.ShadowTransmittanceBias = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowOpacity(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.ShadowOpacity,
|
||||
current => target.ShadowOpacity = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenShadowBlur(this Light3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.ShadowBlur,
|
||||
current => target.ShadowBlur = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://csk3p81k8w61e
|
||||
7
GTweensGodot/Godot/Source/Extensions/MathExtensions.cs
Normal file
7
GTweensGodot/Godot/Source/Extensions/MathExtensions.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class MathExtensions
|
||||
{
|
||||
public const float Deg2Rad = 0.01745329f;
|
||||
public const float Rad2Deg = 57.29578f;
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bp2i5stjyqwv6
|
||||
207
GTweensGodot/Godot/Source/Extensions/Node2DExtensions.cs
Normal file
207
GTweensGodot/Godot/Source/Extensions/Node2DExtensions.cs
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
using Godot;
|
||||
using GTweens.Enums;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Node2DExtensions
|
||||
{
|
||||
public static GTween TweenGlobalPosition(this Node2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalPosition,
|
||||
current => target.GlobalPosition = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionX(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.X,
|
||||
current => target.GlobalPosition = new Vector2(current, target.GlobalPosition.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionY(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.Y,
|
||||
current => target.GlobalPosition = new Vector2(target.GlobalPosition.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPosition(this Node2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Position,
|
||||
current => target.Position = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionX(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.X,
|
||||
current => target.Position = new Vector2(current, target.Position.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionY(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.Y,
|
||||
current => target.Position = new Vector2(target.Position.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotation(this Node2D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotation,
|
||||
current => target.GlobalRotation = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.GlobalRotation, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotation(this Node2D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Rotation,
|
||||
current => target.Rotation = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.Rotation, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationDegrees(this Node2D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotationDegrees,
|
||||
current => target.GlobalRotationDegrees = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.GlobalRotationDegrees, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegrees(this Node2D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.RotationDegrees,
|
||||
current => target.RotationDegrees = current,
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalScale(this Node2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalScale,
|
||||
current => target.GlobalScale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalScaleX(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalScale.X,
|
||||
current => target.GlobalScale = new Vector2(current, target.GlobalScale.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalScaleY(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalScale.Y,
|
||||
current => target.GlobalScale = new Vector2(target.GlobalScale.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScale(this Node2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Scale,
|
||||
current => target.Scale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleX(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.X,
|
||||
current => target.Scale = new Vector2(current, target.Scale.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleY(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.Y,
|
||||
current => target.Scale = new Vector2(target.Scale.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalSkew(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalSkew,
|
||||
current => target.GlobalSkew = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenSkew(this Node2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Skew,
|
||||
current => target.Skew = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d0b1fftj7h4h3
|
||||
383
GTweensGodot/Godot/Source/Extensions/Node3DExtensions.cs
Normal file
383
GTweensGodot/Godot/Source/Extensions/Node3DExtensions.cs
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
using Godot;
|
||||
using GTweens.Enums;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Node3DExtensions
|
||||
{
|
||||
public static GTween TweenGlobalPosition(this Node3D target, Vector3 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalPosition,
|
||||
current => target.GlobalPosition = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionX(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.X,
|
||||
current => target.GlobalPosition = new Vector3(current, target.GlobalPosition.Y, target.GlobalPosition.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionY(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.Y,
|
||||
current => target.GlobalPosition = new Vector3(target.GlobalPosition.X, current, target.GlobalPosition.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionZ(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalPosition.Z,
|
||||
current => target.GlobalPosition = new Vector3(target.GlobalPosition.X, target.GlobalPosition.Y, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionXY(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.GlobalPosition.X, target.GlobalPosition.Y),
|
||||
current => target.GlobalPosition = new Vector3(current.X, current.Y, target.GlobalPosition.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionXZ(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.GlobalPosition.X, target.GlobalPosition.Z),
|
||||
current => target.GlobalPosition = new Vector3(current.X, target.GlobalPosition.Y, current.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalPositionYZ(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.GlobalPosition.Y, target.GlobalPosition.Z),
|
||||
current => target.GlobalPosition = new Vector3(target.GlobalPosition.X, current.X, current.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPosition(this Node3D target, Vector3 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Position,
|
||||
current => target.Position = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionX(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.X,
|
||||
current => target.Position = new Vector3(current, target.Position.Y, target.Position.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionY(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.Y,
|
||||
current => target.Position = new Vector3(target.Position.X, current, target.Position.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionZ(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Position.Z,
|
||||
current => target.Position = new Vector3(target.Position.X, target.Position.Y, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionXY(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.Position.X, target.Position.Y),
|
||||
current => target.Position = new Vector3(current.X, current.Y, target.Position.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionXZ(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.Position.X, target.Position.Z),
|
||||
current => target.Position = new Vector3(current.X, target.Position.Y, current.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPositionYZ(this Node3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => new Vector2(target.Position.Y, target.Position.Z),
|
||||
current => target.Position = new Vector3(target.Position.X, current.X, current.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotation(this Node3D target, Vector3 to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalRotation,
|
||||
current => target.GlobalRotation = current,
|
||||
() => AngleExtensions.GetDestinationAngleRadiants(target.GlobalRotation, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationX(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotation.X,
|
||||
current => target.GlobalRotation = new Vector3(current, target.GlobalRotation.Y, target.GlobalRotation.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.GlobalRotation.X, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationY(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotation.Y,
|
||||
current => target.GlobalRotation = new Vector3(target.GlobalRotation.X, current, target.GlobalRotation.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.GlobalRotation.Y, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationZ(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotation.Z,
|
||||
current => target.GlobalRotation = new Vector3(target.GlobalRotation.X, target.GlobalRotation.Y, current),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.GlobalRotation.Z, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotation(this Node3D target, Vector3 to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Rotation,
|
||||
current => target.Rotation = current,
|
||||
() => AngleExtensions.GetDestinationAngleRadiants(target.Rotation, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationX(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Rotation.X,
|
||||
current => target.Rotation = new Vector3(current, target.Rotation.Y, target.Rotation.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.Rotation.X, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationY(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Rotation.Y,
|
||||
current => target.Rotation = new Vector3(target.Rotation.X, current, target.Rotation.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.Rotation.Y, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationZ(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Rotation.Z,
|
||||
current => target.Rotation = new Vector3(target.Rotation.X, target.Rotation.Y, current),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleRadiants(target.Rotation.X, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationDegrees(this Node3D target, Vector3 to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GlobalRotationDegrees,
|
||||
current => target.GlobalRotationDegrees = current,
|
||||
() => AngleExtensions.GetDestinationAngleDegrees(target.GlobalRotationDegrees, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationDegreesX(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotationDegrees.X,
|
||||
current => target.GlobalRotationDegrees = new Vector3(current, target.GlobalRotationDegrees.Y, target.GlobalRotationDegrees.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.GlobalRotationDegrees.X, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationDegreesY(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotationDegrees.Y,
|
||||
current => target.GlobalRotationDegrees = new Vector3(target.GlobalRotationDegrees.X, current, target.GlobalRotationDegrees.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.GlobalRotationDegrees.Y, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenGlobalRotationDegreesZ(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GlobalRotationDegrees.Z,
|
||||
current => target.GlobalRotationDegrees = new Vector3(target.GlobalRotationDegrees.X, target.GlobalRotationDegrees.Y, current),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.GlobalRotationDegrees.Z, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegrees(this Node3D target, Vector3 to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.RotationDegrees,
|
||||
current => target.RotationDegrees = current,
|
||||
() => AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegreesX(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.RotationDegrees.X,
|
||||
current => target.RotationDegrees = new Vector3(current, target.RotationDegrees.Y, target.RotationDegrees.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees.X, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegreesY(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.RotationDegrees.Y,
|
||||
current => target.RotationDegrees = new Vector3(target.RotationDegrees.X, current, target.RotationDegrees.Z),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees.Y, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenRotationDegreesZ(this Node3D target, float to, float duration, RotationMode rotationMode = RotationMode.ShortestDistance)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.RotationDegrees.Z,
|
||||
current => target.RotationDegrees = new Vector3(target.RotationDegrees.X, target.RotationDegrees.Y, current),
|
||||
() => GTweens.Extensions.AngleExtensions.GetDestinationAngleDegrees(target.RotationDegrees.Z, to, rotationMode),
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScale(this Node3D target, Vector3 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Scale,
|
||||
current => target.Scale = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleX(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.X,
|
||||
current => target.Scale = new Vector3(current, target.Scale.Y, target.Scale.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleY(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.Y,
|
||||
current => target.Scale = new Vector3(target.Scale.X, current, target.Scale.Z),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenScaleZ(this Node3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Scale.Z,
|
||||
current => target.Scale = new Vector3(target.Scale.X, target.Scale.Y, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bkfgnrba5v3dx
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class RichTextLabelExtensions
|
||||
{
|
||||
public static GTween TweenDisplayedTextVisibleRatio(this RichTextLabel target, float value, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.VisibleRatio,
|
||||
current => target.VisibleRatio = current,
|
||||
value,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://xxwaq6v8ryyd
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class ShaderMaterialExtensions
|
||||
{
|
||||
public static GTween TweenPropertyInt(this ShaderMaterial target, StringName property, int to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsInt32(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyFloat(this ShaderMaterial target, StringName property, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsSingle(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyVector2(this ShaderMaterial target, StringName property, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsVector2(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyVector2I(this ShaderMaterial target, StringName property, Vector2I to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsVector2I(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColor(this ShaderMaterial target, StringName property, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor(),
|
||||
current => target.SetShaderParameter(property, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColorRgb(this ShaderMaterial target, StringName property, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor(),
|
||||
current => target.SetShaderParameter(
|
||||
property,
|
||||
new Color(current.R, current.G, current.B, target.GetShaderParameter(property).AsColor().A)
|
||||
),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenPropertyColorAlpha(this ShaderMaterial target, StringName property, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.GetShaderParameter(property).AsColor().A,
|
||||
current =>
|
||||
{
|
||||
Color previous = target.GetShaderParameter(property).AsColor();
|
||||
target.SetShaderParameter(property, new Color(previous.R, previous.G, previous.B, current));
|
||||
},
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c365bexkpc7oj
|
||||
41
GTweensGodot/Godot/Source/Extensions/Sprite2DExtensions.cs
Normal file
41
GTweensGodot/Godot/Source/Extensions/Sprite2DExtensions.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class Sprite2DExtensions
|
||||
{
|
||||
public static GTween TweenOffset(this Sprite2D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Offset,
|
||||
current => target.Offset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetX(this Sprite2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.X,
|
||||
current => target.Offset = new Vector2(current, target.Offset.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetY(this Sprite2D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.Y,
|
||||
current => target.Offset = new Vector2(target.Offset.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bo20q0wd8k2pv
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
using Godot;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
|
||||
namespace GTweensGodot.Extensions;
|
||||
|
||||
public static class SpriteBase3DExtensions
|
||||
{
|
||||
public static GTween TweenModulate(this SpriteBase3D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Modulate,
|
||||
current => target.Modulate = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenModulateRgb(this SpriteBase3D target, Color to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Modulate,
|
||||
current => target.Modulate = new Color(current.R, current.G, current.B, target.Modulate.A),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenModulateAlpha(this SpriteBase3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Modulate.A,
|
||||
current => target.Modulate = new Color(target.Modulate.R, target.Modulate.G, target.Modulate.B, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffset(this SpriteBase3D target, Vector2 to, float duration)
|
||||
{
|
||||
return GTweenGodotExtensions.Tween(
|
||||
() => target.Offset,
|
||||
current => target.Offset = current,
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetX(this SpriteBase3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.X,
|
||||
current => target.Offset = new Vector2(current, target.Offset.Y),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
|
||||
public static GTween TweenOffsetY(this SpriteBase3D target, float to, float duration)
|
||||
{
|
||||
return GTweenExtensions.Tween(
|
||||
() => target.Offset.Y,
|
||||
current => target.Offset = new Vector2(target.Offset.X, current),
|
||||
to,
|
||||
duration,
|
||||
GodotObjectExtensions.GetGodotObjectValidationFunction(target)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c14wi0i2utc1e
|
||||
Loading…
Add table
Add a link
Reference in a new issue