Pawn.cs

Abstract Pawn component base class for game entities. Defines virtual lifecycle hooks OnAssign(Client) and OnUnassign() that derived pawns can override. OnUnassign transfers network ownership of the GameObject to the host if the GameObject is valid.

namespace ShrimplePawns;

/// <summary>
/// The base pawn that you should inherit off of.
/// </summary>
public abstract class Pawn : Component
{
	/// <summary>
	/// Called when the pawn has been assigned.
	/// </summary>
	public virtual void OnAssign( Client client )
	{

	}

	/// <summary>
	/// Called when the pawn has been unassigned.
	/// </summary>
	public virtual void OnUnassign()
	{
		if ( GameObject.IsValid() )
			GameObject.Network.AssignOwnership( Connection.Host );
	}
}