-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCensorSystem.cs
More file actions
63 lines (57 loc) · 2.28 KB
/
Copy pathCensorSystem.cs
File metadata and controls
63 lines (57 loc) · 2.28 KB
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
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
namespace TSC
{
public static class CensorLogic
{
public static bool ShouldCensor(Mod mod)
{
if (mod == null) return false;
var config = ModContent.GetInstance<TSCConfig>();
if (config != null && config.CensoredMods != null)
{
if (config.CensoredMods.TryGetValue(mod.Name, out int state) && state > 0)
{
// Censor IF the mod's target rating is stricter (higher) than your currently allowed mode
if (state > (int)config.CurrentSpiceLevel)
{
return true;
}
}
}
return false;
}
}
public class CensorItems : GlobalItem
{
public override bool PreDrawInInventory(Item item, SpriteBatch spriteBatch, Vector2 position, Rectangle frame,
Color drawColor, Color itemColor, Vector2 origin, float scale)
{
if (CensorLogic.ShouldCensor(item.ModItem?.Mod)) return false;
return base.PreDrawInInventory(item, spriteBatch, position, frame, drawColor, itemColor, origin, scale);
}
public override bool PreDrawInWorld(Item item, SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
if (CensorLogic.ShouldCensor(item.ModItem?.Mod)) return false;
return base.PreDrawInWorld(item, spriteBatch, lightColor, alphaColor, ref rotation, ref scale, whoAmI);
}
}
public class CensorNPCs : GlobalNPC
{
public override bool PreDraw(NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
if (CensorLogic.ShouldCensor(npc.ModNPC?.Mod)) return false;
return base.PreDraw(npc, spriteBatch, screenPos, drawColor);
}
}
public class CensorProjectiles : GlobalProjectile
{
public override bool PreDraw(Projectile projectile, ref Color lightColor)
{
if (CensorLogic.ShouldCensor(projectile.ModProjectile?.Mod)) return false;
return base.PreDraw(projectile, ref lightColor);
}
}
}