-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructify.cs
More file actions
57 lines (49 loc) · 1.77 KB
/
Structify.cs
File metadata and controls
57 lines (49 loc) · 1.77 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
global using Microsoft.Xna.Framework;
global using Terraria;
global using Terraria.ID;
global using Terraria.DataStructures;
global using Terraria.ModLoader;
global using Terraria.ObjectData;
global using Terraria.ModLoader.Config;
global using System;
global using System.Collections.Generic;
global using System.ComponentModel;
global using System.Linq;
using Structify.Content.Items;
using System.IO;
namespace Structify;
public class Structify : Mod
{
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
MessageType msgType = (MessageType)reader.ReadByte();
switch (msgType)
{
case MessageType.SpawnHellavator:
short x = reader.ReadInt16();
short y = reader.ReadInt16();
Point16 mPos = new(x, y);
// Only the server should build the hellavator
if (Main.netMode == NetmodeID.Server)
{
Hellavator.BuildHellavator(mPos);
// Now broadcast updated tiles back to all clients in slices
int xStart = mPos.X - 4;
int width = 8;
int worldHeight = Main.maxTilesY;
for (int tileY = mPos.Y; tileY < worldHeight; tileY += 100)
{
int slice = Math.Min(100, worldHeight - tileY);
NetMessage.SendTileSquare(
whoAmi: -1, // -1 = broadcast to everyone
tileX: xStart,
tileY: tileY,
xSize: width,
ySize: slice
);
}
}
break;
}
}
}