Tile engine A object should not add another object to a field.
The main loop consiste of the folowing three steps:
In this step all objects gather information from other objects, and the received messages, so that it has all information for changing the status and sending messages, because when this is started other objects might have changed. Absolutely nothing should be changed during this step.
In this step objects change their status and send messages, information for this is already gathered in the Gathering information step.
In This step, Non-objects can do things, send message to the objects for use input. Update the screen, and everything else.
The good point of using such an gatherinformation-update status is that nothing changes when you're gathering information and the nothing has precedence over something else, the drawback however is that you have to store somewhere what you're gona change. Also things can happen simutaniesly.
Much of the information is send though messages.
Messages is a simple object, with only a new property for the type of the message. It is recommended to make descendant from TTileMessage to include more information, and always use this messages incombination with a specific message type.
A object has a list with all received messages, this list is cleaned after the gathering information step.
Messages may only be during the Update Status step. If a messages is send is specifies the receiver(s) and the message. Messages are semi-referenced counted, and after sending you should Release the message, the receivers also Release the message when clear the messages.
There two standard messages: