Skip to content

Smoke trails for nukes#3402

Open
Restart2008 wants to merge 2 commits intomainfrom
smoke
Open

Smoke trails for nukes#3402
Restart2008 wants to merge 2 commits intomainfrom
smoke

Conversation

@Restart2008
Copy link
Contributor

@Restart2008 Restart2008 commented Mar 11, 2026

Description: Added smoke trails to nukes for cooler in flight nuke animation, also put smoke trails under the special effects setting. When the player enables special effects setting then smoke trails is also enabled. When special effects is disabled then smoke trails is also disabled.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • 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:

Restart

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

Walkthrough

The changes introduce a new smoke trail particle effect system for missiles, integrate it into the FX rendering layer to handle specific missile unit types (AtomBomb, HydrogenBomb, MIRV, MIRVWarhead, SAMMissile), and refactor coordinate handling in unit interactions to avoid mutating input parameters.

Changes

Cohort / File(s) Summary
Smoke Trail Particle System
src/client/graphics/fx/SmokeTrailFx.ts
New smoke trail effect class with internal particle lifecycle management. Particles spawn near units with slight offset, drift and grow over time, fade with age, and are removed when life expires. SmokeTrailFx emits particles on active units and manages rendering based on unit state and remaining particles.
FX Layer Integration
src/client/graphics/layers/FxLayer.ts
Added SmokeTrailFx import and per-unit missile trail tracking. Creates smoke trail effects for specific missile types (AtomBomb, HydrogenBomb, MIRV, MIRVWarhead, SAMMissile) on unit activation. Updates rendering condition to include missile trails and implements trail lifecycle cleanup during render ticks.
Unit Interaction Refactoring
src/client/graphics/layers/UnitLayer.ts
Refactored onMouseUp to use intermediate targetRef variable instead of mutating clickRef parameter. Updates validation and events (isOcean, MoveWarshipIntentEvent, warship selection) to use the new reference, eliminating parameter mutation patterns.

Sequence Diagram

sequenceDiagram
    participant Unit as Unit Activation
    participant FxLayer as FX Layer
    participant SmokeTrail as SmokeTrailFx
    participant Canvas as Canvas Render
    
    Unit->>FxLayer: Unit activated (missile type)
    FxLayer->>SmokeTrail: Create SmokeTrailFx(game, unitId)
    FxLayer->>FxLayer: Store in missileTrails map
    
    loop Each Render Frame
        FxLayer->>SmokeTrail: renderTick(duration, ctx)
        SmokeTrail->>SmokeTrail: Emit new particle if active
        SmokeTrail->>SmokeTrail: Update all particles (position, size, color)
        SmokeTrail->>Canvas: Draw particles to context
        SmokeTrail->>FxLayer: Return active status
        alt Effect Complete
            FxLayer->>FxLayer: Remove from missileTrails
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

Smoke trails bloom as missiles take flight ✨💨
Particles drift and fade into night
Each frame brings new wisps, old ones fade
A visual dance that effects have made
Canvas painted with ephemeral shade

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding smoke trail visual effects specifically for nuclear weapons in the game.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly explains the feature added (smoke trails for nukes) and its relationship to the special effects setting, which aligns with the code changes shown in the summary.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +130 to 157
let targetRef = clickRef;
if (targetRef === undefined) {
// Convert screen coordinates to world coordinates
const cell = this.transformHandler.screenToWorldCoordinates(
event.x,
event.y,
);
if (!this.game.isValidCoord(cell.x, cell.y)) return;

clickRef = this.game.ref(cell.x, cell.y);
targetRef = this.game.ref(cell.x, cell.y);
}
if (!this.game.isOcean(clickRef)) return;
if (!this.game.isOcean(targetRef)) return;

if (this.selectedUnit) {
this.eventBus.emit(
new MoveWarshipIntentEvent(this.selectedUnit.id(), clickRef),
new MoveWarshipIntentEvent(this.selectedUnit.id(), targetRef),
);
// Deselect
this.eventBus.emit(new UnitSelectionEvent(this.selectedUnit, false));
return;
}

// Find warships near this tile, sorted by distance
nearbyWarships ??= this.findWarshipsNearCell(clickRef);
if (nearbyWarships.length > 0) {
const warships = nearbyWarships ?? this.findWarshipsNearCell(targetRef);
if (warships.length > 0) {
// Toggle selection of the closest warship
this.eventBus.emit(new UnitSelectionEvent(nearbyWarships[0], true));
this.eventBus.emit(new UnitSelectionEvent(warships[0], true));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Mar 14, 2026
@evanpelle evanpelle requested a review from DevelopingTom March 16, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

2 participants