BGE: bookmark option on controller to make them run before all other controllers.
A new bookmark button is available on the controller UI. When set, the controller is guaranteed to execute before all other non-bookmarked controllers, provided it is scheduled for execution. This is useful for initialization scripts that run once at startup or scripts that must set some prerequisite for the other controllers at the start of each logic frame. This feature is also available at python level with the "bookmark" attribute. It can be changed during the game. Note that if several script are bookmarked, their relative order of execution is not guaranteed. Make sure they don't depend on each other.
This commit is contained in:
@@ -45,6 +45,7 @@ protected:
|
||||
std::vector<class SCA_IActuator*> m_linkedactuators;
|
||||
unsigned int m_statemask;
|
||||
bool m_justActivated;
|
||||
bool m_bookmark;
|
||||
public:
|
||||
SCA_IController(SCA_IObject* gameobj,PyTypeObject* T);
|
||||
virtual ~SCA_IController();
|
||||
@@ -76,13 +77,24 @@ public:
|
||||
{
|
||||
m_justActivated = false;
|
||||
}
|
||||
|
||||
void SetBookmark(bool bookmark)
|
||||
{
|
||||
m_bookmark = bookmark;
|
||||
}
|
||||
void Activate(SG_DList& head)
|
||||
{
|
||||
if (QEmpty())
|
||||
{
|
||||
InsertActiveQList(m_gameobj->m_activeControllers);
|
||||
head.AddBack(&m_gameobj->m_activeControllers);
|
||||
if (m_bookmark)
|
||||
{
|
||||
m_gameobj->m_activeBookmarkedControllers.QAddBack(this);
|
||||
head.AddFront(&m_gameobj->m_activeBookmarkedControllers);
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertActiveQList(m_gameobj->m_activeControllers);
|
||||
head.AddBack(&m_gameobj->m_activeControllers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user