-
Notifications
You must be signed in to change notification settings - Fork 0
/
DartGunsPlus.cs
50 lines (44 loc) · 1.81 KB
/
DartGunsPlus.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
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Graphics.Effects;
using Terraria.Graphics.Shaders;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Core;
namespace DartGunsPlus;
public class DartGunsPlus : Mod
{
public override void Load()
{
if (!Main.dedServ)
if (Main.netMode != NetmodeID.Server)
{
MethodInfo info = typeof(Mod).GetProperty("File", BindingFlags.NonPublic | BindingFlags.Instance)?.GetGetMethod(true);
if (info != null)
{
TmodFile file = (TmodFile)info.Invoke(ModContent.GetInstance<DartGunsPlus>(), null);
if (file != null)
{
IEnumerable<TmodFile.FileEntry> shaders = file.Where(n => n.Name.StartsWith("DartGunsPlus/Content/Effects/") &&
n.Name.EndsWith(".xnb"));
foreach (TmodFile.FileEntry entry in shaders)
{
string name = entry.Name.Replace(".xnb", "").Replace("DartGunsPlus/Content/Effects/", "");
string path = entry.Name.Replace(".xnb", "");
LoadShader(name, path);
}
}
}
}
}
private static void LoadShader(string name, string path)
{
var screenRef = new Ref<Effect>(ModContent.Request<Effect>(path, AssetRequestMode.ImmediateLoad).Value);
Filters.Scene[name] = new Filter(new ScreenShaderData(screenRef, name + "Pass"), EffectPriority.High);
Filters.Scene[name].Load();
}
}