Closed hyranno closed 8 months ago
StateMachine
used to implement Clone
, but I removed it so that triggers don't have to implement Clone
. I recommend this pattern:
let state_machine_builder = || {
StateMachine::default()
.trans<MyState>(MyTrigger, MyOtherState)
};
commands.spawn((
MyState,
state_machine_builder(),
));
commands.spawn((
MyOtherState,
state_machine_builder(),
));
Or break it out into a separate function. I'd accept the impls that are here, though. But I'll wait to see what you think first.
Sounds reasonable.
It is good to allowing things to be not Clone
, and it looks hard to implement Clone
for StateMachine
without forcing its member to be Clone
.
I expected these merits to implement Clone
for StateMachine
:
Clone
will be faster than repeated initializer calls.Clone
for impl Bundle
which contains StateMachine
.But I think these merits are less important.
Thanks!
This PR add
Clone
and some common traits onto triggers and some values for convenience. It is good for reusing triggers.Implementing
Clone
onStateMachine
will be convenient too, but it will conflict with pending PR (#7 ), so I won't implement until it is closed (weather merged or not).