2025-10-24 11:38:51 +00:00
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
2026-05-22 12:25:02 +00:00
|
|
|
using Rokojori.Extensions;
|
2025-10-24 11:38:51 +00:00
|
|
|
namespace Rokojori
|
|
|
|
|
{
|
|
|
|
|
public class AssignedShaderProperty
|
|
|
|
|
{
|
|
|
|
|
public ShaderProperty property;
|
|
|
|
|
public Variant value;
|
|
|
|
|
|
|
|
|
|
public static AssignedShaderProperty From( ShaderProperty sp )
|
|
|
|
|
{
|
|
|
|
|
var asp = new AssignedShaderProperty();
|
|
|
|
|
asp.property = sp;
|
|
|
|
|
return asp;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-25 13:57:25 +00:00
|
|
|
public bool Update( bool showChangeMessage = false )
|
2025-10-24 11:38:51 +00:00
|
|
|
{
|
2026-05-25 13:57:25 +00:00
|
|
|
if ( ! NeedsUpdate() )
|
2025-10-24 11:38:51 +00:00
|
|
|
{
|
2026-05-25 13:57:25 +00:00
|
|
|
return false;
|
2025-10-24 11:38:51 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-25 13:57:25 +00:00
|
|
|
if ( showChangeMessage )
|
|
|
|
|
{
|
|
|
|
|
RJLog.Log( "Update from", value, "to", property.GetValue() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-10-24 11:38:51 +00:00
|
|
|
property.ApplyGlobal();
|
|
|
|
|
value = property.GetValue();
|
|
|
|
|
|
2026-05-25 13:57:25 +00:00
|
|
|
return true;
|
2025-10-24 11:38:51 +00:00
|
|
|
|
2026-05-25 13:57:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NeedsUpdate()
|
|
|
|
|
{
|
|
|
|
|
if ( value.AsGodotObject() is Texture2D tex )
|
|
|
|
|
{
|
|
|
|
|
var pTexture = property.GetValue().AsGodotObject() as Texture2D;
|
|
|
|
|
|
|
|
|
|
var same = tex == pTexture;
|
|
|
|
|
|
|
|
|
|
if ( ! same )
|
|
|
|
|
{
|
|
|
|
|
RJLog.Log( "textures changed:", tex, ">>", pTexture );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ! same;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( value.Equals( property.GetValue() ) )
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2025-10-24 11:38:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|