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
CancelUseItem(Item)
Forces the Npc to stop using item.
public void CancelUseItem(Item item)
Parameters
Destroy()
Destroys the NPC.
public void Destroy()
DestroyAll()
Destroys all NPCs currently spawned.
public static void DestroyAll()
EquipItem(Item)
public void EquipItem(Item item)
Parameters
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.
GetActions()
Gets actions that can be done by the Dummy.
public IReadOnlyList<DummyAction> GetActions()
Returns
- IReadOnlyList<DummyAction>
HolsterItem()
public void HolsterItem()
IsBeingDone(Item, ActionName)
Checks if certain action is currently active.
public bool IsBeingDone(Item item, ActionName name)
Parameters
Returns
- bool
True if action is actively executed and emulator is not null.
IsBeingDone(DummyKeyEmulator?, ActionName)
Checks if certain action is currently active.
public bool IsBeingDone(DummyKeyEmulator? emulator, ActionName name)
Parameters
emulatorDummyKeyEmulatorThe NetworkManagerUtils.Dummies.DummyKeyEmulator to check action for.
nameActionNameThe name of action to check.
Returns
- bool
True if action is actively executed and emulator is not null.
IsBeingDone<T>(T, ActionName)
Checks if certain action is currently active.
public bool IsBeingDone<T>(T subroutine, ActionName name) where T : SubroutineBase
Parameters
subroutineTThe PlayerRoles.Subroutines.SubroutineBase to check action for.
nameActionNameThe name of action to check.
Returns
- bool
True if action is actively executed and emulator is not null.
Type Parameters
TPlayerRoles.Subroutines.SubroutineBase.
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.
TryAddHorizontalLook(float)
Makes the Npc look more left or more right.
public bool TryAddHorizontalLook(float amount)
Parameters
amountfloatAmount that will be added to horizontal (in degrees).
Returns
- bool
True if successful.
TryAddVerticalLook(float)
Makes the Npc look more up or more down.
public bool TryAddVerticalLook(float amount)
Parameters
amountfloatAmount that will be added to vertical (in degrees).
Returns
- bool
True if successful.
TryEatCandy(Scp330, CandyKindID)
Makes the Npc eat certain kind of candy.
public bool TryEatCandy(Scp330 from, CandyKindID candyKind)
Parameters
Returns
- bool
True if successful.
TryEatCandy(CandyKindID)
Makes the Npc eat certain kind of candy.
public bool TryEatCandy(CandyKindID candyKind)
Parameters
candyKindCandyKindIDThe kind of candy to eat.
Returns
- bool
True if successful.
TryJump(float?)
Makes the Npc jump by amount of strength.
public bool TryJump(float? jumpStrength = null)
Parameters
jumpStrengthfloat?The strength used to jump. Null will choose the default one.
Returns
- bool
True if successful.
TryLookAtDirection(Vector3, float)
Forces Npc to look at a certain direction.
public bool TryLookAtDirection(Vector3 dir, float lerp = 1)
Parameters
dirVector3The direction to look at.
lerpfloatThe amount in percentage how much to look at the direction, 1 is full and will immediately look at the target direction.
Returns
- bool
True if successful.
TryLookAtPoint(Vector3, float)
Forces Npc to look at certain point.
public bool TryLookAtPoint(Vector3 position, float lerp = 1)
Parameters
positionVector3Position to look at.
lerpfloatThe amount in percentage how much to look at the position, 1 is full and will immediately look at the point.
Returns
- bool
True if successful.
TryMoveRelative(Vector3, float)
Moves this Npc by a direction relative to where they are looking.
public bool TryMoveRelative(Vector3 dir, float distance)
Parameters
dirVector3Direction where Npc should move relative to where they are looking.
distancefloatThe distance that the Npc should move by.
Returns
- bool
True if successful.
TryReload(bool)
Forces the Npc to reload.
public bool TryReload(bool hold)
Parameters
holdboolSpecifies if the reloading is to be held.
Returns
- bool
True if successful.
TryRunAction(DummyKeyEmulator?, ActionName, bool)
Forces the Npc to run generic action with emulator.
public bool TryRunAction(DummyKeyEmulator? emulator, ActionName name, bool hold)
Parameters
emulatorDummyKeyEmulatorThe NetworkManagerUtils.Dummies.DummyKeyEmulator to run action for.
nameActionNameThe name of action to force.
holdboolSpecifies if the action is to be held.
Returns
- bool
True if successful.
TryRunItemAction(Item, ActionName, bool)
Forces the Npc to run generic action with item.
public bool TryRunItemAction(Item item, ActionName name, bool hold = true)
Parameters
itemItemThe Item to run action for.
nameActionNameThe name of action to force.
holdboolSpecifies if the action is to be held.
Returns
- bool
True if successful.
TryRunSubroutineAction<T>(T, ActionName, bool)
Forces the Npc to run generic action with subroutine.
public bool TryRunSubroutineAction<T>(T subroutine, ActionName name, bool hold = true) where T : SubroutineBase
Parameters
subroutineTThe PlayerRoles.Subroutines.SubroutineBase to run action for.
nameActionNameThe name of action to force.
holdboolSpecifies if the action is to be held.
Returns
- bool
True if successful.
Type Parameters
TPlayerRoles.Subroutines.SubroutineBase.
TryShoot(bool)
Forces the Npc to shoot.
public bool TryShoot(bool hold)
Parameters
holdboolSpecifies if the shooting is to be held.
Returns
- bool
True if successful.
TryStopAction(DummyKeyEmulator?, ActionName)
Forces the Npc to stop generic action with emulator.
public bool TryStopAction(DummyKeyEmulator? emulator, ActionName name)
Parameters
emulatorDummyKeyEmulatorThe NetworkManagerUtils.Dummies.DummyKeyEmulator to stop action for.
nameActionNameThe name of action to stop.
Returns
- bool
True if successful.
TryStopItemAction(Item, ActionName)
Forces the Npc to stop generic action with item.
public bool TryStopItemAction(Item item, ActionName name)
Parameters
Returns
- bool
True if successful.
TryStopSubroutineAction<T>(T, ActionName)
Forces the Npc to stop generic action with subroutine.
public bool TryStopSubroutineAction<T>(T subroutine, ActionName name) where T : SubroutineBase
Parameters
subroutineTThe PlayerRoles.Subroutines.SubroutineBase to stop action for.
nameActionNameThe name of action to stop.
Returns
- bool
True if successful.
Type Parameters
TPlayerRoles.Subroutines.SubroutineBase.
TryZoom(bool)
Forces the Npc to zoom.
public bool TryZoom(bool hold)
Parameters
holdboolSpecifies if the zooming is to be held.
Returns
- bool
True if successful.