2024-04-04 23:05:34 +02:00
|
|
|
using System.Reflection;
|
|
|
|
// using HarmonyLib;
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
namespace Template;
|
|
|
|
|
|
|
|
using Settings;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
#if DEBUG
|
|
|
|
#warning Compiling in Debug mode
|
|
|
|
#endif
|
|
|
|
|
2024-04-04 23:05:34 +02:00
|
|
|
public class TemplateMod : Mod
|
|
|
|
{
|
|
|
|
public TemplateMod(ModContentPack content)
|
|
|
|
: base(content)
|
|
|
|
{
|
2024-10-16 14:11:05 +02:00
|
|
|
#if v1_5
|
|
|
|
const string GAME_VERSION = "v1.5";
|
|
|
|
#else
|
|
|
|
#error No version defined
|
|
|
|
const string GAME_VERSION = "UNDEFINED";
|
|
|
|
#endif
|
|
|
|
|
2024-04-04 23:05:34 +02:00
|
|
|
#if DEBUG
|
|
|
|
const string build = "Debug";
|
|
|
|
#else
|
|
|
|
const string build = "Release";
|
|
|
|
#endif
|
2024-10-16 14:11:05 +02:00
|
|
|
Log(
|
|
|
|
$"Running Version {Assembly.GetAssembly(typeof(TemplateMod)).GetName().Version} {build} compiled for RimWorld version {GAME_VERSION}"
|
2024-04-04 23:05:34 +02:00
|
|
|
+ build
|
|
|
|
);
|
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
Log(content.ModMetaData.packageIdLowerCase);
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-04-05 00:03:46 +02:00
|
|
|
Settings = GetSettings<TemplateSettings>();
|
|
|
|
WriteSettings();
|
|
|
|
|
2024-04-04 23:05:34 +02:00
|
|
|
// Harmony harmony = new(content.ModMetaData.packageIdLowerCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
#nullable disable // Set in constructor.
|
|
|
|
|
|
|
|
public static TemplateSettings Settings { get; private set; }
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
public override void DoSettingsWindowContents(Rect inRect) =>
|
|
|
|
SettingsWindow.DoSettingsWindowContents(inRect);
|
|
|
|
|
|
|
|
public override string SettingsCategory() => SettingsWindow.SettingsCategory();
|
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
const string LogPrefix = "Toby's Template Mod - ";
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void DebugError(string message, int? key = null)
|
|
|
|
{
|
2024-04-04 23:05:34 +02:00
|
|
|
#if DEBUG
|
2024-10-16 14:11:05 +02:00
|
|
|
Error(message, key);
|
2024-04-04 23:05:34 +02:00
|
|
|
#endif
|
2024-10-16 14:11:05 +02:00
|
|
|
}
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void Error(string message, int? key = null)
|
|
|
|
{
|
|
|
|
if (key is int keyNotNull)
|
|
|
|
Verse.Log.ErrorOnce(LogPrefix + message, keyNotNull);
|
|
|
|
else
|
2024-04-04 23:05:34 +02:00
|
|
|
Verse.Log.Error(LogPrefix + message);
|
2024-10-16 14:11:05 +02:00
|
|
|
}
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void DebugWarn(string message, int? key = null)
|
|
|
|
{
|
2024-04-04 23:05:34 +02:00
|
|
|
#if DEBUG
|
2024-10-16 14:11:05 +02:00
|
|
|
Warn(message, key);
|
2024-04-04 23:05:34 +02:00
|
|
|
#endif
|
2024-10-16 14:11:05 +02:00
|
|
|
}
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void Warn(string message, int? key = null)
|
|
|
|
{
|
|
|
|
if (key is int keyNotNull)
|
|
|
|
Verse.Log.WarningOnce(LogPrefix + message, keyNotNull);
|
|
|
|
else
|
2024-04-04 23:05:34 +02:00
|
|
|
Verse.Log.Warning(LogPrefix + message);
|
2024-10-16 14:11:05 +02:00
|
|
|
}
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void DebugLog(string message)
|
|
|
|
{
|
2024-04-04 23:05:34 +02:00
|
|
|
#if DEBUG
|
2024-10-16 14:11:05 +02:00
|
|
|
Log(message);
|
2024-04-04 23:05:34 +02:00
|
|
|
#endif
|
2024-10-16 14:11:05 +02:00
|
|
|
}
|
2024-04-04 23:05:34 +02:00
|
|
|
|
2024-10-16 14:11:05 +02:00
|
|
|
public static void Log(string message)
|
|
|
|
{
|
|
|
|
Verse.Log.Message(LogPrefix + message);
|
2024-04-04 23:05:34 +02:00
|
|
|
}
|
|
|
|
}
|