quantum-space-buddies/QSB/Utility/DebugLog.cs
AmazingAlek 42cb791c5d
nre fixes (#177)
Co-authored-by: Mister_Nebula <41904486+misternebula@users.noreply.github.com>
2020-08-16 17:35:27 +02:00

46 lines
1.2 KiB
C#

using System.Linq;
using OWML.Common;
using UnityEngine;
namespace QSB.Utility
{
public class DebugLog : MonoBehaviour
{
private static string JoinAll(params object[] logObjects)
{
return string.Join(" ", logObjects.Select(o => o.ToString()).ToArray());
}
public static void ToConsole(string message)
{
QSB.Helper.Console.WriteLine(message, MessageType.Message);
}
public static void ToConsole(string message, MessageType type)
{
QSB.Helper.Console.WriteLine(message, type);
}
public static void ToHud(params object[] logObjects)
{
if (Locator.GetPlayerBody() == null)
{
return;
}
var data = new NotificationData(NotificationTarget.Player, JoinAll(logObjects));
NotificationManager.SharedInstance.PostNotification(data);
}
public static void ToAll(MessageType type, params object[] logObjects)
{
ToConsole(JoinAll(logObjects), type);
ToHud(logObjects);
}
public static void ToAll(params object[] logObjects)
{
ToAll(MessageType.Message, logObjects);
}
}
}