Class Npc
Wrapper class for handling NPC players.
public class Npc : Player, IEntity, IWorldSpace, IPosition, IRotation
- Inheritance
-
Npc
- Implements
- Inherited Members
- Extension Methods
Constructors
Npc(ReferenceHub)
Represents the in-game player, by encapsulating a ReferenceHub.
public Npc(ReferenceHub referenceHub)
Parameters
referenceHub
ReferenceHub
Npc(GameObject)
Represents the in-game player, by encapsulating a ReferenceHub.
public Npc(GameObject gameObject)
Parameters
gameObject
GameObject
Properties
FollowedPlayer
Gets or sets the player being followed.
public Player? FollowedPlayer { get; set; }
Property Value
Remarks
The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.
List
Gets a list of Npcs.
public static IReadOnlyCollection<Npc> List { get; }
Property Value
MaxDistance
Gets or sets the Max Distance of the npc.
public float? MaxDistance { get; set; }
Property Value
Remarks
The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.
MinDistance
Gets or sets the Min Distance of the npc.
public float? MinDistance { get; set; }
Property Value
Remarks
The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.
Position
Gets or sets the player's position.
public override Vector3 Position { get; set; }
Property Value
- Vector3
Speed
Gets or sets the Speed of the npc.
public float? Speed { get; set; }
Property Value
Remarks
The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.
Methods
Destroy()
Destroys the NPC.
public void Destroy()
DestroyAll()
Destroys all NPCs currently spawned.
public static void DestroyAll()
Follow(Player)
Follow a specific player.
public void Follow(Player player)
Parameters
player
Playerthe Player to follow.
Follow(Player, float, float, float)
Follow a specific player.
public void Follow(Player player, float maxDistance, float minDistance, float speed = 30)
Parameters
player
Playerthe Player to follow.
maxDistance
floatthe max distance the npc will go.
minDistance
floatthe min distance the npc will go.
speed
floatthe speed the npc will go.
Get(CommandSender)
Retrieves the NPC associated with the specified CommandSender.
public static Npc? Get(CommandSender sender)
Parameters
sender
CommandSenderThe CommandSender to retrieve the NPC for.
Returns
- Npc
The NPC associated with the CommandSender, or
null
if not found.
Get(ICommandSender)
Retrieves the NPC associated with the specified ICommandSender.
public static Npc? Get(ICommandSender sender)
Parameters
sender
ICommandSenderThe ICommandSender to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ICommandSender, or
null
if not found.
Get(Footprint)
Retrieves the NPC associated with the specified Footprint.
public static Npc? Get(Footprint footprint)
Parameters
footprint
FootprintThe Footprint to retrieve the NPC for.
Returns
- Npc
The NPC associated with the Footprint, or
null
if not found.
Get(NetworkConnection)
Retrieves the NPC associated with the specified NetworkConnection.
public static Npc? Get(NetworkConnection conn)
Parameters
conn
NetworkConnectionThe NetworkConnection to retrieve the NPC for.
Returns
- Npc
The NPC associated with the NetworkConnection, or
null
if not found.
Get(ReferenceHub)
Retrieves the NPC associated with the specified ReferenceHub.
public static Npc? Get(ReferenceHub rHub)
Parameters
rHub
ReferenceHubThe ReferenceHub to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ReferenceHub, or
null
if not found.
Get(int)
Retrieves the NPC associated with the specified ID.
public static Npc? Get(int id)
Parameters
id
intThe ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ID, or
null
if not found.
Get(string)
Retrieves the NPC associated with the specified user ID.
public static Npc? Get(string userId)
Parameters
userId
stringThe user ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the user ID, or
null
if not found.
Get(uint)
Retrieves the NPC associated with the specified net ID.
public static Npc? Get(uint netId)
Parameters
netId
uintThe net ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the net ID, or
null
if not found.
Get(Collider)
Retrieves the NPC associated with the specified Collider.
public static Npc? Get(Collider collider)
Parameters
collider
ColliderThe Collider to retrieve the NPC for.
Returns
- Npc
The NPC associated with the Collider, or
null
if not found.
Get(GameObject)
Retrieves the NPC associated with the specified GameObject.
public static Npc? Get(GameObject gameObject)
Parameters
gameObject
GameObjectThe GameObject to retrieve the NPC for.
Returns
- Npc
The NPC associated with the GameObject, or
null
if not found.
LateDestroy(float)
Schedules the destruction of the NPC after a delay.
public void LateDestroy(float time)
Parameters
time
floatThe delay in seconds before the NPC is destroyed.
Spawn(string, RoleTypeId, bool, Vector3?)
Spawns an NPC based on the given parameters.
public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, Vector3? position = null)
Parameters
name
stringThe name of the NPC.
role
RoleTypeIdThe RoleTypeId of the NPC, defaulting to None.
ignored
boolWhether the NPC should be ignored by round ending checks.
position
Vector3?The position where the NPC should spawn. If null, the default spawn location is used.
Returns
Spawn(string, RoleTypeId, Vector3)
Spawns an NPC based on the given parameters.
public static Npc Spawn(string name, RoleTypeId role, Vector3 position)
Parameters
name
stringThe name of the NPC.
role
RoleTypeIdThe RoleTypeId of the NPC.
position
Vector3The position where the NPC should spawn.
Returns
- Npc
Docs4.