| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Mischief.ECS.World.Modify
Synopsis
- modify :: (Updateable (Result c), Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System ()
- modify' :: (Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System ()
- alter :: (Queryable (C c) (Result c), Bundle c, Component c) => (Maybe c -> Maybe c) -> Entity -> System ()
Documentation
modify :: (Updateable (Result c), Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System () Source #
Modifies the value of the component with the given function.
The function will be applied over the live value of the component, adding some overhead.
If you are confident the value in the Result is the live one, or otherwise do not care of updating the live value,
you are encouraged to use modify' instead.
Note that this will trigger change detection even if the provided function is id.
modify' :: (Settable (Result c) i, DeepValue (Result c) i) => Result c -> (i -> i) -> System () Source #
Modifies the value of the component with the given function.
The function will be applied over the value contained within the Result, which is not guaranteed
to be the live value of the component.
If you wish to apply the function over the live value, use modify instead.
Note that this will trigger change detection even if the provided function is id.
alter :: (Queryable (C c) (Result c), Bundle c, Component c) => (Maybe c -> Maybe c) -> Entity -> System () Source #
The most generic function for modifying a component on a given entity.
This can do removals, insertions, and modify the value.
Example:
data Counter = CounterIntderiving (Component,Queryable) incrementCounter ::Entity->System() incrementCounter =alter(caseNothing->Just$ Counter 0;Just(Counter x) ->Just$ Counter (x + 1))