Weapons/Extras/WeaponPlayerAttachment.cs
/// <summary>
/// Place this on a weapon's world model, and it'll attach either a prefab or an existing GameObject to a specified bone
/// </summary>
public partial class WeaponPlayerAttachment : Component, Carryable.IEvent
{
	[Property] public GameObject Object { get; set; }
	[Property] public string Bone { get; set; }

	GameObject gameObject;

	void Carryable.IEvent.OnCreateWorldModel()
	{
		if ( gameObject.IsValid() ) 
			gameObject.Destroy();

		var player = GetComponentInParent<PlayerController>();
		var parent = player.Renderer.GetBoneObject( Bone );

		if ( Object is PrefabScene )
		{
			gameObject = Object?.Clone( new CloneConfig()
			{
				StartEnabled = true,
				Parent = parent,
			} );

			Assert.True( gameObject.IsValid(), "Couldn't create WeaponPlayerAttachment from prefab" );
		}
		else
		{
			Assert.True( Object.IsValid(), "WeaponPlayerAttachment does not have an Object defined" );

			gameObject = Object;
			gameObject.SetParent( parent, false );
		}
	}

	void Carryable.IEvent.OnDestroyWorldModel()
	{
		if ( gameObject.IsValid() ) 
			gameObject.Destroy();
	}
}