Address feedback from @hakusaro about style & documentation
This commit is contained in:
parent
658c714ac5
commit
817dfe26fc
3 changed files with 40 additions and 18 deletions
|
|
@ -323,10 +323,13 @@ namespace TShockAPI.Handlers
|
|||
/// </summary>
|
||||
/// <param name="tile">The tile to update</param>
|
||||
/// <param name="newTile">The NetTile containing the change</param>
|
||||
/// <param name="data">The type of data to merge into world state</param>
|
||||
public static void UpdateServerTileState(ITile tile, NetTile newTile, TileDataType data)
|
||||
/// <param name="updateType">The type of data to merge into world state</param>
|
||||
public static void UpdateServerTileState(ITile tile, NetTile newTile, TileDataType updateType)
|
||||
{
|
||||
if ((data & TileDataType.Tile) != 0)
|
||||
//This logic (updateType & TDT.Tile) != 0 is the way Terraria does it (see: Tile.cs/Clear(TileDataType))
|
||||
//& is not a typo - we're performing a binary AND test to see if a given flag is set.
|
||||
|
||||
if ((updateType & TileDataType.Tile) != 0)
|
||||
{
|
||||
tile.active(newTile.Active);
|
||||
tile.type = newTile.Type;
|
||||
|
|
@ -338,39 +341,40 @@ namespace TShockAPI.Handlers
|
|||
}
|
||||
else if (tile.type != newTile.Type || !tile.active())
|
||||
{
|
||||
//This is vanilla logic - if the tile changed types (or wasn't active) the frame values might not be valid - so we reset them to -1.
|
||||
tile.frameX = -1;
|
||||
tile.frameY = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((data & TileDataType.Wall) != 0)
|
||||
if ((updateType & TileDataType.Wall) != 0)
|
||||
{
|
||||
tile.wall = newTile.Wall;
|
||||
}
|
||||
|
||||
if ((data & TileDataType.TilePaint) != 0)
|
||||
if ((updateType & TileDataType.TilePaint) != 0)
|
||||
{
|
||||
tile.color(newTile.TileColor);
|
||||
}
|
||||
|
||||
if((data & TileDataType.WallPaint) != 0)
|
||||
if ((updateType & TileDataType.WallPaint) != 0)
|
||||
{
|
||||
tile.wallColor(newTile.WallColor);
|
||||
}
|
||||
|
||||
if((data & TileDataType.Liquid) != 0)
|
||||
if ((updateType & TileDataType.Liquid) != 0)
|
||||
{
|
||||
tile.liquid = newTile.Liquid;
|
||||
tile.liquidType(newTile.LiquidType);
|
||||
}
|
||||
|
||||
if((data & TileDataType.Slope) != 0)
|
||||
if ((updateType & TileDataType.Slope) != 0)
|
||||
{
|
||||
tile.halfBrick(newTile.IsHalf);
|
||||
tile.slope((byte)((newTile.Slope ? 1 : 0) + (newTile.Slope2 ? 2 : 0) + (newTile.Slope3 ? 4 : 0)));
|
||||
tile.slope(newTile.Slope);
|
||||
}
|
||||
|
||||
if((data & TileDataType.Wiring) != 0)
|
||||
if ((updateType & TileDataType.Wiring) != 0)
|
||||
{
|
||||
tile.wire(newTile.Wire);
|
||||
tile.wire2(newTile.Wire2);
|
||||
|
|
@ -378,7 +382,7 @@ namespace TShockAPI.Handlers
|
|||
tile.wire4(newTile.Wire4);
|
||||
}
|
||||
|
||||
if((data & TileDataType.Actuator) != 0)
|
||||
if ((updateType & TileDataType.Actuator) != 0)
|
||||
{
|
||||
tile.actuator(newTile.IsActuator);
|
||||
tile.inActive(newTile.Inactive);
|
||||
|
|
|
|||
|
|
@ -42,10 +42,29 @@ namespace TShockAPI.Net
|
|||
public bool IsActuator { get; set; }
|
||||
public byte TileColor { get; set; }
|
||||
public byte WallColor { get; set; }
|
||||
public bool Slope { get; set; }
|
||||
public bool Slope1 { get; set; }
|
||||
public bool Slope2 { get; set; }
|
||||
public bool Slope3 { get; set; }
|
||||
|
||||
public byte Slope
|
||||
{
|
||||
get
|
||||
{
|
||||
byte sl = 0;
|
||||
|
||||
if (Slope1)
|
||||
sl += 1;
|
||||
|
||||
if (Slope2)
|
||||
sl += 2;
|
||||
|
||||
if (Slope3)
|
||||
sl += 4;
|
||||
|
||||
return sl;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasColor
|
||||
{
|
||||
get { return TileColor > 0; }
|
||||
|
|
@ -87,8 +106,9 @@ namespace TShockAPI.Net
|
|||
TileColor = 0;
|
||||
WallColor = 0;
|
||||
Lighted = false;
|
||||
Slope = false;
|
||||
Slope1 = false;
|
||||
Slope2 = false;
|
||||
Slope3 = false;
|
||||
}
|
||||
|
||||
public NetTile(Stream stream)
|
||||
|
|
@ -120,9 +140,7 @@ namespace TShockAPI.Net
|
|||
bits[6] = true;
|
||||
|
||||
if (Inactive)
|
||||
{
|
||||
bits[7] = true;
|
||||
}
|
||||
|
||||
stream.WriteInt8((byte) bits);
|
||||
|
||||
|
|
@ -140,7 +158,7 @@ namespace TShockAPI.Net
|
|||
if (HasWallColor)
|
||||
bits[3] = true;
|
||||
|
||||
if (Slope)
|
||||
if (Slope1)
|
||||
bits[4] = true;
|
||||
|
||||
if (Slope2)
|
||||
|
|
@ -191,7 +209,7 @@ namespace TShockAPI.Net
|
|||
|
||||
Wire2 = flags2[0];
|
||||
Wire3 = flags2[1];
|
||||
Slope = flags2[4];
|
||||
Slope1 = flags2[4];
|
||||
Slope2 = flags2[5];
|
||||
Slope3 = flags2[6];
|
||||
Wire4 = flags2[7];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue