-
Notifications
You must be signed in to change notification settings - Fork 0
/
BSODMod.cs
62 lines (57 loc) · 1.45 KB
/
BSODMod.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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using Terraria;
using Terraria.ModLoader;
using Terraria.UI;
namespace BSODMod
{
public class BsodMod : Mod
{
private Texture2D BSODTEX;
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
int inventoryIndex = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Interface Logic 4"));
if (inventoryIndex != -1)
{
layers.Insert(inventoryIndex, new LegacyGameInterfaceLayer(
"BSOD: CrashScreen",
delegate
{
if (Main.LocalPlayer.GetModPlayer<MyPlayer>().playerDied)
{
Color color = Color.Blue;
Texture2D tex = this.BSODTEX;
Rectangle sourceRectangle = new Rectangle(
x: 0,
y: 0,
width: tex.Width,
height: tex.Height
);
Main.spriteBatch.Draw(
texture: tex,
destinationRectangle: new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4),
sourceRectangle: sourceRectangle,
color: Color.White,
rotation: default,
origin: default,
effects: SpriteEffects.None,
layerDepth: 1f
);
}
return true;
},
InterfaceScaleType.Game)
);
}
base.ModifyInterfaceLayers(layers);
}
public override void PostSetupContent()
{
if (!Main.dedServ && Main.netMode != 2)
{
this.BSODTEX = this.GetTexture("fakebsod");
}
}
}
}