From b5090b83f06d8d6a98141560a89b515187a2f7b6 Mon Sep 17 00:00:00 2001 From: Connie Sarah Date: Sun, 20 Oct 2024 20:25:21 +0300 Subject: [PATCH] Small cleanup and reorganization of Shape .ts files Imo, there's no reason why there should be really small .ts files defining stuff that could very well just... exist in another .ts file (per example, Small Duct Fans shouldn't have their own .ts file, but should be part of duct_fan.ts, same thing with all the Signs). It'd also make things more organized (all Duct Fan instances in one file, all Sign instances in one file, all Bumper instances in one file). --- src/ts/level.ts | 11 +++------ src/ts/shapes/abstract_bumper.ts | 11 +++++++++ src/ts/shapes/duct_fan.ts | 20 ++++++++++++++++ src/ts/shapes/round_bumper.ts | 7 ------ src/ts/shapes/sign.ts | 41 ++++++++++++++++++++++++++++++++ src/ts/shapes/sign_caution.ts | 19 --------------- src/ts/shapes/sign_finish.ts | 6 ----- src/ts/shapes/sign_plain.ts | 21 ---------------- src/ts/shapes/small_duct_fan.ts | 22 ----------------- src/ts/shapes/triangle_bumper.ts | 7 ------ 10 files changed, 75 insertions(+), 90 deletions(-) delete mode 100644 src/ts/shapes/round_bumper.ts delete mode 100644 src/ts/shapes/sign_caution.ts delete mode 100644 src/ts/shapes/sign_finish.ts delete mode 100644 src/ts/shapes/sign_plain.ts delete mode 100644 src/ts/shapes/small_duct_fan.ts delete mode 100644 src/ts/shapes/triangle_bumper.ts diff --git a/src/ts/level.ts b/src/ts/level.ts index 1b92dbfe..300ddfa2 100644 --- a/src/ts/level.ts +++ b/src/ts/level.ts @@ -3,16 +3,13 @@ import { Marble, bounceParticleOptions } from "./marble"; import { Shape, SharedShapeData } from "./shape"; import { MissionElementSimGroup, MissionElementType, MissionElementStaticShape, MissionElementItem, MisParser, MissionElementTrigger, MissionElementInteriorInstance, MissionElementTSStatic, MissionElementParticleEmitterNode, MissionElementSky } from "./parsing/mis_parser"; import { StartPad } from "./shapes/start_pad"; -import { SignFinish } from "./shapes/sign_finish"; -import { SignPlain } from "./shapes/sign_plain"; import { EndPad, fireworkSmoke, redSpark, redTrail, blueSpark, blueTrail } from "./shapes/end_pad"; import { Gem } from "./shapes/gem"; import { SuperJump, superJumpParticleOptions } from "./shapes/super_jump"; -import { SignCaution } from "./shapes/sign_caution"; import { SuperBounce } from "./shapes/super_bounce"; -import { RoundBumper } from "./shapes/round_bumper"; +import { RoundBumper, TriangleBumper } from "./shapes/abstract_bumper"; import { Helicopter } from "./shapes/helicopter"; -import { DuctFan } from "./shapes/duct_fan"; +import { DuctFan, SmallDuctFan } from "./shapes/duct_fan"; import { AntiGravity } from "./shapes/anti_gravity"; import { LandMine, landMineSmokeParticle, landMineSparksParticle } from "./shapes/land_mine"; import { ShockAbsorber } from "./shapes/shock_absorber"; @@ -20,12 +17,10 @@ import { SuperSpeed, superSpeedParticleOptions } from "./shapes/super_speed"; import { TimeTravel } from "./shapes/time_travel"; import { Tornado } from "./shapes/tornado"; import { TrapDoor } from "./shapes/trap_door"; -import { TriangleBumper } from "./shapes/triangle_bumper"; import { Oilslick } from "./shapes/oilslick"; import { Util, Scheduler } from "./util"; import { PowerUp } from "./shapes/power_up"; import { isPressed, releaseAllButtons, gamepadAxes, getPressedFlag, resetPressedFlag, hideTouchControls, maybeShowTouchControls, setTouchControlMode } from "./input"; -import { SmallDuctFan } from "./shapes/small_duct_fan"; import { PathedInterior } from "./pathed_interior"; import { Trigger } from "./triggers/trigger"; import { InBoundsTrigger } from "./triggers/in_bounds_trigger"; @@ -39,7 +34,7 @@ import { Replay } from "./replay"; import { Mission } from "./mission"; import { PushButton } from "./shapes/push_button"; import { state } from "./state"; -import { Sign } from "./shapes/sign"; +import { Sign, SignFinish, SignPlain, SignCaution } from "./shapes/sign"; import { Magnet } from "./shapes/magnet"; import { Nuke, nukeSmokeParticle, nukeSparksParticle } from "./shapes/nuke"; import { TeleportTrigger } from "./triggers/teleport_trigger"; diff --git a/src/ts/shapes/abstract_bumper.ts b/src/ts/shapes/abstract_bumper.ts index 9fd9c6f8..d81d4010 100644 --- a/src/ts/shapes/abstract_bumper.ts +++ b/src/ts/shapes/abstract_bumper.ts @@ -37,4 +37,15 @@ export abstract class AbstractBumper extends Shape { super.render(time); } +} + +/** The Bumpers. */ +export class TriangleBumper extends AbstractBumper { + dtsPath = "shapes/bumpers/pball_tri.dts"; + sounds = ["bumper1.wav"]; +} + +export class RoundBumper extends AbstractBumper { + dtsPath = "shapes/bumpers/pball_round.dts"; + sounds = ["bumperding1.wav"]; } \ No newline at end of file diff --git a/src/ts/shapes/duct_fan.ts b/src/ts/shapes/duct_fan.ts index 12388051..749b6a30 100644 --- a/src/ts/shapes/duct_fan.ts +++ b/src/ts/shapes/duct_fan.ts @@ -13,6 +13,26 @@ export class DuctFan extends ForceShape { this.addConicForce(10, 2.617, 40); } + async onLevelStart() { + this.soundSource = this.level.audio.createAudioSource(this.sounds[0], undefined, this.worldPosition); + this.soundSource.setLoop(true); + this.soundSource.play(); + await this.soundSource.promise; + } +} + +/** Blows the marble away, but not much. */ +export class SmallDuctFan extends ForceShape { + dtsPath = "shapes/hazards/ductfan.dts"; + sounds = ["fan_loop.wav"]; + soundSource: AudioSource; + + constructor() { + super(); + + this.addConicForce(5, 2.617, 10); + } + async onLevelStart() { this.soundSource = this.level.audio.createAudioSource(this.sounds[0], undefined, this.worldPosition); this.soundSource.setLoop(true); diff --git a/src/ts/shapes/round_bumper.ts b/src/ts/shapes/round_bumper.ts deleted file mode 100644 index 580c2728..00000000 --- a/src/ts/shapes/round_bumper.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AbstractBumper } from "./abstract_bumper"; - -/** A round bumper. */ -export class RoundBumper extends AbstractBumper { - dtsPath = "shapes/bumpers/pball_round.dts"; - sounds = ["bumperding1.wav"]; -} \ No newline at end of file diff --git a/src/ts/shapes/sign.ts b/src/ts/shapes/sign.ts index 6fae8e66..eff07a98 100644 --- a/src/ts/shapes/sign.ts +++ b/src/ts/shapes/sign.ts @@ -21,4 +21,45 @@ export class Sign extends Shape { } } } +} + +/** A caution/danger sign. */ +export class SignCaution extends Shape { + dtsPath = "shapes/signs/cautionsign.dts"; + shareMaterials = false; + + constructor(element: MissionElementStaticShape) { + super(); + + // Determine the type of the sign + let type = element.datablock.slice("SignCaution".length).toLowerCase(); + switch (type) { + case "caution": this.matNamesOverride["base.cautionsign"] = "caution.cautionsign"; break; + case "danger": this.matNamesOverride["base.cautionsign"] = "danger.cautionsign"; break; + } + } +} + +/** The flickering finish sign, usually above the finish pad. */ +export class SignFinish extends Shape { + dtsPath = "shapes/signs/finishlinesign.dts"; +} + +/** A plain sign showing a direction, used in Marble Blast Gold. */ +export class SignPlain extends Shape { + dtsPath = "shapes/signs/plainsign.dts"; + shareMaterials = false; + + constructor(element: MissionElementStaticShape) { + super(); + + // Determine the direction to show + let direction = element.datablock.slice("SignPlain".length).toLowerCase(); + switch (direction) { + case "right": this.matNamesOverride["base.plainsign"] = "right.plainsign"; break; + case "left": this.matNamesOverride["base.plainsign"] = "left.plainsign"; break; + case "up": this.matNamesOverride["base.plainsign"] = "up.plainsign"; break; + case "down": this.matNamesOverride["base.plainsign"] = "down.plainsign"; break; + } + } } \ No newline at end of file diff --git a/src/ts/shapes/sign_caution.ts b/src/ts/shapes/sign_caution.ts deleted file mode 100644 index 3367b303..00000000 --- a/src/ts/shapes/sign_caution.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Shape } from "../shape"; -import { MissionElementStaticShape } from "../parsing/mis_parser"; - -/** A caution/danger sign. */ -export class SignCaution extends Shape { - dtsPath = "shapes/signs/cautionsign.dts"; - shareMaterials = false; - - constructor(element: MissionElementStaticShape) { - super(); - - // Determine the type of the sign - let type = element.datablock.slice("SignCaution".length).toLowerCase(); - switch (type) { - case "caution": this.matNamesOverride["base.cautionsign"] = "caution.cautionsign"; break; - case "danger": this.matNamesOverride["base.cautionsign"] = "danger.cautionsign"; break; - } - } -} \ No newline at end of file diff --git a/src/ts/shapes/sign_finish.ts b/src/ts/shapes/sign_finish.ts deleted file mode 100644 index a9ae31a0..00000000 --- a/src/ts/shapes/sign_finish.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Shape } from "../shape"; - -/** The flickering finish sign, usually above the finish pad. */ -export class SignFinish extends Shape { - dtsPath = "shapes/signs/finishlinesign.dts"; -} \ No newline at end of file diff --git a/src/ts/shapes/sign_plain.ts b/src/ts/shapes/sign_plain.ts deleted file mode 100644 index 6b1c915d..00000000 --- a/src/ts/shapes/sign_plain.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Shape } from "../shape"; -import { MissionElementStaticShape } from "../parsing/mis_parser"; - -/** A plain sign showing a direction. */ -export class SignPlain extends Shape { - dtsPath = "shapes/signs/plainsign.dts"; - shareMaterials = false; - - constructor(element: MissionElementStaticShape) { - super(); - - // Determine the direction to show - let direction = element.datablock.slice("SignPlain".length).toLowerCase(); - switch (direction) { - case "right": this.matNamesOverride["base.plainsign"] = "right.plainsign"; break; - case "left": this.matNamesOverride["base.plainsign"] = "left.plainsign"; break; - case "up": this.matNamesOverride["base.plainsign"] = "up.plainsign"; break; - case "down": this.matNamesOverride["base.plainsign"] = "down.plainsign"; break; - } - } -} \ No newline at end of file diff --git a/src/ts/shapes/small_duct_fan.ts b/src/ts/shapes/small_duct_fan.ts deleted file mode 100644 index 0320e6ee..00000000 --- a/src/ts/shapes/small_duct_fan.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ForceShape } from "./force_shape"; -import { AudioSource } from "../audio"; - -/** Blows the marble away, but not much. */ -export class SmallDuctFan extends ForceShape { - dtsPath = "shapes/hazards/ductfan.dts"; - sounds = ["fan_loop.wav"]; - soundSource: AudioSource; - - constructor() { - super(); - - this.addConicForce(5, 2.617, 10); - } - - async onLevelStart() { - this.soundSource = this.level.audio.createAudioSource(this.sounds[0], undefined, this.worldPosition); - this.soundSource.setLoop(true); - this.soundSource.play(); - await this.soundSource.promise; - } -} \ No newline at end of file diff --git a/src/ts/shapes/triangle_bumper.ts b/src/ts/shapes/triangle_bumper.ts deleted file mode 100644 index 2bbacf8a..00000000 --- a/src/ts/shapes/triangle_bumper.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AbstractBumper } from "./abstract_bumper"; - -/** A triangle-shaped bumper. */ -export class TriangleBumper extends AbstractBumper { - dtsPath = "shapes/bumpers/pball_tri.dts"; - sounds = ["bumper1.wav"]; -} \ No newline at end of file