69 lines
2.0 KiB
C#
Raw Normal View History

using QSB.Events;
using QSB.Patches;
2021-02-24 10:45:25 +00:00
using QSB.TranslationSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.TranslationSync.Patches
{
internal class SpiralPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public override void DoPatches()
{
2021-03-13 10:17:52 +00:00
QSBCore.HarmonyHelper.AddPrefix<NomaiWallText>("SetAsTranslated", typeof(SpiralPatches), nameof(Wall_SetAsTranslated));
QSBCore.HarmonyHelper.AddPrefix<NomaiComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(Computer_SetAsTranslated));
QSBCore.HarmonyHelper.AddPrefix<NomaiVesselComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(VesselComputer_SetAsTranslated));
}
2021-02-09 17:18:01 +00:00
public override void DoUnpatches()
{
2021-03-13 10:17:52 +00:00
QSBCore.HarmonyHelper.Unpatch<NomaiWallText>("SetAsTranslated");
QSBCore.HarmonyHelper.Unpatch<NomaiComputer>("SetAsTranslated");
QSBCore.HarmonyHelper.Unpatch<NomaiVesselComputer>("SetAsTranslated");
2021-02-09 17:18:01 +00:00
}
public static bool Wall_SetAsTranslated(NomaiWallText __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
2021-02-10 19:34:41 +00:00
QSBEventManager.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.WallText,
2021-02-24 10:45:25 +00:00
QSBWorldSync.GetIdFromUnity<QSBWallText, NomaiWallText>(__instance),
id);
return true;
}
public static bool Computer_SetAsTranslated(NomaiComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
2021-02-10 19:34:41 +00:00
QSBEventManager.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.Computer,
2021-02-24 10:45:25 +00:00
QSBWorldSync.GetIdFromUnity<QSBComputer, NomaiComputer>(__instance),
id);
return true;
}
public static bool VesselComputer_SetAsTranslated(NomaiVesselComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
2021-02-10 19:34:41 +00:00
QSBEventManager.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.VesselComputer,
2021-02-24 10:45:25 +00:00
QSBWorldSync.GetIdFromUnity<QSBVesselComputer, NomaiVesselComputer>(__instance),
id);
return true;
}
}
}