using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Graphics.Drawers
{
///
/// A class to handle drawing a visual effect to a rendertarget, then drawing the target to the screen at selected layer.
///
public abstract class BaseDrawer
{
#region Fields/Properties
///
/// The layer that the target should be drawn at.
///
public abstract DrawerLayer Layer { get; }
///
/// Whether the target should draw and be drawn to this frame.
///
public abstract bool ShouldDraw { get; }
///
/// The target that the visual is drawn to. Automatically handled.
///
public ManagedRenderTarget MainTarget
{
get;
private set;
}
#endregion
#region Methods
public void Load()
{
MainTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
OnLoad();
}
///
/// Called on mod load.
///
public virtual void OnLoad()
{
}
///
/// Called on mod unload.
///
public virtual void OnUnload()
{
}
///
/// Draw whatever needed to the target here.
///
///
public abstract void DrawToTarget(SpriteBatch spriteBatch);
///
/// Draw the target here. By default, just draws the target.
///
///
public virtual void DrawTarget(SpriteBatch spriteBatch)
{
spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White);
}
#endregion
}
}