From 4eaf3de5de09f60fcd8b9ebdfabb4511b8da3f6b Mon Sep 17 00:00:00 2001 From: DevelopingTom Date: Fri, 17 Oct 2025 04:58:13 +0200 Subject: [PATCH] Add destructed structure FX (#2210) ## Description: New FX on building destruction Icon level: https://github.com/user-attachments/assets/0ba5e557-a5d7-436f-8a58-2843d4c99332 Pixel art level: https://github.com/user-attachments/assets/12002df6-eb46-4853-b84f-4f81ce7c3528 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: IngloriousTom --------- Co-authored-by: Evan --- resources/sprites/buildingExplosion.png | Bin 0 -> 884 bytes src/client/graphics/AnimatedSpriteLoader.ts | 10 +++++++++ src/client/graphics/fx/Fx.ts | 1 + src/client/graphics/layers/FxLayer.ts | 22 ++++++++++++++++++++ src/core/game/Game.ts | 1 + 5 files changed, 34 insertions(+) create mode 100644 resources/sprites/buildingExplosion.png diff --git a/resources/sprites/buildingExplosion.png b/resources/sprites/buildingExplosion.png new file mode 100644 index 0000000000000000000000000000000000000000..de827d4e06ba8a2cc8b854cbd9a64d2b6012c0f2 GIT binary patch literal 884 zcmV-)1B?8LP)Px&E=fc|RA_2(Ocyfe>!_SqLviNAExozMQC$^G)|_fCkdw%Y3LwRmho z=r|bFb9vx#lt=T+XTS&L@!b8y&cild_b`c@hl{Q+&p{n|J+P0hj|_RhCI|pPN}2f` zFsg(6_|5sZEgqY&yPsJ5pPn42f5`7Yey#Q8o@oLi=?}f$f$rlw9(yGHp~UCDK3Lb6 z=g{u-3gc-bL8age>1XwDfEq)pM8Rs4EpoX+5(9P$%vi7%sX`_e1t8=B03d`A*wghH zrmX-ML6sDw_gCe#?d)crp1T0619p4#BrYEI*7|XvU?0lE7qn@$0v~=)B=!w~waBPi z*nf}-Bp-+spkmy3X{Zg-d#)Y|)Ka-Cl-IKIUI<56Pfw2F{;HgTQ$efRI9N@Q&<8eG zj}XveL{_!e3;~t`{#{-(PEtwg1$0n2} zGm$1pIU+HP>cBzBN#9QjK`*N|cyy1X&-bHXb6L_kh<%pySWy*UTO+E1(|5U+D^cwn z#1e_@z(myD{Y0{*sc}Or=PmOb97|g`!EzO@UHUH5RDYjDXj-kXl?Tp)i>RUZO?}v< zKX3M~M_~nNu01L~uMLD=4X|lBZ)Kr$Or}(Vr1qjZlz2-(B~$o?Up(xsqUx(C=yXW% z^-k-jyghnii~Tm;9UO{jwL*^PJlma~R8h`Upm)josr{#mHnwi2q{HY7x=VS=R`93F zQzB=H3TNnfvUQt>&p!3*-#_B+;4mHIo9$!JFucNJ**AHZ#&0C3G3v0f6}#vk@>M9b zjN}r{ImIYL2@TGozivfUj4DIk@BNv1> = { originX: 9, originY: 9, }, + [FxType.BuildingExplosion]: { + url: buildingExplosion, + frameWidth: 17, + frameCount: 10, + frameDuration: 70, + looping: false, + originX: 8, + originY: 8, + }, [FxType.SinkingShip]: { url: sinkingShip, frameWidth: 16, diff --git a/src/client/graphics/fx/Fx.ts b/src/client/graphics/fx/Fx.ts index 2aeb3ccf6..d4b206614 100644 --- a/src/client/graphics/fx/Fx.ts +++ b/src/client/graphics/fx/Fx.ts @@ -9,6 +9,7 @@ export enum FxType { MiniSmokeAndFire = "MiniSmokeAndFire", MiniExplosion = "MiniExplosion", UnitExplosion = "UnitExplosion", + BuildingExplosion = "BuildingExplosion", SinkingShip = "SinkingShip", Nuke = "Nuke", SAMExplosion = "SAMExplosion", diff --git a/src/client/graphics/layers/FxLayer.ts b/src/client/graphics/layers/FxLayer.ts index 027b8dd6c..e5ddf3831 100644 --- a/src/client/graphics/layers/FxLayer.ts +++ b/src/client/graphics/layers/FxLayer.ts @@ -151,6 +151,14 @@ export class FxLayer implements Layer { case UnitType.Train: this.onTrainEvent(unit); break; + case UnitType.DefensePost: + case UnitType.City: + case UnitType.Port: + case UnitType.MissileSilo: + case UnitType.SAMLauncher: + case UnitType.Factory: + this.onStructureEvent(unit); + break; } } @@ -246,6 +254,20 @@ export class FxLayer implements Layer { } } + onStructureEvent(unit: UnitView) { + if (!unit.isActive()) { + const x = this.game.x(unit.lastTile()); + const y = this.game.y(unit.lastTile()); + const explosion = new SpriteFx( + this.animatedSpriteLoader, + x, + y, + FxType.BuildingExplosion, + ); + this.allFx.push(explosion); + } + } + onNukeEvent(unit: UnitView, radius: number) { if (!unit.isActive()) { if (!unit.reachedTarget()) { diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index db48e0a2f..978672084 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -202,6 +202,7 @@ const _structureTypes: ReadonlySet = new Set([ UnitType.SAMLauncher, UnitType.MissileSilo, UnitType.Port, + UnitType.Factory, ]); export function isStructureType(type: UnitType): boolean {