* - Added ManagedRenderTarget to better handle RenderTarget2Ds. - Added a Graphics folder that contains the above. - Made all existing RenderTarget2Ds use the above instead. - Removed some old/reduntant loading code for metaballs. - Moved PrimitiveTrail to the new Graphics folder. * - Manually unload the event, as afaik TMod will not do this. * - Added a drawer system, for making doing more advanced visual effects easier. - Moved miracle blight's shader effect to use this instead of the old method. - Ares Body is now vulnerable to miracle blight again, as the visual effect is disabled seperately.
72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
namespace CalamityMod.Graphics.Drawers
|
|
{
|
|
/// <summary>
|
|
/// A class to handle drawing a visual effect to a rendertarget, then drawing the target to the screen at selected layer.
|
|
/// </summary>
|
|
public abstract class BaseDrawer
|
|
{
|
|
#region Fields/Properties
|
|
/// <summary>
|
|
/// The layer that the target should be drawn at.
|
|
/// </summary>
|
|
public abstract DrawerLayer Layer { get; }
|
|
|
|
/// <summary>
|
|
/// Whether the target should draw and be drawn to this frame.
|
|
/// </summary>
|
|
public abstract bool ShouldDraw { get; }
|
|
|
|
/// <summary>
|
|
/// The target that the visual is drawn to. Automatically handled.
|
|
/// </summary>
|
|
public ManagedRenderTarget MainTarget
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
public void Load()
|
|
{
|
|
MainTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget);
|
|
OnLoad();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called on mod load.
|
|
/// </summary>
|
|
public virtual void OnLoad()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called on mod unload.
|
|
/// </summary>
|
|
public virtual void OnUnload()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Draw whatever needed to the target here.
|
|
/// </summary>
|
|
/// <param name="spriteBatch"></param>
|
|
public abstract void DrawToTarget(SpriteBatch spriteBatch);
|
|
|
|
/// <summary>
|
|
/// Draw the target here. By default, just draws the target.
|
|
/// </summary>
|
|
/// <param name="spriteBatch"></param>
|
|
public virtual void DrawTarget(SpriteBatch spriteBatch)
|
|
{
|
|
spriteBatch.Draw(MainTarget, Vector2.Zero, Color.White);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|