Map/ShopDoor.cs

A usable scene component representing the shop-to-mansion door. It requires a short interaction, is locked by default, shows a lock hint, only allows use when all alive players are within 300 units, and advances the run by calling MansionGame.NextLevel() when used.

Networking
using System.Linq;
using Sandbox;

namespace BrickJam;

/// <summary>
/// Door from the shop into the mansion; advances the run when all players are gathered.
/// Scene-System port of legacy <c>ShopDoor</c>.
/// </summary>
[Title( "Shop Door" )]
[Category( "Map" )]
public sealed partial class ShopDoor : LegacyUsableComponent
{
	public override float InteractionDuration { get; set; } = 0.8f;
	public override bool StartLocked => true;
	public override string LockText => "lockpick the mansion door";

	public override bool CanUse => Scene.GetAllComponents<Player>()
		.Where( x => x.IsAlive )
		.All( x => x.WorldPosition.Distance( WorldPosition ) <= 300f );

	public override string UseString
	{
		get => CanUse ? "enter the mansion" : "ALL PLAYERS NEED TO BE NEARBY TO PROCEED";
		set { }
	}

	public override void Use( Player user )
	{
		MansionGame.NextLevel();
	}
}