_internal.classes.focus._base.BaseFocusable - vladzaharia/bitburner GitHub Wiki

Class: BaseFocusable

_internal/classes/focus/_base.BaseFocusable

Abstract class handling priority and sleep returns.

abstract

implements IFocusable

Hierarchy

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BaseFocusable(name, ns, priority, detailField?, sleepTime?, checkInterval?)

Creates a new focusable action.

Parameters

Name Type Default value Description
name string undefined The name of this focusable.
ns NS undefined The Netscript object.
priority number undefined Priority this action should run at, lower first.
detailField? string undefined -
sleepTime number DEFAULT_SLEEP_TIME Time to sleep after a successful focus event, defaults to 15 minutes.
checkInterval number DEFAULT_CHECK_INTERVAL -

Defined in

_internal/classes/focus/_base.ts:44

Properties

_checkInterval

Private _checkInterval: number

Interval to check while sleeping.

Defined in

_internal/classes/focus/_base.ts:30


_detailField

Private _detailField: undefined | string

Field to pull detail from.

Defined in

_internal/classes/focus/_base.ts:33


_ns

Protected _ns: NS

The Netscript object.

Defined in

_internal/classes/focus/_base.ts:21


_priority

Private _priority: number

Priority of this focusable.

Defined in

_internal/classes/focus/_base.ts:24


_sleepTime

Private _sleepTime: number

Time to sleep after a successful focus event.

Defined in

_internal/classes/focus/_base.ts:27


name

name: string

The name of the focusable.

Implementation of

IFocusable.name

Defined in

_internal/classes/focus/_base.ts:18

Methods

_focus

Protected _focus(): boolean

Execute focus using ns.singularity, must be implemented by subclass.

virtual Must be overridden by implementing classes.

Returns

boolean

Whether the focus action was successful.

Defined in

_internal/classes/focus/_base.ts:151


canFocus

canFocus(): boolean

virtual Must be overridden by implementing classes.

Returns

boolean

Implementation of

IFocusable.canFocus

Defined in

_internal/classes/focus/_base.ts:67


focus

focus(): number

Executes a focus action, returning a predefined sleep time.

Returns

number

_sleepTime if successful, -1 otherwise.

Implementation of

IFocusable.focus

Defined in

_internal/classes/focus/_base.ts:76


getCheckInterval

getCheckInterval(): number

Gets how often to check for task completion, defaults to this._checkInterval.

Returns

number

How often to check for task completion.

Implementation of

IFocusable.getCheckInterval

Defined in

_internal/classes/focus/_base.ts:118


getDetailText

getDetailText(): string

Returns value from preset field.

Returns

string

Value of this._detailField if set, "" otherwise

Implementation of

IFocusable.getDetailText

Defined in

_internal/classes/focus/_base.ts:137


getFocusTime

getFocusTime(): number

Get time needed for task, defaults to this._sleepTime.

Returns

number

The time to sleep before running the manager again.

Implementation of

IFocusable.getFocusTime

Defined in

_internal/classes/focus/_base.ts:109


getPriority

getPriority(): number

Gets the current priority of the focusable action.

Returns

number

Current priority, with 0 being the highest.

Implementation of

IFocusable.getPriority

Defined in

_internal/classes/focus/_base.ts:60


shouldContinueRunning

shouldContinueRunning(): boolean

Checks if the player is still working.

virtual Can be overridden, but run super.shouldContinueRunning if you do.

Returns

boolean

True if user is still working, false otherwise.

Implementation of

IFocusable.shouldContinueRunning

Defined in

_internal/classes/focus/_base.ts:128


shouldRunInBackground

shouldRunInBackground(): boolean

Checks if the action should run in the background, defaults to if priority is > 50.

Returns

boolean

True if this can run in the background, False if it needs to be in the foreground.

Implementation of

IFocusable.shouldRunInBackground

Defined in

_internal/classes/focus/_base.ts:95

⚠️ **GitHub.com Fallback** ⚠️