-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWireModGlobalTile.cs
30 lines (25 loc) · 1018 Bytes
/
WireModGlobalTile.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
using System.Linq;
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria.ModLoader;
using WireMod.Devices;
namespace WireMod
{
internal class WireModGlobalTile : GlobalTile
{
public override bool CanPlace(int i, int j, int type)
{
var protect = WireMod.Devices.Any(d => d is ProtectArea dev && (((TileArea)dev.GetProtectPlaceArea())?.Contains(new Vector2(i, j)) ?? false));
return !protect && base.CanPlace(i, j, type);
}
public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
{
var protect = WireMod.Devices.Any(d => d is ProtectArea dev && (((TileArea)dev.GetProtectDestroyArea())?.Contains(new Vector2(i, j)) ?? false));
return !protect && base.CanKillTile(i, j, type, ref blockDamaged);
}
public override void HitWire(int i, int j, int type)
{
WireMod.GetDevice(i, j)?.OnHitWire(WireMod.GetDevicePin(i, j));
}
}
}