Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
37
GameContent/NetModules/NetAmbienceModule.cs
Normal file
37
GameContent/NetModules/NetAmbienceModule.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetAmbienceModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Terraria.GameContent.Ambience;
|
||||
using Terraria.GameContent.Skies;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetAmbienceModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializeSkyEntitySpawn(Player player, SkyEntityType type)
|
||||
{
|
||||
int num = Main.rand.Next();
|
||||
NetPacket packet = NetModule.CreatePacket<NetAmbienceModule>(6);
|
||||
packet.Writer.Write((byte) player.whoAmI);
|
||||
packet.Writer.Write(num);
|
||||
packet.Writer.Write((byte) type);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
byte playerId = reader.ReadByte();
|
||||
int seed = reader.ReadInt32();
|
||||
SkyEntityType type = (SkyEntityType) reader.ReadByte();
|
||||
Main.QueueMainThreadAction((Action) (() => ((AmbientSky) SkyManager.Instance["Ambience"]).Spawn(Main.player[(int) playerId], type, seed)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
71
GameContent/NetModules/NetBestiaryModule.cs
Normal file
71
GameContent/NetModules/NetBestiaryModule.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetBestiaryModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.ID;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetBestiaryModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializeKillCount(int npcNetId, int killcount)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetBestiaryModule>(5);
|
||||
packet.Writer.Write((byte) 0);
|
||||
packet.Writer.Write((short) npcNetId);
|
||||
packet.Writer.Write((ushort) killcount);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeSight(int npcNetId)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetBestiaryModule>(3);
|
||||
packet.Writer.Write((byte) 1);
|
||||
packet.Writer.Write((short) npcNetId);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeChat(int npcNetId)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetBestiaryModule>(3);
|
||||
packet.Writer.Write((byte) 2);
|
||||
packet.Writer.Write((short) npcNetId);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
switch (reader.ReadByte())
|
||||
{
|
||||
case 0:
|
||||
short num1 = reader.ReadInt16();
|
||||
string bestiaryCreditId1 = ContentSamples.NpcsByNetId[(int) num1].GetBestiaryCreditId();
|
||||
ushort num2 = reader.ReadUInt16();
|
||||
Main.BestiaryTracker.Kills.SetKillCountDirectly(bestiaryCreditId1, (int) num2);
|
||||
break;
|
||||
case 1:
|
||||
short num3 = reader.ReadInt16();
|
||||
string bestiaryCreditId2 = ContentSamples.NpcsByNetId[(int) num3].GetBestiaryCreditId();
|
||||
Main.BestiaryTracker.Sights.SetWasSeenDirectly(bestiaryCreditId2);
|
||||
break;
|
||||
case 2:
|
||||
short num4 = reader.ReadInt16();
|
||||
string bestiaryCreditId3 = ContentSamples.NpcsByNetId[(int) num4].GetBestiaryCreditId();
|
||||
Main.BestiaryTracker.Chats.SetWasChatWithDirectly(bestiaryCreditId3);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private enum BestiaryUnlockType : byte
|
||||
{
|
||||
Kill,
|
||||
Sight,
|
||||
Chat,
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/NetModules/NetCreativePowerPermissionsModule.cs
Normal file
40
GameContent/NetModules/NetCreativePowerPermissionsModule.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetCreativePowerPermissionsModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetCreativePowerPermissionsModule : NetModule
|
||||
{
|
||||
private const byte _setPermissionLevelId = 0;
|
||||
|
||||
public static NetPacket SerializeCurrentPowerPermissionLevel(ushort powerId, int level)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetCreativePowerPermissionsModule>(4);
|
||||
packet.Writer.Write((byte) 0);
|
||||
packet.Writer.Write(powerId);
|
||||
packet.Writer.Write((byte) level);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
if (reader.ReadByte() == (byte) 0)
|
||||
{
|
||||
ushort id = reader.ReadUInt16();
|
||||
int num = (int) reader.ReadByte();
|
||||
ICreativePower power;
|
||||
if (Main.netMode == 2 || !CreativePowerManager.Instance.TryGetPower(id, out power))
|
||||
return false;
|
||||
power.CurrentPermissionLevel = (PowerPermissionLevel) num;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
34
GameContent/NetModules/NetCreativePowersModule.cs
Normal file
34
GameContent/NetModules/NetCreativePowersModule.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetCreativePowersModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.GameContent.Creative;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetCreativePowersModule : NetModule
|
||||
{
|
||||
public static NetPacket PreparePacket(
|
||||
ushort powerId,
|
||||
int specificInfoBytesInPacketCount)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetCreativePowersModule>(specificInfoBytesInPacketCount + 2);
|
||||
packet.Writer.Write(powerId);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
ushort id = reader.ReadUInt16();
|
||||
ICreativePower power;
|
||||
if (!CreativePowerManager.Instance.TryGetPower(id, out power))
|
||||
return false;
|
||||
power.DeserializeNetMessage(reader, userId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
30
GameContent/NetModules/NetCreativeUnlocksModule.cs
Normal file
30
GameContent/NetModules/NetCreativeUnlocksModule.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetCreativeUnlocksModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.ID;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetCreativeUnlocksModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializeItemSacrifice(int itemId, int sacrificeCount)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetCreativeUnlocksModule>(3);
|
||||
packet.Writer.Write((short) itemId);
|
||||
packet.Writer.Write((ushort) sacrificeCount);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
short num = reader.ReadInt16();
|
||||
Main.LocalPlayerCreativeTracker.ItemSacrifices.SetSacrificeCountDirectly(ContentSamples.ItemPersistentIdsByNetIds[(int) num], (int) reader.ReadUInt16());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetCreativeUnlocksPlayerReportModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetCreativeUnlocksPlayerReportModule : NetModule
|
||||
{
|
||||
private const byte _requestItemSacrificeId = 0;
|
||||
|
||||
public static NetPacket SerializeSacrificeRequest(int itemId, int amount)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetCreativeUnlocksPlayerReportModule>(5);
|
||||
packet.Writer.Write((byte) 0);
|
||||
packet.Writer.Write((ushort) itemId);
|
||||
packet.Writer.Write((ushort) amount);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
if (reader.ReadByte() == (byte) 0)
|
||||
{
|
||||
int num1 = (int) reader.ReadUInt16();
|
||||
int num2 = (int) reader.ReadUInt16();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
140
GameContent/NetModules/NetLiquidModule.cs
Normal file
140
GameContent/NetModules/NetLiquidModule.cs
Normal file
|
@ -0,0 +1,140 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetLiquidModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetLiquidModule : NetModule
|
||||
{
|
||||
private static List<int> _changesForPlayerCache = new List<int>();
|
||||
private static Dictionary<Point, NetLiquidModule.ChunkChanges> _changesByChunkCoords = new Dictionary<Point, NetLiquidModule.ChunkChanges>();
|
||||
|
||||
public static NetPacket Serialize(HashSet<int> changes)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetLiquidModule>(changes.Count * 6 + 2);
|
||||
packet.Writer.Write((ushort) changes.Count);
|
||||
foreach (int change in changes)
|
||||
{
|
||||
int index1 = change >> 16 & (int) ushort.MaxValue;
|
||||
int index2 = change & (int) ushort.MaxValue;
|
||||
packet.Writer.Write(change);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquid);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquidType());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeForPlayer(int playerIndex)
|
||||
{
|
||||
NetLiquidModule._changesForPlayerCache.Clear();
|
||||
foreach (KeyValuePair<Point, NetLiquidModule.ChunkChanges> changesByChunkCoord in NetLiquidModule._changesByChunkCoords)
|
||||
{
|
||||
if (changesByChunkCoord.Value.BroadcastingCondition(playerIndex))
|
||||
NetLiquidModule._changesForPlayerCache.AddRange((IEnumerable<int>) changesByChunkCoord.Value.DirtiedPackedTileCoords);
|
||||
}
|
||||
NetPacket packet = NetModule.CreatePacket<NetLiquidModule>(NetLiquidModule._changesForPlayerCache.Count * 6 + 2);
|
||||
packet.Writer.Write((ushort) NetLiquidModule._changesForPlayerCache.Count);
|
||||
foreach (int num in NetLiquidModule._changesForPlayerCache)
|
||||
{
|
||||
int index1 = num >> 16 & (int) ushort.MaxValue;
|
||||
int index2 = num & (int) ushort.MaxValue;
|
||||
packet.Writer.Write(num);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquid);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquidType());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
int num1 = (int) reader.ReadUInt16();
|
||||
for (int index1 = 0; index1 < num1; ++index1)
|
||||
{
|
||||
int num2 = reader.ReadInt32();
|
||||
byte num3 = reader.ReadByte();
|
||||
byte num4 = reader.ReadByte();
|
||||
int index2 = num2 >> 16 & (int) ushort.MaxValue;
|
||||
int index3 = num2 & (int) ushort.MaxValue;
|
||||
Tile tile = Main.tile[index2, index3];
|
||||
if (tile != null)
|
||||
{
|
||||
tile.liquid = num3;
|
||||
tile.liquidType((int) num4);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void CreateAndBroadcastByChunk(HashSet<int> dirtiedPackedTileCoords)
|
||||
{
|
||||
NetLiquidModule.PrepareChunks(dirtiedPackedTileCoords);
|
||||
NetLiquidModule.PrepareAndSendToEachPlayerSeparately();
|
||||
}
|
||||
|
||||
private static void PrepareAndSendToEachPlayerSeparately()
|
||||
{
|
||||
for (int index = 0; index < 256; ++index)
|
||||
{
|
||||
if (Netplay.Clients[index].IsConnected())
|
||||
NetManager.Instance.SendToClient(NetLiquidModule.SerializeForPlayer(index), index);
|
||||
}
|
||||
}
|
||||
|
||||
private static void BroadcastEachChunkSeparately()
|
||||
{
|
||||
foreach (KeyValuePair<Point, NetLiquidModule.ChunkChanges> changesByChunkCoord in NetLiquidModule._changesByChunkCoords)
|
||||
NetManager.Instance.Broadcast(NetLiquidModule.Serialize(changesByChunkCoord.Value.DirtiedPackedTileCoords), new NetManager.BroadcastCondition(changesByChunkCoord.Value.BroadcastingCondition));
|
||||
}
|
||||
|
||||
private static void PrepareChunks(HashSet<int> dirtiedPackedTileCoords)
|
||||
{
|
||||
foreach (KeyValuePair<Point, NetLiquidModule.ChunkChanges> changesByChunkCoord in NetLiquidModule._changesByChunkCoords)
|
||||
changesByChunkCoord.Value.DirtiedPackedTileCoords.Clear();
|
||||
NetLiquidModule.DistributeChangesIntoChunks(dirtiedPackedTileCoords);
|
||||
}
|
||||
|
||||
private static void BroadcastAllChanges(HashSet<int> dirtiedPackedTileCoords) => NetManager.Instance.Broadcast(NetLiquidModule.Serialize(dirtiedPackedTileCoords));
|
||||
|
||||
private static void DistributeChangesIntoChunks(HashSet<int> dirtiedPackedTileCoords)
|
||||
{
|
||||
foreach (int dirtiedPackedTileCoord in dirtiedPackedTileCoords)
|
||||
{
|
||||
int x = dirtiedPackedTileCoord >> 16 & (int) ushort.MaxValue;
|
||||
int y = dirtiedPackedTileCoord & (int) ushort.MaxValue;
|
||||
Point key;
|
||||
key.X = Netplay.GetSectionX(x);
|
||||
key.Y = Netplay.GetSectionY(y);
|
||||
NetLiquidModule.ChunkChanges chunkChanges;
|
||||
if (!NetLiquidModule._changesByChunkCoords.TryGetValue(key, out chunkChanges))
|
||||
{
|
||||
chunkChanges = new NetLiquidModule.ChunkChanges(key.X, key.Y);
|
||||
NetLiquidModule._changesByChunkCoords[key] = chunkChanges;
|
||||
}
|
||||
chunkChanges.DirtiedPackedTileCoords.Add(dirtiedPackedTileCoord);
|
||||
}
|
||||
}
|
||||
|
||||
private class ChunkChanges
|
||||
{
|
||||
public HashSet<int> DirtiedPackedTileCoords;
|
||||
public int ChunkX;
|
||||
public int ChunkY;
|
||||
|
||||
public ChunkChanges(int x, int y)
|
||||
{
|
||||
this.ChunkX = x;
|
||||
this.ChunkY = y;
|
||||
this.DirtiedPackedTileCoords = new HashSet<int>();
|
||||
}
|
||||
|
||||
public bool BroadcastingCondition(int clientIndex) => Netplay.Clients[clientIndex].TileSections[this.ChunkX, this.ChunkY];
|
||||
}
|
||||
}
|
||||
}
|
37
GameContent/NetModules/NetParticlesModule.cs
Normal file
37
GameContent/NetModules/NetParticlesModule.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetParticlesModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.GameContent.Drawing;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetParticlesModule : NetModule
|
||||
{
|
||||
public static NetPacket Serialize(
|
||||
ParticleOrchestraType particleType,
|
||||
ParticleOrchestraSettings settings)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetParticlesModule>(22);
|
||||
packet.Writer.Write((byte) particleType);
|
||||
settings.Serialize(packet.Writer);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
ParticleOrchestraType particleOrchestraType = (ParticleOrchestraType) reader.ReadByte();
|
||||
ParticleOrchestraSettings settings = new ParticleOrchestraSettings();
|
||||
settings.DeserializeFrom(reader);
|
||||
if (Main.netMode == 2)
|
||||
NetManager.Instance.Broadcast(NetParticlesModule.Serialize(particleOrchestraType, settings), userId);
|
||||
else
|
||||
ParticleOrchestrator.SpawnParticlesDirect(particleOrchestraType, settings);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
29
GameContent/NetModules/NetPingModule.cs
Normal file
29
GameContent/NetModules/NetPingModule.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetPingModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetPingModule : NetModule
|
||||
{
|
||||
public static NetPacket Serialize(Vector2 position)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetPingModule>(8);
|
||||
packet.Writer.WriteVector2(position);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
Vector2 position = reader.ReadVector2();
|
||||
Main.Pings.Add(position);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
73
GameContent/NetModules/NetTeleportPylonModule.cs
Normal file
73
GameContent/NetModules/NetTeleportPylonModule.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetTeleportPylonModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetTeleportPylonModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializePylonWasAddedOrRemoved(
|
||||
TeleportPylonInfo info,
|
||||
NetTeleportPylonModule.SubPacketType packetType)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTeleportPylonModule>(6);
|
||||
packet.Writer.Write((byte) packetType);
|
||||
packet.Writer.Write(info.PositionInTiles.X);
|
||||
packet.Writer.Write(info.PositionInTiles.Y);
|
||||
packet.Writer.Write((byte) info.TypeOfPylon);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeUseRequest(TeleportPylonInfo info)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTeleportPylonModule>(6);
|
||||
packet.Writer.Write((byte) 2);
|
||||
packet.Writer.Write(info.PositionInTiles.X);
|
||||
packet.Writer.Write(info.PositionInTiles.Y);
|
||||
packet.Writer.Write((byte) info.TypeOfPylon);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
switch (reader.ReadByte())
|
||||
{
|
||||
case 0:
|
||||
Main.PylonSystem.AddForClient(new TeleportPylonInfo()
|
||||
{
|
||||
PositionInTiles = new Point16(reader.ReadInt16(), reader.ReadInt16()),
|
||||
TypeOfPylon = (TeleportPylonType) reader.ReadByte()
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
Main.PylonSystem.RemoveForClient(new TeleportPylonInfo()
|
||||
{
|
||||
PositionInTiles = new Point16(reader.ReadInt16(), reader.ReadInt16()),
|
||||
TypeOfPylon = (TeleportPylonType) reader.ReadByte()
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
Main.PylonSystem.HandleTeleportRequest(new TeleportPylonInfo()
|
||||
{
|
||||
PositionInTiles = new Point16(reader.ReadInt16(), reader.ReadInt16()),
|
||||
TypeOfPylon = (TeleportPylonType) reader.ReadByte()
|
||||
}, userId);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum SubPacketType : byte
|
||||
{
|
||||
PylonWasAdded,
|
||||
PylonWasRemoved,
|
||||
PlayerRequestsTeleport,
|
||||
}
|
||||
}
|
||||
}
|
55
GameContent/NetModules/NetTextModule.cs
Normal file
55
GameContent/NetModules/NetTextModule.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetTextModule
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
using Terraria.Chat;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Net;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetTextModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializeClientMessage(ChatMessage message)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTextModule>(message.GetMaxSerializedSize());
|
||||
message.Serialize(packet.Writer);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeServerMessage(NetworkText text, Color color) => NetTextModule.SerializeServerMessage(text, color, byte.MaxValue);
|
||||
|
||||
public static NetPacket SerializeServerMessage(
|
||||
NetworkText text,
|
||||
Color color,
|
||||
byte authorId)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTextModule>(1 + text.GetMaxSerializedSize() + 3);
|
||||
packet.Writer.Write(authorId);
|
||||
text.Serialize(packet.Writer);
|
||||
packet.Writer.WriteRGB(color);
|
||||
return packet;
|
||||
}
|
||||
|
||||
private bool DeserializeAsClient(BinaryReader reader, int senderPlayerId)
|
||||
{
|
||||
byte messageAuthor = reader.ReadByte();
|
||||
ChatHelper.DisplayMessage(NetworkText.Deserialize(reader), reader.ReadRGB(), messageAuthor);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DeserializeAsServer(BinaryReader reader, int senderPlayerId)
|
||||
{
|
||||
ChatMessage message = ChatMessage.Deserialize(reader);
|
||||
ChatManager.Commands.ProcessIncomingMessage(message, senderPlayerId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int senderPlayerId) => this.DeserializeAsClient(reader, senderPlayerId);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue