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
referenceHubReferenceHub
Npc(GameObject)
Represents the in-game player, by encapsulating a ReferenceHub.
public Npc(GameObject gameObject)
Parameters
gameObjectGameObject
Fields
SpawnSetRoleDelay
The time it takes for the NPC to receive its CustomHumeShieldStat and Role.
public const float SpawnSetRoleDelay = 0.5
Field Value
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
playerPlayerthe 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
playerPlayerthe Player to follow.
maxDistancefloatthe max distance the npc will go.
minDistancefloatthe min distance the npc will go.
speedfloatthe speed the npc will go.
Get(CommandSender)
Retrieves the NPC associated with the specified CommandSender.
public static Npc? Get(CommandSender sender)
Parameters
senderCommandSenderThe CommandSender to retrieve the NPC for.
Returns
- Npc
The NPC associated with the CommandSender, or
nullif not found.
Get(ICommandSender)
Retrieves the NPC associated with the specified ICommandSender.
public static Npc? Get(ICommandSender sender)
Parameters
senderICommandSenderThe ICommandSender to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ICommandSender, or
nullif not found.
Get(Footprint)
Retrieves the NPC associated with the specified Footprint.
public static Npc? Get(Footprint footprint)
Parameters
footprintFootprintThe Footprint to retrieve the NPC for.
Returns
- Npc
The NPC associated with the Footprint, or
nullif not found.
Get(NetworkConnection)
Retrieves the NPC associated with the specified NetworkConnection.
public static Npc? Get(NetworkConnection conn)
Parameters
connNetworkConnectionThe NetworkConnection to retrieve the NPC for.
Returns
- Npc
The NPC associated with the NetworkConnection, or
nullif not found.
Get(ReferenceHub)
Retrieves the NPC associated with the specified ReferenceHub.
public static Npc? Get(ReferenceHub rHub)
Parameters
rHubReferenceHubThe ReferenceHub to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ReferenceHub, or
nullif not found.
Get(int)
Retrieves the NPC associated with the specified ID.
public static Npc? Get(int id)
Parameters
idintThe ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the ID, or
nullif not found.
Get(string)
Retrieves the NPC associated with the specified user ID.
public static Npc? Get(string userId)
Parameters
userIdstringThe user ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the user ID, or
nullif not found.
Get(uint)
Retrieves the NPC associated with the specified net ID.
public static Npc? Get(uint netId)
Parameters
netIduintThe net ID to retrieve the NPC for.
Returns
- Npc
The NPC associated with the net ID, or
nullif not found.
Get(Collider)
Retrieves the NPC associated with the specified Collider.
public static Npc? Get(Collider collider)
Parameters
colliderColliderThe Collider to retrieve the NPC for.
Returns
- Npc
The NPC associated with the Collider, or
nullif not found.
Get(GameObject)
Retrieves the NPC associated with the specified GameObject.
public static Npc? Get(GameObject gameObject)
Parameters
gameObjectGameObjectThe GameObject to retrieve the NPC for.
Returns
- Npc
The NPC associated with the GameObject, or
nullif not found.
LateDestroy(float)
Schedules the destruction of the NPC after a delay.
public void LateDestroy(float time)
Parameters
timefloatThe 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
namestringThe name of the NPC.
roleRoleTypeIdThe RoleTypeId of the NPC, defaulting to None.
ignoredboolWhether the NPC should be ignored by round ending checks.
positionVector3?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
namestringThe name of the NPC.
roleRoleTypeIdThe RoleTypeId of the NPC.
positionVector3The position where the NPC should spawn.
Returns
- Npc
Docs4.