2025-11-28 14:27:39 +00:00
|
|
|
using Godot;
|
|
|
|
|
using Rokojori;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
[Tool, GlobalClass]
|
|
|
|
|
public partial class PostProcessingHack : Action
|
|
|
|
|
{
|
|
|
|
|
[Export]
|
|
|
|
|
public WorldEnvironment environment;
|
|
|
|
|
|
|
|
|
|
protected override void _OnTrigger()
|
|
|
|
|
{
|
2025-12-21 18:58:19 +00:00
|
|
|
ApplyHack();
|
|
|
|
|
}
|
2025-11-28 14:27:39 +00:00
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
void ApplyHack()
|
|
|
|
|
{
|
2025-11-28 14:27:39 +00:00
|
|
|
var godotArray = new Godot.Collections.Array<CompositorEffect>();
|
2025-12-21 18:58:19 +00:00
|
|
|
var compositorEffects = environment.Compositor.CompositorEffects;
|
2025-11-28 14:27:39 +00:00
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
for ( int i = 0; i < compositorEffects.Count; i++ )
|
2025-11-28 14:27:39 +00:00
|
|
|
{
|
2025-12-25 17:21:27 +00:00
|
|
|
if ( compositorEffects[ i ] == null )
|
|
|
|
|
{
|
|
|
|
|
godotArray.Add( null );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2025-11-28 14:27:39 +00:00
|
|
|
godotArray.Add( (CompositorEffect) compositorEffects[ i ].Duplicate() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
environment.Compositor.CompositorEffects = godotArray;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
#if TOOLS
|
|
|
|
|
int retriggerFramesCount = 60 * 5;
|
|
|
|
|
int framesCounter = 0;
|
|
|
|
|
|
|
|
|
|
public override void _Process( double delta )
|
|
|
|
|
{
|
|
|
|
|
if ( ! Engine.IsEditorHint() )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-25 17:21:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
framesCounter --;
|
|
|
|
|
|
|
|
|
|
if ( framesCounter > 0 )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-12-25 17:21:27 +00:00
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
framesCounter = retriggerFramesCount;
|
|
|
|
|
|
2025-12-25 17:21:27 +00:00
|
|
|
var selection = EditorInterface.Singleton.GetSelection();
|
|
|
|
|
var topSelected = selection.GetTopSelectedNodes();
|
|
|
|
|
|
|
|
|
|
if ( topSelected.Contains( environment ) )
|
|
|
|
|
{
|
|
|
|
|
// RJLog.Log( "Environment selected, not applying Post Processing Hack" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-21 18:58:19 +00:00
|
|
|
// RJLog.Log( "Applying Post Processing Hack" );
|
|
|
|
|
ApplyHack();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2025-11-28 14:27:39 +00:00
|
|
|
}
|