Decompiled source of StartingItems v1.0.0

StartingItems.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("StartingItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b8a768abaf319ce1375174c79f2a4dd31c8102c6")]
[assembly: AssemblyProduct("StartingItems")]
[assembly: AssemblyTitle("StartingItems")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StartingItems;

[BepInPlugin("kruumy.StartingItems", "StartingItems", "1.0.0")]
public class Main : BaseUnityPlugin
{
	public ConfigEntry<string> StartingItems;

	public void Awake()
	{
		StartingItems = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StartingItems", "JumpBoost,Hoof", "A csv (comma seperated values) of all the items to give to a player on spawn. The diplay name might not always equal the codename of the item. For example: Wax Quail = JumpBoost. To find the name out for yourself, open the console (ctrl + alt + grave (`)) and type in \"item_list\". To give muliple of an item simply just repeat it. (Hoof,Hoof,Hoof)");
		PlayerCharacterMasterController.onPlayerAdded += PlayerCharacterMasterController_onPlayerAdded;
	}

	private void PlayerCharacterMasterController_onPlayerAdded(PlayerCharacterMasterController player)
	{
		player.master.onBodyStart += Master_onBodyStart;
		void Master_onBodyStart(CharacterBody body)
		{
			string[] array = StartingItems.Value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				body.inventory.GiveItemString(text.Trim());
			}
			player.master.onBodyStart -= Master_onBodyStart;
		}
	}
}