Loot/PissingGuySpawner.Runtime.cs

Runtime component that spawns a PissingGuy NPC. It checks host authority and a random chance, then creates the NPC at the spawner's world position and rotation and records its starting transform.

Networking
using Sandbox;

namespace BrickJam;

/// <summary>
/// Runtime behaviour for the <see cref="PissingGuySpawner"/> map component (stub in
/// <c>LegacyMapEntities.cs</c>). Scene-System port of the legacy <c>PissingGuySpawner.SpawnGuy</c>.
/// </summary>
public sealed partial class PissingGuySpawner
{
	public PissingGuy SpawnGuy()
	{
		if ( !Networking.IsHost )
			return null;

		if ( MansionGame.Random.NextSingle() > ChanceToSpawn )
			return null;

		var guy = NPC.Create<PissingGuy>( WorldPosition, WorldRotation );
		guy.StartingPosition = WorldPosition;
		guy.StartingRotation = WorldRotation;
		return guy;
	}
}