Selectors Update
This commit is contained in:
parent
b475d5141a
commit
31f5077b72
|
@ -45,11 +45,20 @@ namespace Rokojori
|
|||
|
||||
void TriggerOnEnter( Node n )
|
||||
{
|
||||
if ( ! Selector.IsSelecting( selector, n ) )
|
||||
if ( ! Math3D.IsValid( area.GlobalPosition ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Selector.IsSelecting( selector, n ) )
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
this.LogInfo( "Selecting Enter", area.GlobalPosition, HierarchyName.Of( n ), ( (Node3D)n ).GlobalPosition );
|
||||
Action.Trigger( onEntered );
|
||||
|
||||
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 Scale = new AnimationMember( "scale" );
|
||||
|
||||
public static readonly AnimationMember VolumeDB = new AnimationMember( "volumeDB" );
|
||||
|
||||
public static readonly AnimationMember[] Transform = new AnimationMember[]
|
||||
{
|
||||
AnimationMember.Position, AnimationMember.Rotation, AnimationMember.Scale
|
||||
|
|
|
@ -50,8 +50,8 @@ namespace Rokojori
|
|||
|
||||
|
||||
|
||||
[ExportToolButton( "Initialize")]
|
||||
public Callable InitializeButton => Callable.From( Initialize );
|
||||
// [ExportToolButton( "Initialize")]
|
||||
// public Callable InitializeButton => Callable.From( Initialize );
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
|
|
@ -153,8 +153,6 @@ namespace Rokojori
|
|||
{
|
||||
Trigger( onStoppedMoving );
|
||||
}
|
||||
|
||||
this.LogInfo( "Moving:", _moving );
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
_inputIcons = value;
|
||||
UpdateInfo();
|
||||
// UpdateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,11 @@ namespace Rokojori
|
|||
|
||||
[Export]
|
||||
public DeviceFilter deviceFilter;
|
||||
|
||||
// public override void _Ready()
|
||||
// {
|
||||
// UpdateInfo();
|
||||
// }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UpdateInfo();
|
||||
}
|
||||
|
||||
void UpdateInfo()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue