bevyengine / bevyengine/bevy

Provide easy access to components of targeted entity in observers

オープン
#15,653 コメント 9 件 リアクション 1 件 担当者 0 名 GitHub で見る
A-ECS C-Feature D-Modest S-Ready-For-Implementation
主要言語
Rust
スター
48.2k
フォーク
4.8k
平均マージ
3日 16時間
マージ済み PR(30日)
171

説明

## What problem does this solve or what need does it fill?

When writing observers, it is frequently desirable to be able to access a component on the listener entity, that is, the entity in the trigger event.

Currently there are two ways to do this: either inject a query for all components of that type and pick the one you want; or inject a DeferredWorld, and then look up the component you need on the event's entity.

bevy_mod_picking had convenience methods for injecting components directly. I'd like to see something similar for Bevy.

## What solution would you like?

I'm not sure about naming, but I was thinking of something like:

```rust
entity.observe(trigger: Trigger>, component: ListenerRef);
```
There would be a `ListenerMut` version as well. Alternate names might be `TargetRef`, `TriggerRef`, or `ObserverEntityRef`.

## What alternative(s) have you considered?

For now, I'm using DeferredWorld, as I am unsure about the overhead of injecting a Query.

## Additional context

bevy_mod_picking also provided a means to access the "target" entity and it's components, which was the entity upon which the event was triggered before bubbling, not the entity which handled the event. However, this feature was used rarely (at least by me anyway).

This is also somewhat related to a previous ticket filed by me a long time ago (#11048) - that was rejected (for good reason), but this ticket provides a much more narrowly-scoped variation of the same idea.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず Bevy の既存の Observer、Trigger、Query、DeferredWorld API を確認し、次に提案されているアクセスパターンを以前の issue #11048 および bevy_mod_picking の便利メソッドと比較します。完了条件は、listener entity のコンポーネントへの不変アクセスと可変アクセスのための合意された API があり、その設計とスコープが解決されていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
game-dev
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。