-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathModArmorShaderData.cs
95 lines (83 loc) · 2.26 KB
/
ModArmorShaderData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;
using ShaderLib.System;
namespace ShaderLib
{
/// <summary>
/// A class designed for the creation of custom shaders.
/// </summary>
public abstract class ModArmorShaderData : ArmorShaderData
{
public Mod Mod { get; internal set; }
public virtual string Name => GetType().Name;
public ShaderID ShaderID { get; internal set; }
public virtual int? BoundItemID => null;
private Color _primary = new Color(Vector3.One);
public Color Primary {
get { return _primary; }
set {
_primary = value;
UseColor(_primary);
}
}
private Color _secondary = new Color(Vector3.One);
public Color Secondary {
get { return _secondary; }
set {
_secondary = value;
UseSecondaryColor(_secondary);
}
}
private float _saturation = 1f;
public float Saturation {
get { return _saturation; }
set {
_saturation = value;
UseSaturation(_saturation);
}
}
private float _opacity = 1f;
public float Opacity {
get { return _opacity; }
set {
_opacity = value;
UseOpacity(_opacity);
}
}
public string PassName {
get { return _passName; }
set {
_passName = value;
SwapProgram(_passName);
}
}
public new Effect Shader {
get { return _shader != null ? _shader.Value : null; }
set { _shader = new Ref<Effect>(value != null ? value : null); }
}
public Texture2D Image {
get { return ShaderReflections.GetImage(this).Value; }
set { ShaderReflections.SetImage(this, new Ref<Texture2D>(value)); }
}
/// <summary>
/// Override this to change whether this shader autoloads.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public virtual bool Autoload() => true;
/// <summary>
/// Called before the shader is applied.
/// Use this to change the shader's various properties or provide other effects.
/// </summary>
public virtual void PreApply(Entity e, DrawData? drawData) { }
public ModArmorShaderData() : base(ShaderLibMod.shaderRef, "ArmorColored") { }
public override void Apply(Entity e, DrawData? drawData) {
PreApply(e, drawData);
base.Apply(e, drawData);
}
}
}