Mister_Nebula 53974485c9
Spiral sync (#242)
* add stuff

* extract patches

* extract worldobjects (#241)

* add spiral sync

* cleanup

* cleanup

* fix

* rename

* add computers

* remove qnet flagshelper

* Update README.md

* cleanup
2020-12-31 12:10:55 +00:00

63 lines
1.7 KiB
C#

using QSB.Events;
using QSB.Patches;
namespace QSB.TranslationSync.Patches
{
internal class SpiralPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public override void DoPatches()
{
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiWallText>("SetAsTranslated", typeof(SpiralPatches), nameof(Wall_SetAsTranslated));
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(Computer_SetAsTranslated));
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiVesselComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(VesselComputer_SetAsTranslated));
}
public static bool Wall_SetAsTranslated(NomaiWallText __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.WallText,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
public static bool Computer_SetAsTranslated(NomaiComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.Computer,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
public static bool VesselComputer_SetAsTranslated(NomaiVesselComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.VesselComputer,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
}
}