diff --git a/EXILED/Exiled.API/Features/Npc.cs b/EXILED/Exiled.API/Features/Npc.cs index a52cee705..fac23db4f 100644 --- a/EXILED/Exiled.API/Features/Npc.cs +++ b/EXILED/Exiled.API/Features/Npc.cs @@ -442,12 +442,10 @@ public bool TryLookAtDirection(Vector3 dir, float lerp = 1) /// /// The strength used to jump. Null will choose the default one. /// True if successful. - 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; @@ -458,16 +456,14 @@ public bool Jump(float? jumpStrength = null) /// /// The kind of candy to eat. /// True if successful. - 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; @@ -479,7 +475,7 @@ public bool EatCandy(CandyKindID candyKind) /// The bag. /// The kind of candy to eat. /// True if successful. - public bool EatCandy(Scp330 from, CandyKindID candyKind) + public bool TryEatCandy(Scp330 from, CandyKindID candyKind) { for (int i = 0; i < from.Candies.Count; i++) { @@ -535,24 +531,24 @@ public void CancelUseItem(Item item) /// /// Specifies if the shooting is to be held. /// True if successful. - public bool Shoot(bool hold) => - RunItemAction(CurrentItem, ActionName.Shoot, hold); + public bool TryShoot(bool hold) => + TryRunItemAction(CurrentItem, ActionName.Shoot, hold); /// /// Forces the Npc to reload. /// /// Specifies if the reloading is to be held. /// True if successful. - public bool Reload(bool hold) => - RunItemAction(CurrentItem, ActionName.Reload, hold); + public bool TryReload(bool hold) => + TryRunItemAction(CurrentItem, ActionName.Reload, hold); /// /// Forces the Npc to zoom. /// /// Specifies if the zooming is to be held. /// True if successful. - public bool Zoom(bool hold) => - RunItemAction(CurrentItem, ActionName.Zoom, hold); + public bool TryZoom(bool hold) => + TryRunItemAction(CurrentItem, ActionName.Zoom, hold); /// /// Forces the Npc to run generic action with item. @@ -561,8 +557,8 @@ public bool Zoom(bool hold) => /// The name of action to force. /// Specifies if the action is to be held. /// True if successful. - 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); /// /// Forces the Npc to stop generic action with item. @@ -570,8 +566,8 @@ public bool RunItemAction(Item item, ActionName name, bool hold = true) => /// The to stop action for. /// The name of action to stop. /// True if successful. - public bool StopItemAction(Item item, ActionName name) => - StopAction(item?.DummyEmulator, name); + public bool TryStopItemAction(Item item, ActionName name) => + TryStopAction(item?.DummyEmulator, name); /// /// Checks if certain action is currently active. @@ -590,9 +586,9 @@ public bool IsBeingDone(Item item, ActionName name) => /// Specifies if the action is to be held. /// . /// True if successful. - public bool RunSubroutineAction(T subroutine, ActionName name, bool hold = true) + public bool TryRunSubroutineAction(T subroutine, ActionName name, bool hold = true) where T : SubroutineBase => - RunAction(subroutine?.DummyEmulator, name, hold); + TryRunAction(subroutine?.DummyEmulator, name, hold); /// /// Forces the Npc to stop generic action with subroutine. @@ -601,9 +597,9 @@ public bool RunSubroutineAction(T subroutine, ActionName name, bool hold = tr /// The name of action to stop. /// . /// True if successful. - public bool StopSubroutineAction(T subroutine, ActionName name) + public bool TryStopSubroutineAction(T subroutine, ActionName name) where T : SubroutineBase => - StopAction(subroutine?.DummyEmulator, name); + TryStopAction(subroutine?.DummyEmulator, name); /// /// Checks if certain action is currently active. @@ -623,7 +619,7 @@ public bool IsBeingDone(T subroutine, ActionName name) /// The name of action to force. /// Specifies if the action is to be held. /// True if successful. - public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) + public bool TryRunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) { if (emulator == null) return false; @@ -638,7 +634,7 @@ public bool RunAction(DummyKeyEmulator? emulator, ActionName name, bool hold) /// The to stop action for. /// The name of action to stop. /// True if successful. - public bool StopAction(DummyKeyEmulator? emulator, ActionName name) + public bool TryStopAction(DummyKeyEmulator? emulator, ActionName name) { if (emulator == null) return false;