-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.cs
40 lines (32 loc) · 1.11 KB
/
API.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
using System;
using Terraria;
namespace MotionBlurs {
public static class MotionBlursAPI {
public static void BeginCustomEntityBlur( Entity ent, Func<Entity, int> intensityFunc ) {
if( ent is NPC ) {
var npcInfo = ((NPC)ent).GetGlobalNPC<MotionBlursNpc>();
if( npcInfo == null ) { return; }
npcInfo.Fx.SetCustomIntensity( intensityFunc );
} else if( ent is Projectile ) {
var projInfo = ((Projectile)ent).GetGlobalProjectile<MyProjectile>();
if( projInfo == null ) { return; }
projInfo.Fx.SetCustomIntensity( intensityFunc );
} else {
throw new Exception( "Invalid entity type." );
}
}
public static void EndCustomEntityBlur( Entity ent ) {
if( ent is NPC ) {
var npcInfo = ((NPC)ent).GetGlobalNPC<MotionBlursNpc>();
if( npcInfo == null ) { return; }
npcInfo.Fx.SetCustomIntensity( null );
} else if( ent is Projectile ) {
var projInfo = ((Projectile)ent).GetGlobalProjectile<MyProjectile>();
if( projInfo == null ) { return; }
projInfo.Fx.SetCustomIntensity( null );
} else {
throw new Exception( "Invalid entity type." );
}
}
}
}