Simplify gravity control in BehaviorControllers
Currently, it's quite cumbersome to implement behavior controllers that temporarily enable gravity for their entity (e.g. to implement jumping enemies). More specifically, reacting to the object hitting the ground due to gravity.
This is because the physics system runs after behavior controllers, so objects will only hit the ground after their behavior controller has been invoked. This means they have to react in a separate callback, instead of doing it as part of their regular update.
It would be much easier if there was a free-standing applyPhysics function, that would allow controllers to apply physics themselves as part of the update.
Edit: As of #769, this function now exists. It's used for the Spider enemy so far. Adding a convenience wrapper that takes s & d parameters like BehaviorController::update might be nice.
This would allow writing code like this:
if (state == falling) {
applyPhysics();
if (isOnSolidGround()) {
// React to having landed after being in the air
}
}
The following controllers are affected by this:
- [ ] BigBomb
- [ ] BossEpisode1
- [ ] SpikedGreenCreature
- [ ] RedBird
- [ ] RigelatinSoldier
- [ ] SlimeBlob
- [x] Spider
- [ ] SpikeBall
- [ ] WatchBot