Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
32
Chat/ChatCommandId.cs
Normal file
32
Chat/ChatCommandId.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.ChatCommandId
|
||||
// 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 ReLogic.Utilities;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Terraria.Chat.Commands;
|
||||
|
||||
namespace Terraria.Chat
|
||||
{
|
||||
public struct ChatCommandId
|
||||
{
|
||||
private readonly string _name;
|
||||
|
||||
private ChatCommandId(string name) => this._name = name;
|
||||
|
||||
public static ChatCommandId FromType<T>() where T : IChatCommand
|
||||
{
|
||||
ChatCommandAttribute cacheableAttribute = AttributeUtilities.GetCacheableAttribute<T, ChatCommandAttribute>();
|
||||
return cacheableAttribute != null ? new ChatCommandId(cacheableAttribute.Name) : new ChatCommandId((string) null);
|
||||
}
|
||||
|
||||
public void Serialize(BinaryWriter writer) => writer.Write(this._name ?? "");
|
||||
|
||||
public static ChatCommandId Deserialize(BinaryReader reader) => new ChatCommandId(reader.ReadString());
|
||||
|
||||
public int GetMaxSerializedSize() => 4 + Encoding.UTF8.GetByteCount(this._name ?? "");
|
||||
}
|
||||
}
|
107
Chat/ChatCommandProcessor.cs
Normal file
107
Chat/ChatCommandProcessor.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.ChatCommandProcessor
|
||||
// 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 ReLogic.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Chat.Commands;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat
|
||||
{
|
||||
public class ChatCommandProcessor : IChatProcessor
|
||||
{
|
||||
private readonly Dictionary<LocalizedText, ChatCommandId> _localizedCommands = new Dictionary<LocalizedText, ChatCommandId>();
|
||||
private readonly Dictionary<ChatCommandId, IChatCommand> _commands = new Dictionary<ChatCommandId, IChatCommand>();
|
||||
private readonly Dictionary<LocalizedText, NetworkText> _aliases = new Dictionary<LocalizedText, NetworkText>();
|
||||
private IChatCommand _defaultCommand;
|
||||
|
||||
public ChatCommandProcessor AddCommand<T>() where T : IChatCommand, new()
|
||||
{
|
||||
string commandKey = "ChatCommand." + AttributeUtilities.GetCacheableAttribute<T, ChatCommandAttribute>().Name;
|
||||
ChatCommandId key1 = ChatCommandId.FromType<T>();
|
||||
this._commands[key1] = (IChatCommand) new T();
|
||||
if (Language.Exists(commandKey))
|
||||
{
|
||||
this._localizedCommands.Add(Language.GetText(commandKey), key1);
|
||||
}
|
||||
else
|
||||
{
|
||||
commandKey += "_";
|
||||
foreach (LocalizedText key2 in Language.FindAll((LanguageSearchFilter) ((key, text) => key.StartsWith(commandKey))))
|
||||
this._localizedCommands.Add(key2, key1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void AddAlias(LocalizedText text, NetworkText result) => this._aliases[text] = result;
|
||||
|
||||
public ChatCommandProcessor AddDefaultCommand<T>() where T : IChatCommand, new()
|
||||
{
|
||||
this.AddCommand<T>();
|
||||
this._defaultCommand = this._commands[ChatCommandId.FromType<T>()];
|
||||
return this;
|
||||
}
|
||||
|
||||
private static bool HasLocalizedCommand(ChatMessage message, LocalizedText command)
|
||||
{
|
||||
string lower = message.Text.ToLower();
|
||||
string str = command.Value;
|
||||
if (!lower.StartsWith(str))
|
||||
return false;
|
||||
return lower.Length == str.Length || lower[str.Length] == ' ';
|
||||
}
|
||||
|
||||
private static string RemoveCommandPrefix(string messageText, LocalizedText command)
|
||||
{
|
||||
string str = command.Value;
|
||||
return !messageText.StartsWith(str) || messageText.Length == str.Length || messageText[str.Length] != ' ' ? "" : messageText.Substring(str.Length + 1);
|
||||
}
|
||||
|
||||
public ChatMessage CreateOutgoingMessage(string text)
|
||||
{
|
||||
ChatMessage message = new ChatMessage(text);
|
||||
KeyValuePair<LocalizedText, ChatCommandId> keyValuePair1 = this._localizedCommands.FirstOrDefault<KeyValuePair<LocalizedText, ChatCommandId>>((Func<KeyValuePair<LocalizedText, ChatCommandId>, bool>) (pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key)));
|
||||
ChatCommandId chatCommandId = keyValuePair1.Value;
|
||||
if (keyValuePair1.Key != null)
|
||||
{
|
||||
message.SetCommand(chatCommandId);
|
||||
message.Text = ChatCommandProcessor.RemoveCommandPrefix(message.Text, keyValuePair1.Key);
|
||||
this._commands[chatCommandId].ProcessOutgoingMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag = false;
|
||||
for (KeyValuePair<LocalizedText, NetworkText> keyValuePair2 = this._aliases.FirstOrDefault<KeyValuePair<LocalizedText, NetworkText>>((Func<KeyValuePair<LocalizedText, NetworkText>, bool>) (pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key))); keyValuePair2.Key != null; keyValuePair2 = this._aliases.FirstOrDefault<KeyValuePair<LocalizedText, NetworkText>>((Func<KeyValuePair<LocalizedText, NetworkText>, bool>) (pair => ChatCommandProcessor.HasLocalizedCommand(message, pair.Key))))
|
||||
{
|
||||
flag = true;
|
||||
message = new ChatMessage(keyValuePair2.Value.ToString());
|
||||
}
|
||||
if (flag)
|
||||
return this.CreateOutgoingMessage(message.Text);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public void ProcessIncomingMessage(ChatMessage message, int clientId)
|
||||
{
|
||||
IChatCommand chatCommand;
|
||||
if (this._commands.TryGetValue(message.CommandId, out chatCommand))
|
||||
{
|
||||
chatCommand.ProcessIncomingMessage(message.Text, (byte) clientId);
|
||||
message.Consume();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._defaultCommand == null)
|
||||
return;
|
||||
this._defaultCommand.ProcessIncomingMessage(message.Text, (byte) clientId);
|
||||
message.Consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
89
Chat/ChatHelper.cs
Normal file
89
Chat/ChatHelper.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.ChatHelper
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.NetModules;
|
||||
using Terraria.GameContent.UI.Chat;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.Chat
|
||||
{
|
||||
public static class ChatHelper
|
||||
{
|
||||
private static List<Tuple<string, Color>> _cachedMessages = new List<Tuple<string, Color>>();
|
||||
|
||||
public static void DisplayMessageOnClient(NetworkText text, Color color, int playerId) => ChatHelper.DisplayMessage(text, color, byte.MaxValue);
|
||||
|
||||
public static void SendChatMessageToClient(NetworkText text, Color color, int playerId) => ChatHelper.SendChatMessageToClientAs(byte.MaxValue, text, color, playerId);
|
||||
|
||||
public static void SendChatMessageToClientAs(
|
||||
byte messageAuthor,
|
||||
NetworkText text,
|
||||
Color color,
|
||||
int playerId)
|
||||
{
|
||||
if (playerId != Main.myPlayer)
|
||||
return;
|
||||
ChatHelper.DisplayMessage(text, color, messageAuthor);
|
||||
}
|
||||
|
||||
public static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer = -1) => ChatHelper.BroadcastChatMessageAs(byte.MaxValue, text, color, excludedPlayer);
|
||||
|
||||
public static void BroadcastChatMessageAs(
|
||||
byte messageAuthor,
|
||||
NetworkText text,
|
||||
Color color,
|
||||
int excludedPlayer = -1)
|
||||
{
|
||||
if (excludedPlayer == Main.myPlayer)
|
||||
return;
|
||||
ChatHelper.DisplayMessage(text, color, messageAuthor);
|
||||
}
|
||||
|
||||
public static bool OnlySendToPlayersWhoAreLoggedIn(int clientIndex) => Netplay.Clients[clientIndex].State == 10;
|
||||
|
||||
public static void SendChatMessageFromClient(ChatMessage message)
|
||||
{
|
||||
if (message.IsConsumed)
|
||||
return;
|
||||
NetPacket packet = NetTextModule.SerializeClientMessage(message);
|
||||
NetManager.Instance.SendToServer(packet);
|
||||
}
|
||||
|
||||
public static void DisplayMessage(NetworkText text, Color color, byte messageAuthor)
|
||||
{
|
||||
string str = text.ToString();
|
||||
if (messageAuthor < byte.MaxValue)
|
||||
{
|
||||
Main.player[(int) messageAuthor].chatOverhead.NewMessage(str, Main.PlayerOverheadChatMessageDisplayTime);
|
||||
Main.player[(int) messageAuthor].chatOverhead.color = color;
|
||||
str = NameTagHandler.GenerateTag(Main.player[(int) messageAuthor].name) + " " + str;
|
||||
}
|
||||
if (ChatHelper.ShouldCacheMessage())
|
||||
ChatHelper.CacheMessage(str, color);
|
||||
else
|
||||
Main.NewTextMultiline(str, c: color);
|
||||
}
|
||||
|
||||
private static void CacheMessage(string message, Color color) => ChatHelper._cachedMessages.Add(new Tuple<string, Color>(message, color));
|
||||
|
||||
public static void ShowCachedMessages()
|
||||
{
|
||||
lock (ChatHelper._cachedMessages)
|
||||
{
|
||||
foreach (Tuple<string, Color> cachedMessage in ChatHelper._cachedMessages)
|
||||
Main.NewTextMultiline(cachedMessage.Item1, c: cachedMessage.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearDelayedMessagesCache() => ChatHelper._cachedMessages.Clear();
|
||||
|
||||
private static bool ShouldCacheMessage() => Main.netMode == 1 && Main.gameMenu;
|
||||
}
|
||||
}
|
72
Chat/ChatMessage.cs
Normal file
72
Chat/ChatMessage.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.ChatMessage
|
||||
// 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 System.Text;
|
||||
using Terraria.Chat.Commands;
|
||||
|
||||
namespace Terraria.Chat
|
||||
{
|
||||
public sealed class ChatMessage
|
||||
{
|
||||
public ChatCommandId CommandId { get; private set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public bool IsConsumed { get; private set; }
|
||||
|
||||
public ChatMessage(string message)
|
||||
{
|
||||
this.CommandId = ChatCommandId.FromType<SayChatCommand>();
|
||||
this.Text = message;
|
||||
this.IsConsumed = false;
|
||||
}
|
||||
|
||||
private ChatMessage(string message, ChatCommandId commandId)
|
||||
{
|
||||
this.CommandId = commandId;
|
||||
this.Text = message;
|
||||
}
|
||||
|
||||
public void Serialize(BinaryWriter writer)
|
||||
{
|
||||
if (this.IsConsumed)
|
||||
throw new InvalidOperationException("Message has already been consumed.");
|
||||
this.CommandId.Serialize(writer);
|
||||
writer.Write(this.Text);
|
||||
}
|
||||
|
||||
public int GetMaxSerializedSize()
|
||||
{
|
||||
if (this.IsConsumed)
|
||||
throw new InvalidOperationException("Message has already been consumed.");
|
||||
return 0 + this.CommandId.GetMaxSerializedSize() + (4 + Encoding.UTF8.GetByteCount(this.Text));
|
||||
}
|
||||
|
||||
public static ChatMessage Deserialize(BinaryReader reader)
|
||||
{
|
||||
ChatCommandId commandId = ChatCommandId.Deserialize(reader);
|
||||
return new ChatMessage(reader.ReadString(), commandId);
|
||||
}
|
||||
|
||||
public void SetCommand(ChatCommandId commandId)
|
||||
{
|
||||
if (this.IsConsumed)
|
||||
throw new InvalidOperationException("Message has already been consumed.");
|
||||
this.CommandId = commandId;
|
||||
}
|
||||
|
||||
public void SetCommand<T>() where T : IChatCommand
|
||||
{
|
||||
if (this.IsConsumed)
|
||||
throw new InvalidOperationException("Message has already been consumed.");
|
||||
this.CommandId = ChatCommandId.FromType<T>();
|
||||
}
|
||||
|
||||
public void Consume() => this.IsConsumed = true;
|
||||
}
|
||||
}
|
18
Chat/Commands/ChatCommandAttribute.cs
Normal file
18
Chat/Commands/ChatCommandAttribute.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.ChatCommandAttribute
|
||||
// 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;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
|
||||
public sealed class ChatCommandAttribute : Attribute
|
||||
{
|
||||
public readonly string Name;
|
||||
|
||||
public ChatCommandAttribute(string name) => this.Name = name;
|
||||
}
|
||||
}
|
73
Chat/Commands/EmojiCommand.cs
Normal file
73
Chat/Commands/EmojiCommand.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.EmojiCommand
|
||||
// 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.Collections.Generic;
|
||||
using Terraria.GameContent.UI;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Emoji")]
|
||||
public class EmojiCommand : IChatCommand
|
||||
{
|
||||
public const int PlayerEmojiDuration = 360;
|
||||
private readonly Dictionary<LocalizedText, int> _byName = new Dictionary<LocalizedText, int>();
|
||||
|
||||
public EmojiCommand() => this.Initialize();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
this._byName.Clear();
|
||||
for (int id = 0; id < 145; ++id)
|
||||
{
|
||||
LocalizedText emojiName = Lang.GetEmojiName(id);
|
||||
if (emojiName != LocalizedText.Empty)
|
||||
this._byName[emojiName] = id;
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId)
|
||||
{
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
int result = -1;
|
||||
if (int.TryParse(message.Text, out result))
|
||||
{
|
||||
if (result < 0 || result >= 145)
|
||||
return;
|
||||
}
|
||||
else
|
||||
result = -1;
|
||||
if (result == -1)
|
||||
{
|
||||
foreach (LocalizedText key in this._byName.Keys)
|
||||
{
|
||||
if (message.Text == key.Value)
|
||||
{
|
||||
result = this._byName[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result != -1)
|
||||
{
|
||||
if (Main.netMode == 0)
|
||||
{
|
||||
EmoteBubble.NewBubble(result, new WorldUIAnchor((Entity) Main.LocalPlayer), 360);
|
||||
EmoteBubble.CheckForNPCsToReactToEmoteBubble(result, Main.LocalPlayer);
|
||||
}
|
||||
else
|
||||
NetMessage.SendData(120, number: Main.myPlayer, number2: ((float) result));
|
||||
}
|
||||
message.Consume();
|
||||
}
|
||||
|
||||
public void PrintWarning(string text) => throw new Exception("This needs localized text!");
|
||||
}
|
||||
}
|
29
Chat/Commands/EmoteCommand.cs
Normal file
29
Chat/Commands/EmoteCommand.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.EmoteCommand
|
||||
// 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 Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Emote")]
|
||||
public class EmoteCommand : IChatCommand
|
||||
{
|
||||
private static readonly Color RESPONSE_COLOR = new Color(200, 100, 0);
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId)
|
||||
{
|
||||
if (!(text != ""))
|
||||
return;
|
||||
text = string.Format("*{0} {1}", (object) Main.player[(int) clientId].name, (object) text);
|
||||
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(text), EmoteCommand.RESPONSE_COLOR);
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
57
Chat/Commands/HelpCommand.cs
Normal file
57
Chat/Commands/HelpCommand.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.HelpCommand
|
||||
// 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 Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Help")]
|
||||
public class HelpCommand : IChatCommand
|
||||
{
|
||||
private static readonly Color RESPONSE_COLOR = new Color((int) byte.MaxValue, 240, 20);
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId) => ChatHelper.SendChatMessageToClient(HelpCommand.ComposeMessage(HelpCommand.GetCommandAliasesByID()), HelpCommand.RESPONSE_COLOR, (int) clientId);
|
||||
|
||||
private static Dictionary<string, List<LocalizedText>> GetCommandAliasesByID()
|
||||
{
|
||||
LocalizedText[] all = Language.FindAll(Lang.CreateDialogFilter("ChatCommand.", Lang.CreateDialogSubstitutionObject()));
|
||||
Dictionary<string, List<LocalizedText>> dictionary = new Dictionary<string, List<LocalizedText>>();
|
||||
foreach (LocalizedText localizedText in all)
|
||||
{
|
||||
string key = localizedText.Key.Replace("ChatCommand.", "");
|
||||
int length = key.IndexOf('_');
|
||||
if (length != -1)
|
||||
key = key.Substring(0, length);
|
||||
List<LocalizedText> localizedTextList;
|
||||
if (!dictionary.TryGetValue(key, out localizedTextList))
|
||||
{
|
||||
localizedTextList = new List<LocalizedText>();
|
||||
dictionary[key] = localizedTextList;
|
||||
}
|
||||
localizedTextList.Add(localizedText);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
private static NetworkText ComposeMessage(
|
||||
Dictionary<string, List<LocalizedText>> aliases)
|
||||
{
|
||||
string text = "";
|
||||
for (int index = 0; index < aliases.Count; ++index)
|
||||
text = text + "{" + (object) index + "}\n";
|
||||
List<NetworkText> networkTextList = new List<NetworkText>();
|
||||
foreach (KeyValuePair<string, List<LocalizedText>> alias in aliases)
|
||||
networkTextList.Add(Language.GetText("ChatCommandDescription." + alias.Key).ToNetworkText());
|
||||
return NetworkText.FromFormattable(text, (object[]) networkTextList.ToArray());
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
15
Chat/Commands/IChatCommand.cs
Normal file
15
Chat/Commands/IChatCommand.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.IChatCommand
|
||||
// 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
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
public interface IChatCommand
|
||||
{
|
||||
void ProcessIncomingMessage(string text, byte clientId);
|
||||
|
||||
void ProcessOutgoingMessage(ChatMessage message);
|
||||
}
|
||||
}
|
26
Chat/Commands/ListPlayersCommand.cs
Normal file
26
Chat/Commands/ListPlayersCommand.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.ListPlayersCommand
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Playing")]
|
||||
public class ListPlayersCommand : IChatCommand
|
||||
{
|
||||
private static readonly Color RESPONSE_COLOR = new Color((int) byte.MaxValue, 240, 20);
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId) => ChatHelper.SendChatMessageToClient(NetworkText.FromLiteral(string.Join(", ", ((IEnumerable<Player>) Main.player).Where<Player>((Func<Player, bool>) (player => player.active)).Select<Player, string>((Func<Player, string>) (player => player.name)))), ListPlayersCommand.RESPONSE_COLOR, (int) clientId);
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
43
Chat/Commands/PartyChatCommand.cs
Normal file
43
Chat/Commands/PartyChatCommand.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.PartyChatCommand
|
||||
// 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 Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Party")]
|
||||
public class PartyChatCommand : IChatCommand
|
||||
{
|
||||
private static readonly Color ERROR_COLOR = new Color((int) byte.MaxValue, 240, 20);
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId)
|
||||
{
|
||||
int team = Main.player[(int) clientId].team;
|
||||
Color color = Main.teamColor[team];
|
||||
if (team == 0)
|
||||
{
|
||||
this.SendNoTeamError(clientId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (text == "")
|
||||
return;
|
||||
for (int playerId = 0; playerId < (int) byte.MaxValue; ++playerId)
|
||||
{
|
||||
if (Main.player[playerId].team == team)
|
||||
ChatHelper.SendChatMessageToClientAs(clientId, NetworkText.FromLiteral(text), color, playerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
|
||||
private void SendNoTeamError(byte clientId) => ChatHelper.SendChatMessageToClient(Lang.mp[10].ToNetworkText(), PartyChatCommand.ERROR_COLOR, (int) clientId);
|
||||
}
|
||||
}
|
31
Chat/Commands/RockPaperScissorsCommand.cs
Normal file
31
Chat/Commands/RockPaperScissorsCommand.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.RockPaperScissorsCommand
|
||||
// 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 Terraria.GameContent.UI;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("RPS")]
|
||||
public class RockPaperScissorsCommand : IChatCommand
|
||||
{
|
||||
public void ProcessIncomingMessage(string text, byte clientId)
|
||||
{
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
int num = Main.rand.NextFromList<int>(37, 38, 36);
|
||||
if (Main.netMode == 0)
|
||||
{
|
||||
EmoteBubble.NewBubble(num, new WorldUIAnchor((Entity) Main.LocalPlayer), 360);
|
||||
EmoteBubble.CheckForNPCsToReactToEmoteBubble(num, Main.LocalPlayer);
|
||||
}
|
||||
else
|
||||
NetMessage.SendData(120, number: Main.myPlayer, number2: ((float) num));
|
||||
message.Consume();
|
||||
}
|
||||
}
|
||||
}
|
27
Chat/Commands/RollCommand.cs
Normal file
27
Chat/Commands/RollCommand.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.RollCommand
|
||||
// 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 Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Roll")]
|
||||
public class RollCommand : IChatCommand
|
||||
{
|
||||
private static readonly Color RESPONSE_COLOR = new Color((int) byte.MaxValue, 240, 20);
|
||||
|
||||
public void ProcessIncomingMessage(string text, byte clientId)
|
||||
{
|
||||
int num = Main.rand.Next(1, 101);
|
||||
ChatHelper.BroadcastChatMessage(NetworkText.FromFormattable("*{0} {1} {2}", (object) Main.player[(int) clientId].name, (object) Lang.mp[9].ToNetworkText(), (object) num), RollCommand.RESPONSE_COLOR);
|
||||
}
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
20
Chat/Commands/SayChatCommand.cs
Normal file
20
Chat/Commands/SayChatCommand.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.Commands.SayChatCommand
|
||||
// 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 Terraria.Localization;
|
||||
|
||||
namespace Terraria.Chat.Commands
|
||||
{
|
||||
[ChatCommand("Say")]
|
||||
public class SayChatCommand : IChatCommand
|
||||
{
|
||||
public void ProcessIncomingMessage(string text, byte clientId) => ChatHelper.BroadcastChatMessageAs(clientId, NetworkText.FromLiteral(text), Main.player[(int) clientId].ChatColor());
|
||||
|
||||
public void ProcessOutgoingMessage(ChatMessage message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
15
Chat/IChatProcessor.cs
Normal file
15
Chat/IChatProcessor.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.Chat.IChatProcessor
|
||||
// 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
|
||||
|
||||
namespace Terraria.Chat
|
||||
{
|
||||
public interface IChatProcessor
|
||||
{
|
||||
void ProcessIncomingMessage(ChatMessage message, int clientId);
|
||||
|
||||
ChatMessage CreateOutgoingMessage(string text);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue