rj-action-library/Runtime/Godot/NodeState.cs

74 lines
1.5 KiB
C#

using Godot;
using System.Collections.Generic;
using System;
namespace Rokojori
{
public class NodeState
{
public static void Configure( Node n, bool processEnabled, bool inputEnabled, bool physicsEnabled, bool signalsEnabled,
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, enabled );
}
public static void Set( Node[] nodes, bool enabled )
{
Arrays.ForEach( nodes, n => Set( n, enabled ) );
}
public static void Enable( Node n )
{
Set( n, true );
}
public static void Enable( params Node[] n )
{
Set( n, true );
}
public static void Disable( Node n )
{
Set( n, false );
}
public static void Disable( params Node[] n )
{
Set( n, false );
}
}
}