In the TeapotWars, all the actors are created by the BaseGameLogic. The BaseGameLogic has strong pointers to each actor it created. Therefore, to truly destroy an actor, we can't just call actor.Destroy();; we have to remove the strong pointer from the BaseGameLogic.
The TeapotWars provides an event namely EvtData_Request_Destroy_Actor for destroying actors. We can simply create and dispatch this event, then the BaseGameLogic will be triggered by it and will do the clean up.
But what makes me confused is a comment in the Events.h:
//---------------------------------------------------------------------------------------------------------------------
// EvtData_Request_Destroy_Actor - sent by any system requesting that the game logic destroy an actor
// FUTURE WORK - This event shouldn't really exist - subsystems should never ask the game logic to destroy something through an event, should they?
//---------------------------------------------------------------------------------------------------------------------
My questions are:
- Why subsystems should never ask the game logic to destroy something through an event?
- What is the better way to ask the game logic to destroy something?
The TeapotWars provides an event namely EvtData_Request_Destroy_Actor for destroying actors. We can simply create and dispatch this event, then the BaseGameLogic will be triggered by it and will do the clean up.
But what makes me confused is a comment in the Events.h:
//---------------------------------------------------------------------------------------------------------------------
// EvtData_Request_Destroy_Actor - sent by any system requesting that the game logic destroy an actor
// FUTURE WORK - This event shouldn't really exist - subsystems should never ask the game logic to destroy something through an event, should they?
//---------------------------------------------------------------------------------------------------------------------
My questions are:
- Why subsystems should never ask the game logic to destroy something through an event?
- What is the better way to ask the game logic to destroy something?