-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Megghy/main
fix NetTeleportPylonModule, complete NetLiquidModule
- Loading branch information
Showing
7 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TrProtocol.Models | ||
{ | ||
public struct LiquidChange | ||
{ | ||
public ShortPosition Position { get; set; } | ||
public byte LiquidAmount { get; set; } | ||
public LiquidType LiquidType { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TrProtocol.Models | ||
{ | ||
public partial struct LiquidData | ||
{ | ||
public ushort TotalChanges { get; set; } | ||
public LiquidChange[] LiquidChanges { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TrProtocol.Serializers; | ||
|
||
namespace TrProtocol.Models | ||
{ | ||
[Serializer(typeof(ByteEnumSerializer<LiquidType>))] | ||
public enum LiquidType : byte | ||
{ | ||
Water = 1, | ||
Lava = 2, | ||
Honey = 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using TrProtocol.Serializers; | ||
|
||
namespace TrProtocol.Models | ||
{ | ||
[Serializer(typeof(ByteEnumSerializer<PylonPacketType>))] | ||
public enum PylonPacketType : byte | ||
{ | ||
PylonWasAdded, | ||
PylonWasRemoved, | ||
PlayerRequestsTeleport | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Channels; | ||
|
||
namespace TrProtocol.Models | ||
{ | ||
[Serializer(typeof(LiquidDataSerializer))] | ||
public partial struct LiquidData | ||
{ | ||
private class LiquidDataSerializer : FieldSerializer<LiquidData> | ||
{ | ||
protected override LiquidData _Read(BinaryReader br) | ||
{ | ||
var liquid = new LiquidData() | ||
{ | ||
TotalChanges = br.ReadUInt16() | ||
}; | ||
var changes = new LiquidChange[liquid.TotalChanges]; | ||
for (int i = 0; i < liquid.TotalChanges; i++) | ||
{ | ||
changes[i] = new LiquidChange() | ||
{ | ||
Position = new(br.ReadInt16(), br.ReadInt16()), | ||
LiquidAmount = br.ReadByte(), | ||
LiquidType = (LiquidType)br.ReadByte() | ||
}; | ||
} | ||
liquid.LiquidChanges = changes; | ||
return liquid; | ||
} | ||
|
||
protected override void _Write(BinaryWriter bw, LiquidData t) | ||
{ | ||
bw.Write(t.TotalChanges); | ||
foreach (LiquidChange change in t.LiquidChanges) | ||
{ | ||
bw.Write(change.Position.X); | ||
bw.Write(change.Position.Y); | ||
bw.Write(change.LiquidAmount); | ||
bw.Write((byte)change.LiquidType); | ||
} | ||
} | ||
} | ||
} | ||
} |