using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Graphics { /// /// Manager class that handles all created instances of /// [Obsolete("ManagedRenderTarget is obsolete; developers should use RenderTarget2Ds and RenderTargetLeases")] public class RenderTargetManager : ModSystem { public delegate void RenderTargetUpdateDelegate(); /// /// Use this event to update/draw things to the target before anything else is drawn to the game. /// public static event RenderTargetUpdateDelegate RenderTargetUpdateLoopEvent; /// /// How many frames should pass since a target was last accessed before automatically disposing of it. /// public const int TimeBeforeAutoDispose = 600; public override void OnModLoad() { Main.OnPreDraw += HandleTargetUpdateLoop; } public override void OnModUnload() { Main.OnPreDraw -= HandleTargetUpdateLoop; RenderTargetUpdateLoopEvent = null; } private void HandleTargetUpdateLoop(GameTime obj) { RenderTargetUpdateLoopEvent?.Invoke(); } } }