public static string BuildMessage(string message, Players.Player p, localization.LocalizationHelper localization, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal) { var colorPrefix = "<color=" + color + ">"; var colorSuffix = "</color>"; string stylePrefix, styleSuffix; switch (style) { case ChatStyle.bold: stylePrefix = "<b>"; styleSuffix = "</b>"; break; case ChatStyle.bolditalic: stylePrefix = "<b><i>"; styleSuffix = "</i></b>"; break; case ChatStyle.italic: stylePrefix = "<i>"; styleSuffix = "</i>"; break; default: stylePrefix = ""; styleSuffix = ""; break; } return(stylePrefix + colorPrefix + localization.LocalizeOrDefault(message, p) + colorSuffix + styleSuffix); }
public static void Send(Players.Player player, localization.LocalizationHelper localizationHelper, string message, params string[] args) { if (player.IsConnected()) { var messageBuilt = BuildMessage(string.Format(localizationHelper.LocalizeOrDefault(message, player), LocalizeArgs(player, localizationHelper, args)), player, localizationHelper); Chat.Send(player, messageBuilt); } }
public static string[] LocalizeArgs(Players.Player p, localization.LocalizationHelper localizationHelper, params string[] args) { for (int i = 0; i < args.Length; i++) { args[i] = localizationHelper.LocalizeOrDefault(args[i], p); } return(args); }
public static void SendThrottle(Players.Player player, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, params string[] args) { if (CanSendMesssage(player)) { var messageBuilt = BuildMessage(string.Format(localizationHelper.LocalizeOrDefault(message, player), LocalizeArgs(player, localizationHelper, args)), player, localizationHelper, color); Chat.Send(player, messageBuilt); _nextSendTime[player] = Time.SecondsSinceStartDouble + 10; } }
public static void SendThrottle(Players.Player player, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default) { if (CanSendMesssage(player)) { var messageBuilt = BuildMessage(message, player, localizationHelper, color, style); Chat.Send(player, messageBuilt, sender); _nextSendTime[player] = Time.SecondsSinceStartDouble + 10; } }
public static void Send(Players.Player player, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default) { if (player.IsConnected()) { var messageBuilt = BuildMessage(message, player, localizationHelper, color, style); Chat.Send(player, messageBuilt, sender); } }
public static void SendToAll(string message, localization.LocalizationHelper localizationHelper, params string[] args) { foreach (var p in Players.PlayerDatabase.Values) { if (p.IsConnected()) { var messageBuilt = BuildMessage(string.Format(localizationHelper.LocalizeOrDefault(message, p), LocalizeArgs(p, localizationHelper, args)), p, localizationHelper); Chat.Send(p, messageBuilt); } } }
public static void Send(ColonyState colony, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default) { colony.ColonyRef.ForEachOwner(p => { if (p.IsConnected()) { var messageBuilt = BuildMessage(colony.ColonyRef.Name + ": " + localizationHelper.LocalizeOrDefault(message, p), p, localizationHelper, color, style); Chat.Send(p, messageBuilt, sender); } }); }
public static void Send(Colony colony, localization.LocalizationHelper localizationHelper, string message, params string[] args) { colony.ForEachOwner(o => { if (o.IsConnected()) { var messageBuilt = BuildMessage(colony.Name + ": " + string.Format(localizationHelper.LocalizeOrDefault(message, o), LocalizeArgs(o, localizationHelper, args)), o, localizationHelper); Chat.Send(o, messageBuilt); } }); }
public static void SendToAll(string message, localization.LocalizationHelper localizationHelper, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default) { foreach (var p in Players.PlayerDatabase.Values) { if (p.IsConnected()) { var messageBuilt = BuildMessage(message, p, localizationHelper, color, style); Chat.Send(p, messageBuilt, sender); } } }
public static void SendThrottle(ColonyState colony, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, ChatStyle style = ChatStyle.normal, EChatSendOptions sender = EChatSendOptions.Default) { colony.ColonyRef.ForEachOwner(o => SendThrottle(o, localizationHelper, message, color, style, sender)); }
public static void SendThrottle(ColonyState colony, localization.LocalizationHelper localizationHelper, string message, ChatColor color = ChatColor.white, params string[] args) { colony.ColonyRef.ForEachOwner(o => SendThrottle(o, localizationHelper, message, color, args)); }