pub fn mutate_component_with_default<T>(
    entity: EntityId,
    component: Component<T>,
    default: T,
    mutator: impl FnOnce(&mut T)
) -> T
Expand description

Mutates the component component for entity using the passed in mutator, or sets it to default if it doesn’t exist, and returns its value.

This will not set the component if the value is the same, which will prevent change events from being unnecessarily fired.