当前位置: 首页>>代码示例>>C++>>正文


C++ ActorPtr::notify方法代码示例

本文整理汇总了C++中ActorPtr::notify方法的典型用法代码示例。如果您正苦于以下问题:C++ ActorPtr::notify方法的具体用法?C++ ActorPtr::notify怎么用?C++ ActorPtr::notify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActorPtr的用法示例。


在下文中一共展示了ActorPtr::notify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unlock

bool Openable::unlock()
{
  ActorPtr actor = getOwner().lock();
  if ( actor )
  {
    actor->notify(Event(EventId::Actor_Unlocked));
  }
  _locked = false;
  return !_locked;
}
开发者ID:lonski,项目名称:amarlon,代码行数:10,代码来源:openable.cpp

示例2: lock

bool Openable::lock()
{
  ActorPtr actor = getOwner().lock();
  if ( actor )
  {
    actor->notify(Event(EventId::Actor_Locked));
  }
  _locked = true;
  return _locked;
}
开发者ID:lonski,项目名称:amarlon,代码行数:10,代码来源:openable.cpp

示例3: execute

int CmdPutInto::execute()
{
  int turns = 0;
  ActorPtr target = SingleNeighbourSelector("Select a container to put into...")
                    .select()
                    .firstActor();

  if ( target != nullptr && target->hasFeature<Inventory>())
  {
    OpenablePtr openable = target->getFeature<Openable>();
    if ( openable && openable->isClosed() )
    {
      gui::msgBox("Cannot put into " + target->getName() + " - it is closed.", gui::MsgType::Warning);
    }
    else
    {
      auto afterPutIntoAction =
      [&](const std::string& item, int amount)
      {
        target->notify(Event(EventId::Actor_Put,{{"putter","Player"},
                                                 {"container",target->getName()},
                                                 {"count", std::to_string(amount)},
                                                 {"item", tolowers(item)}}));
      };

      auto containerFullAction =
      [&target](const std::string& item)
      {
        gui::msgBox("Cannot put "+item+" into "+tolowers(target->getName())+":#Not enough space!",
                    gui::MsgType::Error);
      };

      Engine::instance().getWindowManager()
                        .getWindow<gui::PickUpWindow>()
                        .setPicker(target)
                        .setSource( [](){ return Engine::instance().getPlayer()->getFeature<Inventory>()->items(); })
                        .setRemoveAction([&](ActorPtr a){Engine::instance().getPlayer()->getFeature<Inventory>()->remove(a);})
                        .setAfterPickupAction( afterPutIntoAction )
                        .setInventoryFullAction( containerFullAction )
                        .setWindowTitle("Select item to put")
                        .show();
    }
    ++turns;
  }
  else if ( target )
  {
    gui::msgBox("You cannot put anything into "+tolowers(target->getName())+".",
                gui::MsgType::Error);
  }
  return turns;
}
开发者ID:lonski,项目名称:amarlon,代码行数:51,代码来源:cmd_put_into.cpp


注:本文中的ActorPtr::notify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。