本文整理汇总了C++中ActorPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ActorPtr类的具体用法?C++ ActorPtr怎么用?C++ ActorPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActorPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSpell
int CmdCast::execute()
{
int turns = 0;
SpellPtr spell = getSpell();
Engine::instance().render();
Engine::instance().flush();
ActorPtr player = Engine::instance().getPlayer();
if ( spell )
{
TargetSelectorPtr selector( TargetSelector::create( spell->getTargetType() ) );
if ( selector )
{
selector->setRange( spell->getRange() );
selector->setRadius( spell->getRadius() );
MapPtr map = Engine::instance().getWorld().getCurrentMap();
Target target = selector->select([&](ActorPtr a){ return map->isInFov(a->getX(), a->getY()); });
if ( player->performAction( new CastAction(spell, target) ) != ActorActionResult::Ok )
{
gui::msgBox("Failed to cast spell!", gui::MsgType::Warning);
}
}
++turns;
}
return turns;
}
示例2: ASSERT
void ActorSet::load(const PropertyBag &objects, World *_world)
{
ASSERT(_world!=0, "world was null");
world = _world;
for(size_t i=0, n=objects.getNumInstances("object"); i<n; ++i)
{
const tuple<OBJECT_ID, ActorPtr> t = create();
const ActorPtr object = t.get<1>();
const PropertyBag decl = objects.getBag("object", i);
const FileName templateFile = decl.getFileName("template");
const vec3 initialPosition = decl.getVec3("position");
const PropertyBag templateData = PropertyBag::fromFile(templateFile);
const PropertyBag base = templateData.getBag("components");
ComponentDataSet s = ComponentDataSet::load(base, decl);
// get actor name
object->actorName = "(no name)";
templateData.get("name", object->actorName);
object->load(s, initialPosition, vec3(0,0,0), world);
object->setParentBlackBoard(this);
}
}
示例3: ASSERT
void ComponentObjectApproachable::update(float) {
ASSERT(world, "World has not been set yet");
const ActorSet &players = world->players;
for (ActorSet::const_iterator i=players.begin(); i!=players.end(); ++i) {
ActorPtr player = i->second;
if (player->hasComponent("Physics")) {
shared_ptr<Component> component;
shared_ptr<ComponentPhysics> physics;
component = player->getComponent("Physics");
physics = dynamic_pointer_cast<ComponentPhysics>(component);
if (physics) {
const float distance = vec3((physics->getPosition())-lastReportedPosition).getMagnitude();
const ActorID id = player->getUID();
if (distance <= thresholdTrigger) {
playerApproaches(id);
} else if (distance > thresholdRelease) {
playerRecedes(id);
}
}
}
}
}
示例4: stdMesh
//----------------------------------------------------------------------------
void EditMap::CreateSphere (PX2::APoint pos)
{
PX2::Texture2D *tex = DynamicCast<PX2::Texture2D>(
ResourceManager::GetSingleton().BlockLoad("ToolRes/images/default.png"));
if (!tex)
return;
StandardMesh stdMesh(mVertexFormat);
TriMesh *mesh = stdMesh.Sphere(16, 16, 1);
mesh->SetName("NoName");
Texture2DMaterialPtr material = new0 Texture2DMaterial;
mesh->SetMaterialInstance(material->CreateInstance(tex));
ActorPtr actor = new0 Actor();
actor->SetName("NoName");
actor->SetMovable(mesh);
actor->SetPosition(pos);
actor->ComeInToEventWorld();
AddActor(actor);
Event *event = 0;
event = EditorEventSpace::CreateEventX
(EditorEventSpace::AddActor);
event->SetData<Actor*>(actor);
EventWorld::GetSingleton().BroadcastingLocalEvent(event);
ActorAddDeleteCommand *command = new0 ActorAddDeleteCommand(actor);
EditSystem::GetSingleton().GetCM()->PushUnDo(command);
}
示例5: stdMesh
//----------------------------------------------------------------------------
void EditMap::CreateSphere (PX2::APoint pos)
{
PX2::Texture2D *tex = DynamicCast<PX2::Texture2D>(
ResourceManager::GetSingleton().BlockLoad("ToolRes/images/default.png"));
if (!tex)
return;
StandardMesh stdMesh(mVertexFormat);
TriMesh *mesh = stdMesh.Sphere(16, 16, 1);
mesh->SetName("NoName");
//Texture2DMaterialPtr material = new0 Texture2DMaterial;
//mesh->SetMaterialInstance(material->CreateInstance(tex));
StandardESMaterial_DefaultPtr mtl = new0 StandardESMaterial_Default();
mesh->SetMaterialInstance(mtl->CreateInstance(tex, 0 ,0));
ActorPtr actor = new0 Actor();
actor->SetName("NoName");
actor->SetMovable(mesh);
actor->SetPosition(pos);
actor->ComeInToEventWorld();
AddActor(actor);
ActorAddDeleteCommand *command = new0 ActorAddDeleteCommand(actor);
EditSystem::GetSingleton().GetCM()->PushUnDo(command);
}
示例6: SingleNeighbourSelector
void CmdClose::execute()
{
Target target = SingleNeighbourSelector("Select object to close...")
.select();
auto openableIter = std::find_if(target.actors.begin(), target.actors.end(),
[](ActorPtr a)
{ return a->getFeature<Openable>(); });
ActorPtr toClose = openableIter != target.actors.end() ? *openableIter : nullptr;
if ( toClose != nullptr)
{
if ( target.actors.size() == 1 )
{
Actor::Player->performAction( std::make_shared<CloseAction>(toClose) );
}
else
{
gui::msgBox("Cannot close " + tolowers(toClose->getName())+":\n"
"It is blocked!",
gui::MsgType::Warning);
}
}
else
{
gui::msgBox("Nothing to close there.", gui::MsgType::Warning);
}
}
示例7: turns
int CmdUseSkill::execute()
{
int turns(0);
if ( SkillPtr skill = getSkill() )
{
Engine::instance().render();
Engine::instance().flush();
ActorPtr player = Engine::instance().getPlayer();
TargetSelectorPtr selector( TargetSelector::create( skill->getTargetType() ) );
if ( selector )
{
selector->setRadius( skill->getRadius() );
MapPtr map = Engine::instance().getWorld().getCurrentMap();
ActorActionPtr action(
new UseSkillAction(skill, selector->select([&](ActorPtr a){
return map->isInFov(a->getX(), a->getY());
})) );
if ( player->performAction( action ) != ActorActionResult::Ok )
{
gui::msgBox(skill->getName() + " failed!", gui::MsgType::Warning);
}
++turns;
}
}
return turns;
}
示例8: DALI_LOG_TRACE_METHOD
AnimationPtr ModelActorFactory::CreateAnimation(
Actor& rootActor,
const ModelAnimationMap* animationData,
AlphaFunction alpha,
float durationSeconds)
{
DALI_LOG_TRACE_METHOD(Debug::Filter::gModel);
AnimationPtr animation(Animation::New(durationSeconds));
animation->SetDefaultAlphaFunction(alpha);
for(EntityAnimatorMapIter it = animationData->animators.begin(); it != animationData->animators.end(); ++it)
{
const EntityAnimatorMap& entityAnimator(*it);
// find actor for this animator
ActorPtr animatedActor = rootActor.FindChildByName(entityAnimator.GetEntityName());
if (!animatedActor)
{
// If we can't find the actor, it may not have been instantiated, may
// be a sibling or parent of rootActor or may have been removed.
continue;
}
Dali::Actor targetActor(animatedActor.Get());
Dali::KeyFrames posKFHandle = entityAnimator.GetPositionKeyFrames();
if(posKFHandle)
{
const KeyFrames& positionKeyFrames = GetImplementation(posKFHandle);
if(positionKeyFrames.GetKeyFramesBase()->GetNumberOfKeyFrames() > 0)
{
animation->AnimateBetween(Property(targetActor, Dali::Actor::POSITION),
positionKeyFrames, alpha, durationSeconds);
}
}
Dali::KeyFrames scaleKFHandle = entityAnimator.GetScaleKeyFrames();
if(scaleKFHandle)
{
const KeyFrames& scaleKeyFrames = GetImplementation(scaleKFHandle);
if(scaleKeyFrames.GetKeyFramesBase()->GetNumberOfKeyFrames() > 0)
{
animation->AnimateBetween(Property(targetActor, Dali::Actor::SCALE), scaleKeyFrames, alpha, durationSeconds);
}
}
Dali::KeyFrames rotationKFHandle = entityAnimator.GetRotationKeyFrames();
if(rotationKFHandle)
{
const KeyFrames& rotationKeyFrames = GetImplementation(rotationKFHandle);
if(rotationKeyFrames.GetKeyFramesBase()->GetNumberOfKeyFrames() > 0)
{
animation->AnimateBetween(Property(targetActor, Dali::Actor::ROTATION), rotationKeyFrames, alpha, durationSeconds);
}
}
}
return animation;
}
示例9: getOwner
bool Openable::unlock()
{
ActorPtr actor = getOwner().lock();
if ( actor )
{
actor->notify(Event(EventId::Actor_Unlocked));
}
_locked = false;
return !_locked;
}
示例10: RemoveActor
CInstance::ActorPtr CInstance::RemoveActor(uint32 actorId)
{
ActorPtr result;
auto actorIterator = m_actors.find(actorId);
assert(actorIterator != std::end(m_actors));
result = std::move(actorIterator->second);
result->SetInstance(nullptr);
m_actors.erase(actorIterator);
return std::move(result);
}
示例11: getActorFactory
tuple<OBJECT_ID, ActorPtr> ActorSet::create()
{
ActorFactory &factory = getActorFactory();
const tuple<OBJECT_ID, ActorPtr> t = factory.create();
const OBJECT_ID id = t.get<0>();
const ActorPtr actor = t.get<1>();
actors.insert(make_pair(id, actor)); // record it in this actor set
registerSubscriber(actor); // record it in the blackboard
actor->setParentBlackBoard(this);
return t;
}
示例12: TEST_F
TEST_F(MapTest, addActor)
{
MapPtr map = mapGateway.fetch(MapId::GameStart);
ActorPtr actor = Actor::create(ActorType::HealthPotion,1,1);
map->addActor(actor);
auto actors = map->getActors(1,1);
EXPECT_EQ(actors.size(), (size_t)1);
EXPECT_TRUE( actors.front().get() == actor.get() );
}
示例13: create
void ActorSet::_spawn(const SpawnRequest &spawnData)
{
const ComponentDataSet &data = spawnData.get<0>();
const vec3 &position = spawnData.get<1>();
const vec3 &velocity = spawnData.get<2>();
const tuple<OBJECT_ID, ActorPtr> t = create();
const ActorPtr object = t.get<1>();
object->load(data, position, velocity, world);
object->enableDebugRendering(displayDebugRendering);
}
示例14: getOwner
void Character::setHitPoints(int newHp)
{
_hitPoints = newHp;
if ( _hitPoints <= 0 )
{
ActorPtr owner = getOwner().lock();
if ( owner )
{
owner->performAction( std::make_shared<DieAction>() );
}
}
}
示例15: DestroyActor
void ActorManager::DestroyActor(Actor::Id id)
{
if (mActors.count(id))
{
ActorPtr actor = mActors[id];
actor->ClearComponents();
// move to pool
mActors.erase(id);
mPool.AddObject(actor);
}
else
THROW_ERROR("Unknown actor id " + id);
}