Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions EXILED/Exiled.API/Features/Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,10 @@ public bool TryLookAtDirection(Vector3 dir, float lerp = 1)
/// </summary>
/// <param name="jumpStrength">The strength used to jump. Null will choose the default one.</param>
/// <returns>True if successful.</returns>
public bool Jump(float? jumpStrength = null)
public bool TryJump(float? jumpStrength = null)
{
if (Role is not FpcRole fpcRole)
{
return false;
}

fpcRole.Jump(jumpStrength);
return true;
Expand All @@ -458,16 +456,14 @@ public bool Jump(float? jumpStrength = null)
/// </summary>
/// <param name="candyKind">The kind of candy to eat.</param>
/// <returns>True if successful.</returns>
public bool EatCandy(CandyKindID candyKind)
public bool TryEatCandy(CandyKindID candyKind)
{
foreach(Item? item in Items)
{
if (item is not Scp330 scp330)
{
continue;
}

return EatCandy(scp330, candyKind);
return TryEatCandy(scp330, candyKind);
}

return false;
Expand All @@ -479,7 +475,7 @@ public bool EatCandy(CandyKindID candyKind)
/// <param name="from">The <see cref="Scp330"/> bag.</param>
/// <param name="candyKind">The kind of candy to eat.</param>
/// <returns>True if successful.</returns>
public bool EatCandy(Scp330 from, CandyKindID candyKind)
public bool TryEatCandy(Scp330 from, CandyKindID candyKind)
{
for (int i = 0; i < from.Candies.Count; i++)
{
Expand Down Expand Up @@ -535,24 +531,24 @@ public void CancelUseItem(Item item)
/// </summary>
/// <param name="hold">Specifies if the shooting is to be held.</param>
/// <returns>True if successful.</returns>
public bool Shoot(bool hold) =>
RunItemAction(CurrentItem, ActionName.Shoot, hold);
public bool TryShoot(bool hold) =>
TryRunItemAction(CurrentItem, ActionName.Shoot, hold);

/// <summary>
/// Forces the Npc to reload.
/// </summary>
/// <param name="hold">Specifies if the reloading is to be held.</param>
/// <returns>True if successful.</returns>
public bool Reload(bool hold) =>
RunItemAction(CurrentItem, ActionName.Reload, hold);
public bool TryReload(bool hold) =>
TryRunItemAction(CurrentItem, ActionName.Reload, hold);

/// <summary>
/// Forces the Npc to zoom.
/// </summary>
/// <param name="hold">Specifies if the zooming is to be held.</param>
/// <returns>True if successful.</returns>
public bool Zoom(bool hold) =>
RunItemAction(CurrentItem, ActionName.Zoom, hold);
public bool TryZoom(bool hold) =>
TryRunItemAction(CurrentItem, ActionName.Zoom, hold);

/// <summary>
/// Forces the Npc to run generic action with item.
Expand All @@ -561,17 +557,17 @@ public bool Zoom(bool hold) =>
/// <param name="name">The name of action to force.</param>
/// <param name="hold">Specifies if the action is to be held.</param>
/// <returns>True if successful.</returns>
public bool RunItemAction(Item item, ActionName name, bool hold = true) =>
RunAction(item?.DummyEmulator, name, hold);
public bool TryRunItemAction(Item item, ActionName name, bool hold = true) =>
TryRunAction(item?.DummyEmulator, name, hold);

/// <summary>
/// Forces the Npc to stop generic action with item.
/// </summary>
/// <param name="item">The <see cref="Item"/> to stop action for.</param>
/// <param name="name">The name of action to stop.</param>
/// <returns>True if successful.</returns>
public bool StopItemAction(Item item, ActionName name) =>
StopAction(item?.DummyEmulator, name);
public bool TryStopItemAction(Item item, ActionName name) =>
TryStopAction(item?.DummyEmulator, name);

/// <summary>
/// Checks if certain action is currently active.
Expand All @@ -590,9 +586,9 @@ public bool IsBeingDone(Item item, ActionName name) =>
/// <param name="hold">Specifies if the action is to be held.</param>
/// <typeparam name="T"><see cref="SubroutineBase"/>.</typeparam>
/// <returns>True if successful.</returns>
public bool RunSubroutineAction<T>(T subroutine, ActionName name, bool hold = true)
public bool TryRunSubroutineAction<T>(T subroutine, ActionName name, bool hold = true)
where T : SubroutineBase =>
RunAction(subroutine?.DummyEmulator, name, hold);
TryRunAction(subroutine?.DummyEmulator, name, hold);

/// <summary>
/// Forces the Npc to stop generic action with subroutine.
Expand All @@ -601,9 +597,9 @@ public bool RunSubroutineAction<T>(T subroutine, ActionName name, bool hold = tr
/// <param name="name">The name of action to stop.</param>
/// <typeparam name="T"><see cref="SubroutineBase"/>.</typeparam>
/// <returns>True if successful.</returns>
public bool StopSubroutineAction<T>(T subroutine, ActionName name)
public bool TryStopSubroutineAction<T>(T subroutine, ActionName name)
where T : SubroutineBase =>
StopAction(subroutine?.DummyEmulator, name);
TryStopAction(subroutine?.DummyEmulator, name);

/// <summary>
/// Checks if certain action is currently active.
Expand All @@ -623,7 +619,7 @@ public bool IsBeingDone<T>(T subroutine, ActionName name)
/// <param name="name">The name of action to force.</param>
/// <param name="hold">Specifies if the action is to be held.</param>
/// <returns>True if successful.</returns>
public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold)
public bool TryRunAction(DummyKeyEmulator? emulator, ActionName name, bool hold)
{
if (emulator == null)
return false;
Expand All @@ -638,7 +634,7 @@ public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold)
/// <param name="emulator">The <see cref="DummyKeyEmulator"/> to stop action for.</param>
/// <param name="name">The name of action to stop.</param>
/// <returns>True if successful.</returns>
public bool StopAction(DummyKeyEmulator? emulator, ActionName name)
public bool TryStopAction(DummyKeyEmulator? emulator, ActionName name)
{
if (emulator == null)
return false;
Expand Down
Loading