using Godot; using System.Collections.Generic; using System; using System.Linq; namespace Rokojori { public interface IPostProcessEffectProcessor { public void ClearForStackUpdate(); public void OnVolumeUpdate( PostProcessVolume volume, List allEffects ); public void Apply( WorldEnvironment worldEnvironment ); } public class PostProcessEffectProcessor:IPostProcessEffectProcessor where T:PostProcessVolumeEffect, new() { public T combinedEffect = new T(); public List activeEffects = []; public List activeVolumes = []; public void ClearForStackUpdate() { activeEffects.Clear(); activeVolumes.Clear(); } public void OnVolumeUpdate( PostProcessVolume volume, List allEffects ) { var glows = GetEffectType( allEffects ); activeEffects.AddRange( glows ); glows.ForEach( g => activeVolumes.Add( volume ) ); } List GetEffectType( List effects ) where T:PostProcessVolumeEffect { return effects.FilterType(); } public void Apply( WorldEnvironment worldEnvironment ) { combinedEffect.Lerp( activeEffects, activeVolumes ); combinedEffect.Apply( worldEnvironment ); } } }