munificent/game-programming-patterns

Observer Pattern Logic Question

Opened this issue · 0 comments

I am reading the book (like most others here I believe :D) and a question came up to the observer pattern (page 44-45).

The physics engine (subject) notifies the observer (e.g. achievements) when the entity is not on a surface anymore.

if (wasOnSurface && !entity.isOnSurface()) 
{
    notify(entity, EVENT_START_FALL);
}

and in the Achievements you handle the result of the fall event.

case EVENT_ENTITY_FELL:
    if (entity.isHero() && heroIsOnBridge_)
    {
        unlock(ACHIEVEMENT_FELL_OFF_BRIDGE);
    }
    break;

If I combine some of this logic the entity has fallen and now the entity (hero) is on the bridge should the unlocked achievement not be ACHIEVEMENT_FELL_ON_BRIDGE?
or another possibility the if statement !heroIsOnBridge and the achievement ACHIEVEMENT_FELL_OFF_BRIDGE?

I am a little bit confused, maybe my understanding of fell off and fell on is not good enough. Could you please clarify my logical problem :) thanks in advance.