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


C++ Entity::GetOrigin方法代码示例

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


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

示例1: Touch

void EntTriggerPush::Touch(Entity &other)
{
//	Player	*player;
	float				height, time, dist;
	std::stringstream	sstr;

	if(!target)
		return;

	Vector3f	v = target->GetOrigin() - other.GetOrigin();

	height = v[1];
	time = (float)sqrt(height / (G_GRAVITY * 0.5));

	v[1] = 0;

	dist = v.length();
	v.normalize();
	v *= dist / time;
	v[1] = time * G_GRAVITY;

	sstr << "push" << " " << v[0] << " " << v[1] << " " << v[2];

	if(other.GetClassName() == "player")
	{
//		logstream() << "TOUCH: " << other.GetOrigin()[0] << " " << other.GetOrigin()[1] << " " << other.GetOrigin()[2] << "\n";
		EE.ThrowEvent_i(&other, sstr.str(), 0);

		//play sound
		EE.C_ExecCommand("s_play basehaste/sound/world/jumppad.wav");
	}
}
开发者ID:pkamenarsky,项目名称:hastegame,代码行数:32,代码来源:ent_trigger_push.cpp

示例2: OnCollision

void LaserBeam::OnCollision(ICollidable *other)
{
    Entity *entity = (Entity*)other;

    Damage_t damage;
    damage.damage = entity->GetHealth();

    if (entity->IsPlayer())
    {
        damage.damage = 1;
    }

    damage.direction = Vector2D(-1, 0);
    damage.inflictor = GetOwner();

    if (GetOwner() != nullptr)
    {
        damage.statsInflictorName = GetOwner()->GetEntityClassName();
        damage.statsInflictorClass = GetOwner()->GetEntityResourceClass();
    }

    damage.statsWeaponName = GetEntityClassName();
    damage.statsWeaponClass = GetEntityResourceClass();

    entity->TakeDamage(damage);

    Vector2D laserCenter = GetOrigin();
    laserCenter.x = entity->GetOrigin().x;

    GetGameContext()->GetParticleRoot()->CreateParticles("laser_cannon_hit", laserCenter, Vector2D(-1, 0));
}
开发者ID:Biohazard90,项目名称:Project-Neo-Gemini,代码行数:31,代码来源:laserbeam.cpp

示例3: Maintain

void Client::Maintain (const Entity &ent)
{
   if (ent.IsPlayer ())
   {
      m_ent = ent;

      m_safeOrigin = ent.GetOrigin ();
      m_flags |= ent.IsAlive () ? CLIENT_VALID | CLIENT_ALIVE : CLIENT_VALID;
   }
   else
   {
      m_safeOrigin = nullvec;
      m_flags = ~(CLIENT_VALID | CLIENT_ALIVE);
   }
}
开发者ID:xurubin,项目名称:yapb,代码行数:15,代码来源:engine.cpp

示例4: OnSimulate

void LaserBeam::OnSimulate(float frametime)
{
    BaseClass::OnSimulate(frametime);

    float laserLength = Camera::GetInstance()->GetWorldMaxs().x - Camera::GetInstance()->GetWorldMins().x;
    float gameTime = GetGameContext()->GetGameTime();

    SetSize(Vector2D(laserLength, LASER_MAX_SIZE_Y));

    Entity *owner = GetOwner();

    if (owner == nullptr
            || timer < gameTime)
    {
        Remove();
    }
    else
    {
        Vector2D center = owner->GetOrigin();
        center.x -= laserLength * 0.5f;
        center += offset;

        if (!spawned)
        {
            Teleport(center);
            spawned = true;
        }
        else
        {
            SetOrigin(center);
        }
    }

    if (flashTimer < gameTime)
    {
        flashSize = fixedSize;
        fixedSize = qlerp(qfrand(), LASER_MIN_SIZE_Y, LASER_MAX_SIZE_Y);
        flashTimer = gameTime + LASER_FLASH_DURATION;
    }
}
开发者ID:Biohazard90,项目名称:Project-Neo-Gemini,代码行数:40,代码来源:laserbeam.cpp


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