Polished Nodes/NodeStates

This commit is contained in:
Josef 2024-08-04 18:57:47 +02:00
parent c2c548ae04
commit a53865f099
8 changed files with 107 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cj3w71yd4boe"
path="res://.godot/imported/rokojori-action-library-splash.png-d751c80b8a8a96ee0087afb0bd27552e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Scripts/Rokojori/Rokojori-Action-Library/Assets/Splash/rokojori-action-library-splash.png"
dest_files=["res://.godot/imported/rokojori-action-library-splash.png-d751c80b8a8a96ee0087afb0bd27552e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -33,5 +33,21 @@ namespace Rokojori
Nodes.ForEachDirectChild<RJAction>( target, a => Actions.Trigger( a ) );
}
public static void TriggerAll( RJAction action, Node target, bool triggerDirectChildren )
{
if ( action != null )
{
Actions.Trigger( action );
}
if ( ! triggerDirectChildren )
{
return;
}
Nodes.ForEachDirectChild<RJAction>( target, a => Actions.Trigger( a ) );
}
}
}

View File

@ -7,13 +7,17 @@ namespace Rokojori
[GlobalClass, Icon("res://Scripts/Rokojori/Rokojori-Action-Library/Icons/RJOnEvent.svg") ]
public partial class OnPhysicsProcess : Node
{
/** <summary for="field actions">Actions to execute</summary>*/
[Export]
public RJAction action;
public RJAction[] actions;
/** <summary for="field triggerDirectChildren">Whether to execute RJAction child nodes</summary>*/
[Export]
public bool triggerDirectChildren = true;
public override void _PhysicsProcess( double delta )
{
// RJLog.Log( "OnReady" );
Actions.Trigger( action );
Actions.TriggerAll( actions, this, triggerDirectChildren );
}
}
}

View File

@ -7,13 +7,17 @@ namespace Rokojori
[GlobalClass, Icon("res://Scripts/Rokojori/Rokojori-Action-Library/Icons/RJOnEvent.svg") ]
public partial class OnReady : Node
{
/** <summary for="field actions">Actions to execute</summary>*/
[Export]
public RJAction action;
public RJAction[] actions;
/** <summary for="field triggerDirectChildren">Whether to execute RJAction child nodes</summary>*/
[Export]
public bool triggerDirectChildren = true;
public override void _Ready()
{
// RJLog.Log( "OnReady" );
Actions.Trigger( action );
Actions.TriggerAll( actions, this, triggerDirectChildren );
}
}
}

View File

@ -8,19 +8,41 @@ namespace Rokojori
public class NodeState
{
public static void Configure( Node n, bool processEnabled, bool inputEnabled, bool physicsEnabled, bool signalsEnabled,
Node.ProcessModeEnum processMode )
Node.ProcessModeEnum processMode, bool visible )
{
if ( n == null )
{
return;
}
n.SetProcess( processEnabled );
n.SetProcessInput( inputEnabled );
n.SetPhysicsProcess( physicsEnabled );
n.SetBlockSignals( ! signalsEnabled );
n.ProcessMode = processMode;
if ( n is Node3D )
{
( n as Node3D ).Visible = visible;
}
if ( n is Node2D )
{
( n as Node2D ).Visible = visible;
}
if ( n is CanvasItem )
{
( n as CanvasItem ).Visible = visible;
}
}
public static void Set( Node n, bool enabled )
{
Configure( n, enabled, enabled, enabled, enabled, enabled ? Node.ProcessModeEnum.Inherit : Node.ProcessModeEnum.Disabled );
Configure( n, enabled, enabled, enabled, enabled, enabled ? Node.ProcessModeEnum.Inherit : Node.ProcessModeEnum.Disabled, enabled );
}
public static void Set( Node[] nodes, bool enabled )
@ -33,14 +55,19 @@ namespace Rokojori
Set( n, true );
}
public static void Enable( Node[] n )
public static void Enable( params Node[] n )
{
Set( n, true );
}
public static void Disable( Node n )
{
Set( n, true );
Set( n, false );
}
public static void Disable( params Node[] n )
{
Set( n, false );
}
}

View File

@ -69,6 +69,12 @@ namespace Rokojori
return default(T);
}
public static void ForEachInScene<T>( Action<T> callback ) where T:class
{
var root = Root.Get().GetWindow();
ForEach<T>( root, callback );
}
public static void ForEach<T>( Node root, Action<T> callback ) where T:class
{
var walker = nodesWalker;

View File

@ -19,6 +19,11 @@ namespace Rokojori
return list;
}
public static List<T> From<T>( params T[] elements )
{
return ToList( elements );
}
public static List<T> ToList<T>( T[] array )
{
var list = new List<T>();
@ -123,12 +128,6 @@ namespace Rokojori
return sb.ToString();
}
public static List<T> From<T>( T[] array )
{
var copy = new List<T>();
copy.AddRange( array );
return copy;
}
public static List<T> From<T>( List<T> list )
{