Decompiled source of GuildNamePlates v1.1.1

GuildName.dll

Decompiled 2 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Sims.Online")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sims.Online")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3c45ae74-9729-4a9c-9aae-a674e2d96c65")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GuildNameplateMod;

[BepInPlugin("com.yourdomain.guildnameplate", "Guild Nameplate Mod", "1.1.1")]
public class GuildNameplatePlugin : BaseUnityPlugin
{
	private ConfigEntry<string> GuildName;

	private ConfigEntry<float> ExtraOffset;

	private void Awake()
	{
		GuildName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GuildName", "KnightsOfNi", "The guild tag to display under your player name.");
		ExtraOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExtraOffset", 0f, "Additional vertical offset (added to the base 2.2m) for the plate.");
		SceneManager.sceneLoaded += OnZoneLoaded;
		GuildName.SettingChanged += delegate
		{
			UpdatePlate();
		};
		ExtraOffset.SettingChanged += delegate
		{
			UpdatePlate();
		};
	}

	private void Start()
	{
		((MonoBehaviour)this).Invoke("UpdatePlate", 0.5f);
	}

	private void OnZoneLoaded(Scene _, LoadSceneMode __)
	{
		((MonoBehaviour)this).Invoke("UpdatePlate", 0.5f);
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnZoneLoaded;
	}

	private void UpdatePlate()
	{
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(GuildName.Value))
		{
			return;
		}
		PlayerControl playerControl = GameData.PlayerControl;
		if ((Object)(object)playerControl == (Object)null)
		{
			return;
		}
		Transform val = null;
		string name = ((Object)((Component)GameData.GM).GetComponent<Misc>().NamePlate).name;
		for (int i = 0; i < ((Component)playerControl).transform.childCount; i++)
		{
			Transform child = ((Component)playerControl).transform.GetChild(i);
			if (((Object)child).name == name || ((Object)child).name.Contains("NamePlate"))
			{
				val = child;
				break;
			}
		}
		if (!((Object)(object)val == (Object)null))
		{
			val.localPosition = new Vector3(0f, 2.2f + ExtraOffset.Value, 0f);
			TextMeshPro val2 = ((Component)val).GetComponent<TextMeshPro>() ?? ((Component)val).GetComponentInChildren<TextMeshPro>();
			if ((Object)(object)val2 != (Object)null)
			{
				string myName = GameData.PlayerStats.MyName;
				((TMP_Text)val2).text = myName + "\n<" + GuildName.Value + ">";
			}
		}
	}
}