-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathShaderLibMod.cs
executable file
·61 lines (48 loc) · 1.59 KB
/
ShaderLibMod.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
using System.Collections.Generic;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;
using ShaderLib.System;
namespace ShaderLib
{
public class ShaderLibMod : Mod
{
public static ShaderLibMod instance;
//These store the vanilla shader lists, so that they can be reset when the mod is unloaded.
private List<ArmorShaderData> vanillaShaders;
private Dictionary<int, int> vanillaBindings;
/// <summary>
/// The highest shader ID in the vanilla game.
/// </summary>
public const short maxVanillaID = 116;
//Provides easy access to this object now needed instead of pixelShader directly.
public static Ref<Effect> shaderRef;
public ShaderLibMod() {
Properties = new ModProperties() {
Autoload = true,
};
}
public override void Load() {
Logger.InfoFormat("{0}: ", Name);
shaderRef = new Ref<Effect>(Main.pixelShader);
//Save the state of the vanilla shader listings.
vanillaShaders = new List<ArmorShaderData>(ShaderReflections.GetShaderList());
vanillaBindings = new Dictionary<int, int>(ShaderReflections.GetShaderBindings());
ShaderLoader.RegisterMod(this);
instance = this;
}
public override void PostSetupContent() {
ShaderLoader.SetupContent();
}
public override void Unload() {
//Reset the shader listings to the vanilla state.
ShaderReflections.SetShaderList(vanillaShaders);
ShaderReflections.SetShaderBindings(vanillaBindings);
ShaderReflections.SetShaderCount(vanillaShaders.Count);
instance = null;
shaderRef = null;
ShaderLoader.Unload();
}
}
}