feat: процедурный ghost-превью ленты (с поворотами)#18
Merged
Conversation
Ghost инструмента belt теперь рисуется тем же кодом, что и настоящие ленты (экспортированы beltShape/makePath/drawTrack из belts.ts): - на ховере — одиночный тайл нового вида, форма считается с учётом уже стоящих лент → сразу показывает поворот/стыковку; - при протяжке — превью всей линии целиком с углами (rasterizeLine); - ok → обычные цвета ленты (alpha), bad (наезд на станок) → красный тинт. Статично, без бегущих шевронов. Старый спрайтовый ghost — только не-лента. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the belt tool ghost preview to use the same procedural belt rendering as real belts, so the preview reflects correct corner/connection shapes (including when dragging a full line).
Changes:
- Exported
beltShape,makePath, anddrawTrackfromweb/src/game/belts.tsfor reuse. - Added a belt-specific procedural ghost renderer in
web/src/game/input.ts(single-tile hover and full-line drag preview) with ok/bad tinting. - Kept sprite-based ghost behavior for non-belt tools.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| web/src/game/input.ts | Adds a Graphics-pool-based procedural belt ghost preview (hover + dragged line), and routes belt tool ghost handling through it. |
| web/src/game/belts.ts | Exports belt shape/path/track helpers so belt ghost preview can reuse the real belt renderer. |
Comments suppressed due to low confidence (1)
web/src/game/input.ts:216
updateBeltGhostперерисовываетGraphics(черезdrawTrack(g, ...)) на каждыйpointermove, даже если форма тайла не изменилась. Для длинной линии это может быть заметно дорого. Можно кэшироватьshapeKeyна самомGraphics(например, черезg.name) и вызыватьdrawTrackтолько когдаkind/enter/exitизменились.
const ent: Entity = { id: 'ghost', kind: 'belt', pos: t.pos, dir: t.dir, config: {} };
const shape = beltShape(ent, byTile);
drawTrack(g, shape, makePath(shape));
g.position.set(t.pos.x * TILE, t.pos.y * TILE);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+196
to
+203
| let ok = true; | ||
| for (const t of tiles) { | ||
| const test: Entity = { id: 'ghost', kind: 'belt', pos: t.pos, dir: t.dir, config: {} }; | ||
| if (!(canPlace(store.entities, test) || beltAt(t.pos) !== null)) { | ||
| ok = false; | ||
| break; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что
Ghost-превью инструмента belt больше не старый спрайт
belt.png, а тот же процедурный рендер, что и настоящие ленты (экспортированыbeltShape/makePath/drawTrackизbelts.ts):rasterizeLine), как ляжет после отпускания;Проверка
pnpm typecheck✓,pnpm build✓belts.ts) — авто-мердж стратегией ort, конфликтов нет, оба изменения сохранены🤖 Generated with Claude Code