From 86029981bba07822d0745ea22b36cd6a71b88f3a Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Thu, 21 Sep 2023 18:59:51 +0200 Subject: [PATCH] feat(scripting/properties): add Cinemascope, PlayerControls and PlayerInterface classes --- src/scripting/properties/Cinemascope.ts | 36 +++++++++++++++++++ src/scripting/properties/PlayerControls.ts | 22 ++++++++++++ src/scripting/properties/PlayerInterface.ts | 38 +++++++++++++++++++++ src/scripting/properties/index.ts | 3 ++ 4 files changed, 99 insertions(+) create mode 100644 src/scripting/properties/Cinemascope.ts create mode 100644 src/scripting/properties/PlayerControls.ts create mode 100644 src/scripting/properties/PlayerInterface.ts diff --git a/src/scripting/properties/Cinemascope.ts b/src/scripting/properties/Cinemascope.ts new file mode 100644 index 00000000..a71e056f --- /dev/null +++ b/src/scripting/properties/Cinemascope.ts @@ -0,0 +1,36 @@ +import { ScriptProperty } from '@scripting/ScriptProperty.js' + +/** + * A ScriptProperty for enabling or disabling cinematic borders + * + * @extends ScriptProperty + * @see https://wiki.arx-libertatis.org/Script:cinemascope + */ +export class Cinemascope extends ScriptProperty { + isSliding: boolean + + constructor(value: boolean, isSliding: boolean = false) { + super(value) + this.isSliding = isSliding + } + + toString() { + return `cinemascope ${this.isSliding === true ? '-s' : ''} ${this.value === true ? 'on' : 'off'}` + } + + static get on() { + return new Cinemascope(true) + } + + static get off() { + return new Cinemascope(false) + } + + static get slideIn() { + return new Cinemascope(true, true) + } + + static get slideOut() { + return new Cinemascope(false, true) + } +} diff --git a/src/scripting/properties/PlayerControls.ts b/src/scripting/properties/PlayerControls.ts new file mode 100644 index 00000000..72e5b8bd --- /dev/null +++ b/src/scripting/properties/PlayerControls.ts @@ -0,0 +1,22 @@ +import { ScriptProperty } from '@scripting/ScriptProperty.js' + +/** + * A ScriptProperty for enabling and disabling user input. + * Disabling player controls are necessary during cutscenes. + * + * @extends ScriptProperty + * @see https://wiki.arx-libertatis.org/Script:setplayercontrols + */ +export class PlayerControls extends ScriptProperty { + toString() { + return `setplayercontrols ${this.value === true ? 'on' : 'off'}` + } + + static get on() { + return new PlayerControls(true) + } + + static get off() { + return new PlayerControls(false) + } +} diff --git a/src/scripting/properties/PlayerInterface.ts b/src/scripting/properties/PlayerInterface.ts new file mode 100644 index 00000000..6b835b4f --- /dev/null +++ b/src/scripting/properties/PlayerInterface.ts @@ -0,0 +1,38 @@ +import { ScriptProperty } from '@scripting/ScriptProperty.js' + +/** + * A ScriptProperty for showing and hiding a good chunk of the HUD. + * This command does not fully hide the HUD, only some parts of it. + * Currently the equipment indicators, inventories and minimap remain visible. + * + * @extends ScriptProperty + * @see https://wiki.arx-libertatis.org/Script:playerinterface + */ +export class PlayerInterface extends ScriptProperty { + isSliding: boolean + + constructor(value: boolean, isSliding: boolean = false) { + super(value) + this.isSliding = isSliding + } + + toString() { + return `playerinterface ${this.isSliding === true ? '-s' : ''} ${this.value === true ? 'on' : 'off'}` + } + + static get on() { + return new PlayerInterface(true) + } + + static get off() { + return new PlayerInterface(false) + } + + static get slideIn() { + return new PlayerInterface(true, true) + } + + static get slideOut() { + return new PlayerInterface(false, true) + } +} diff --git a/src/scripting/properties/index.ts b/src/scripting/properties/index.ts index 7b22eb57..47847d86 100644 --- a/src/scripting/properties/index.ts +++ b/src/scripting/properties/index.ts @@ -1,9 +1,12 @@ +export { Cinemascope } from '@scripting/properties/Cinemascope.js' export { Collision } from '@scripting/properties/Collision.js' export { ControlZone } from '@scripting/properties/ControlZone.js' export { Interactivity } from '@scripting/properties/Interactivity.js' export { Invulnerability } from '@scripting/properties/Invulnerability.js' export { Label } from '@scripting/properties/Label.js' export { Material } from '@scripting/properties/Material.js' +export { PlayerControls } from '@scripting/properties/PlayerControls.js' +export { PlayerInterface } from '@scripting/properties/PlayerInterface.js' export { Scale } from '@scripting/properties/Scale.js' export { Shadow } from '@scripting/properties/Shadow.js' export { Speed } from '@scripting/properties/Speed.js'