Selectors Update
This commit is contained in:
parent
b475d5141a
commit
31f5077b72
|
@ -45,11 +45,20 @@ namespace Rokojori
|
||||||
|
|
||||||
void TriggerOnEnter( Node n )
|
void TriggerOnEnter( Node n )
|
||||||
{
|
{
|
||||||
if ( ! Selector.IsSelecting( selector, n ) )
|
if ( ! Math3D.IsValid( area.GlobalPosition ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! Selector.IsSelecting( selector, n ) )
|
||||||
|
{
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.LogInfo( "Selecting Enter", area.GlobalPosition, HierarchyName.Of( n ), ( (Node3D)n ).GlobalPosition );
|
||||||
Action.Trigger( onEntered );
|
Action.Trigger( onEntered );
|
||||||
|
|
||||||
if ( onInside == null )
|
if ( onInside == null )
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass ]
|
||||||
|
public partial class TweenAudio:SequenceAction, Animator
|
||||||
|
{
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public AudioStreamPlayer3D target;
|
||||||
|
|
||||||
|
[Export(PropertyHint.Range, "-80,80")]
|
||||||
|
public float endVolumeDB;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public bool tweenInLinearAmplitude = true;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public bool changePlayState = true;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public float changingPlayStateTresholdDB = -40f;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public TweenType tweenType = new TweenTimeCurve();
|
||||||
|
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public bool cacheEndVolumeOnStart = true;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public TimeLine timeLine;
|
||||||
|
|
||||||
|
|
||||||
|
public void OnAnimatorStart(){}
|
||||||
|
public void OnAnimatorEnd(){}
|
||||||
|
public void OnAnimatorCancel(){}
|
||||||
|
|
||||||
|
|
||||||
|
public float GetVolume( float volume )
|
||||||
|
{
|
||||||
|
if ( tweenInLinearAmplitude )
|
||||||
|
{
|
||||||
|
return MathAudio.DecibelsToAmplitude( volume );
|
||||||
|
}
|
||||||
|
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float SetVolume( float volume )
|
||||||
|
{
|
||||||
|
if ( tweenInLinearAmplitude )
|
||||||
|
{
|
||||||
|
return MathAudio.AmplitudeToDecibels( volume );
|
||||||
|
}
|
||||||
|
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void _OnTrigger()
|
||||||
|
{
|
||||||
|
if ( target == null )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tl = TimeLineManager.Ensure( timeLine );
|
||||||
|
|
||||||
|
var start = tl.position;
|
||||||
|
|
||||||
|
var fromVolume = GetVolume( target.VolumeDb );
|
||||||
|
var toVolume = GetVolume( endVolumeDB );
|
||||||
|
|
||||||
|
|
||||||
|
var sequenceID = DispatchStart();
|
||||||
|
|
||||||
|
var tweenType = this.tweenType;
|
||||||
|
|
||||||
|
if ( tweenType == null )
|
||||||
|
{
|
||||||
|
tweenType = TweenTimeCurve.defaultCurve;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( changePlayState && toVolume > changingPlayStateTresholdDB )
|
||||||
|
{
|
||||||
|
// this.LogInfo( "Play" );
|
||||||
|
target.Playing = true;
|
||||||
|
target.Play( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationManager.StartAnimation( this, target, AnimationMember.VolumeDB );
|
||||||
|
|
||||||
|
TimeLineManager.ScheduleSpanIn( tl, 0, tweenType.GetTweenDuration(),
|
||||||
|
( span, type )=>
|
||||||
|
{
|
||||||
|
if ( ! AnimationManager.IsAnimating( this, target, AnimationMember.VolumeDB ) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var timeNow = tl.position;
|
||||||
|
var elapsed = timeNow - start;
|
||||||
|
|
||||||
|
var state = tweenType.GetTweenPhaseForPhase( span.phase );
|
||||||
|
|
||||||
|
if ( ! cacheEndVolumeOnStart )
|
||||||
|
{
|
||||||
|
toVolume = GetVolume( endVolumeDB );
|
||||||
|
}
|
||||||
|
|
||||||
|
var lerpedVolume = Mathf.Lerp( fromVolume, toVolume, state );
|
||||||
|
|
||||||
|
target.VolumeDb = SetVolume( lerpedVolume );
|
||||||
|
|
||||||
|
// this.LogInfo( "Volume", lerpedVolume );
|
||||||
|
|
||||||
|
if ( type == TimeLineSpanUpdateType.End )
|
||||||
|
{
|
||||||
|
DispatchEnd( sequenceID );
|
||||||
|
|
||||||
|
AnimationManager.EndAnimation( this, target, AnimationMember.VolumeDB );
|
||||||
|
|
||||||
|
if ( changePlayState && SetVolume( toVolume ) < changingPlayStateTresholdDB )
|
||||||
|
{
|
||||||
|
// this.LogInfo( "Stop" );
|
||||||
|
target.Playing = false;
|
||||||
|
target.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
uid://lowdvkluckpb
|
|
@ -25,6 +25,8 @@ namespace Rokojori
|
||||||
public static readonly AnimationMember Rotation = new AnimationMember( "rotation" );
|
public static readonly AnimationMember Rotation = new AnimationMember( "rotation" );
|
||||||
public static readonly AnimationMember Scale = new AnimationMember( "scale" );
|
public static readonly AnimationMember Scale = new AnimationMember( "scale" );
|
||||||
|
|
||||||
|
public static readonly AnimationMember VolumeDB = new AnimationMember( "volumeDB" );
|
||||||
|
|
||||||
public static readonly AnimationMember[] Transform = new AnimationMember[]
|
public static readonly AnimationMember[] Transform = new AnimationMember[]
|
||||||
{
|
{
|
||||||
AnimationMember.Position, AnimationMember.Rotation, AnimationMember.Scale
|
AnimationMember.Position, AnimationMember.Rotation, AnimationMember.Scale
|
||||||
|
|
|
@ -50,8 +50,8 @@ namespace Rokojori
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[ExportToolButton( "Initialize")]
|
// [ExportToolButton( "Initialize")]
|
||||||
public Callable InitializeButton => Callable.From( Initialize );
|
// public Callable InitializeButton => Callable.From( Initialize );
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,8 +153,6 @@ namespace Rokojori
|
||||||
{
|
{
|
||||||
Trigger( onStoppedMoving );
|
Trigger( onStoppedMoving );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.LogInfo( "Moving:", _moving );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Velocity( smoothedMovement, onFloor );
|
Velocity( smoothedMovement, onFloor );
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Selector.svg")]
|
||||||
|
public partial class FlagSelector:Selector
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public SelectorFlag[] flag;
|
||||||
|
|
||||||
|
public enum FlagMode
|
||||||
|
{
|
||||||
|
Needs_One_Flag,
|
||||||
|
Needs_All_Flags
|
||||||
|
}
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public FlagMode mode = FlagMode.Needs_One_Flag;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
|
||||||
|
public TreeIteratorType iteratorType = TreeIteratorType.DirectChildren;
|
||||||
|
|
||||||
|
public override bool Selects( Node node )
|
||||||
|
{
|
||||||
|
var iterator = TreeIterator<Node>.GetIterator( iteratorType, node, NodesWalker.Get() );
|
||||||
|
|
||||||
|
while ( iterator.HasNext() )
|
||||||
|
{
|
||||||
|
iterator.MoveToNext();
|
||||||
|
|
||||||
|
var it = iterator.Current();
|
||||||
|
|
||||||
|
if ( it is Selectable s )
|
||||||
|
{
|
||||||
|
var numPresent = 0;
|
||||||
|
|
||||||
|
for ( int i = 0; i < flag.Length; i++ )
|
||||||
|
{
|
||||||
|
if ( Array.IndexOf( s.flags, flag[ i ] ) != -1 )
|
||||||
|
{
|
||||||
|
numPresent ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( numPresent == flag.Length || mode == FlagMode.Needs_One_Flag && numPresent > 0 )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
uid://doo8jwdet1hyi
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Rokojori
|
||||||
|
{
|
||||||
|
[Tool]
|
||||||
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Selector.svg")]
|
||||||
|
public partial class Selectable:Node
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public SelectorFlag[] flags;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c5vxa38rgr24k
|
|
@ -19,7 +19,7 @@ namespace Rokojori
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_inputIcons = value;
|
_inputIcons = value;
|
||||||
UpdateInfo();
|
// UpdateInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,10 @@ namespace Rokojori
|
||||||
[Export]
|
[Export]
|
||||||
public DeviceFilter deviceFilter;
|
public DeviceFilter deviceFilter;
|
||||||
|
|
||||||
// public override void _Ready()
|
public override void _Ready()
|
||||||
// {
|
{
|
||||||
// UpdateInfo();
|
UpdateInfo();
|
||||||
// }
|
}
|
||||||
|
|
||||||
void UpdateInfo()
|
void UpdateInfo()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue