Sending Messages of Intent

Currently, the PlayerInput and RandomMovement systems load the map and check for tile access. As you add more game-play elements, you don’t want to remember to update both of them—and any other system that can produce movement. Instead, you can share a lot of the functionality by having systems that produce movement send a message indicating that an entity intends to move. A later system can then process all of the movement requests and apply them if possible. This is very powerful. Suppose you add a stun mechanic—stunned monsters can’t move. Your system that handles stun could remove movement intention from any entity, and you wouldn’t have to change a line of the other systems.

Messages Can Be Entities Too

Games ...

Get Hands-on Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.