using Platform; namespace Harmony.TileEntitySignPatches { [HarmonyPatch(typeof(TileEntitySign))] [HarmonyPatch("SetText")] [HarmonyPatch(new[] { typeof(string), typeof(bool), typeof(PlatformUserIdentifierAbs) })] public class SetTextPatch { public static bool Prefix(TileEntitySign __instance, string _text, bool _syncData, PlatformUserIdentifierAbs _signingPlayer) { if (_signingPlayer == null) { _signingPlayer = PlatformManager.MultiPlatform.User.PlatformUserId; } // Check for null as Vanilla code generates an error if still null if (_signingPlayer != null && GameManager.Instance.persistentPlayers != null) { if (GameManager.Instance.persistentPlayers.GetPlayerData(_signingPlayer) == null) { _signingPlayer = (PlatformUserIdentifierAbs)null; _text = ""; } if (_text == __instance.signText.Text) { return false; } __instance.signText.Update(_text, _signingPlayer); GeneratedTextManager.GetDisplayText(__instance.signText, new Action(__instance.RefreshTextMesh), true, true, GeneratedTextManager.TextFilteringMode.FilterWithSafeString, GeneratedTextManager.BbCodeSupportMode.NotSupported); if (!_syncData) { return false; } __instance.setModified(); } return false; } } }