信息化网站建设有什么用,官网优化哪家专业,团队网站怎么做,wordpress 锚点定位dtGame::GMComponent主要用于处理系统中的消息#xff0c;给系统动态的添加功能#xff0c;增加系统的可维护性#xff0c;
简单来说#xff0c;一个游戏管理器组件就是一个由游戏管理器管理的可以处理和发送消息的对象。它不像游戏角色#xff0c;游戏管理器组件接受系统…dtGame::GMComponent主要用于处理系统中的消息给系统动态的添加功能增加系统的可维护性
简单来说一个游戏管理器组件就是一个由游戏管理器管理的可以处理和发送消息的对象。它不像游戏角色游戏管理器组件接受系统中所有的消息。通常情况下组件提供高层的系统行为但它们可以处理你想要的任何事情。游戏管理器组件 是我们向游戏管理器添加自定义行为的最主要的方式。 由于组件接受系统中所有的消息它就有机会知道所有的角色以及系统中发生的任何事情。我们可以创建简单的组件来等待或监听鼠标键盘的特定消息。我们也可以创建复杂的组件通过辅助对象来维护我们的所有角色。组件这种可扩展的结构可以大大方便我们向游戏中添加任何重要的行为。
关于组件的优先级在游戏管理器GameManager中,会根据组件的优先级对其中保存的组件进行排序 void GameManager::AddComponent(GMComponent component, const GameManager::ComponentPriority priority){if (GetComponentByName(component.GetName()) ! NULL){std::string errorText A component was already registered with the Game Manager with the name: component.GetName();LOG_ERROR(errorText);throw dtGame::InvalidParameterException(errorText, __FILE__, __LINE__);}component.SetGameManager(this);component.SetComponentPriority(priority);mGMImpl-mComponentList.push_back(dtCore::RefPtrGMComponent(component)); //vector, list// we sort the items by priority so that components of higher priority get messages first.mGMImpl-mComponentList.sort(CompareComponentPriority);// notify the component that it was added to the GMcomponent.OnAddedToGM();}