#automatic #bevy #attributes #values #gamedev #modifier #highly

bevy_attr

Automatic management of highly modular, highly parallel values with minimal overhead

1 unstable release

0.1.0 Nov 12, 2022

#13 in #modifier

MIT/Apache

25KB
180 lines

bevy_attr

Crates.io MIT/Apache 2.0 Docs.rs GitHub

Automatic management of highly modular, highly parallel values in Bevy with minimal overhead.

bevy version crate version
0.9.0-dev 0.1.0-dev

This crate consists of attributes which are components that contain simple values and modifiers (also components) which automatically edit the values of attributes.

The relationship between the Attribute and Modifier traits can be thought of as similar to that between Bevy's GlobalTransform and Transform components. Once per frame, any changed, added, or removed modifiers will force a refresh on the attribute in the same entity. All of the modifiers on the entity will be collected and sorted and sequentially re-applied to the default value of the attribute. Although impractical, Transform could be implemented as a modifier on a GlobalTransform which copies the data in the Transform into the GlobalTransform, but this crate works best with many concurrent modifiers.

In a Bevy app, example uses of attributes could be stat systems where Strength and Endurance both implement the Attribute trait and whose modifiers are updated infrequently, or more dynamic systems where Health and MaxHealth implement it. Since both attributes and modifiers are just components, in that example, it may be a good idea to have MaxHealth be a modifier for Health.

View the examples here

Dependencies

~19–35MB
~594K SLoC