Files
integration/Docs/OLD/Attention Lock.md
2026-02-05 12:41:07 -05:00

2.2 KiB
Raw Blame History

Attention Lock

Note: at this time, none of the following is implemented.

Attention lock is a new mechanism that is used when you want to force the player to give his undivided attention to a single activity. Attention lock is particularly relevant for turn-based combat. Lets say you have a turn-based combat in progress. You dont want the player to wander away and grow flax when its his turn to attack.

The attention lock mechanism can affect the following aspects of the game:

  • Stops the player from walking around (or walking away).
  • Stops the player from clicking on unrelated sprites.
  • Hides the gui interfaces of unrelated sprites.
  • Forces the gui of a sprite to appear even if the user didnt click on that sprite.
  • Directs the camera to point at a specific place, or a specific object.

Enabling Attention Lock

The mechanism is as follows: the player sprite has a single field, actor.attention, which is a pointer to a sprite that is trying to hold the players attention. There is a second field, actor.attentionID, which must be equal to place.attentionID of the attention-holding sprite. If attentionID doesnt match, then actor.attention field is considered no longer valid, and the attention is considered to be not held. With that protocol, it is easy to implement these functions:

  • function attentionClear(place)

    • Release the attention of all sprites paying attention to place.
    • Implementation: set attentionID to a new unique ID.
  • function attentionHolder(actor)

    • Return the ID of the sprite holding actors attention.
    • Implementation: returns actor.attention after verifying attentionID match.
  • function attentionGrab(place, actor):

    • Cause place to grab the attention of actor.
    • Implementation: sets actor.attention to place, copies attentionID to actor.

This is designed to be resilient to bugs: lets say a battleground is holding the attention of some actor. If the battleground gets bulldozed, attention is implicitly released. Or if the battleground starts a new battle, attention of previous combatants would be implicitly released. In short, it should be pretty easy to clean up messes caused by buggy sprites grabbing attention.