• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cEntity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cEntity的典型用法代码示例。如果您正苦于以下问题:C++ cEntity类的具体用法?C++ cEntity怎么用?C++ cEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: OnHitEntity

void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat())
	{
		// Not an entity that interacts with an arrow
		return;
	}
	
	int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
	
	// Broadcast successful hit sound
	m_World->BroadcastSoundEffect(
		"random.successful_hit",
		(int)std::floor(GetPosX() * 8.0),
		(int)std::floor(GetPosY() * 8.0),
		(int)std::floor(GetPosZ() * 8.0),
		0.5f,
		0.75f + ((float)((GetUniqueID() * 23) % 32)) / 64.0f
	);
	
	Destroy();
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:27,代码来源:ArrowEntity.cpp


示例2: Item

		virtual bool Item(cEntity * a_Entity) override
		{
			if (a_Entity->GetUniqueID() == m_Pusher->GetUniqueID())
			{
				return false;
			}

			// we only push other mobs, boats and minecarts
			if ((a_Entity->GetEntityType() != etMonster) && (a_Entity->GetEntityType() != etMinecart) && (a_Entity->GetEntityType() != etBoat))
			{
				return false;
			}

			// do not push a boat / minecart you're sitting in
			if (m_Pusher->IsAttachedTo(a_Entity))
			{
				return false;
			}

			Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition();
			v3Delta.y = 0.0;  // we only push sideways
			v3Delta *= 1.0 / (v3Delta.Length() + 0.01);  // we push harder if we're close
			// QUESTION: is there an additional multiplier for this? current shoving seems a bit weak

			a_Entity->AddSpeed(v3Delta);
			return false;
		}
开发者ID:Lokislove,项目名称:cuberite,代码行数:27,代码来源:Pawn.cpp


示例3: LoadEntityBaseFromNBT

bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
{
    double Pos[3];
    if (!LoadDoublesListFromNBT(Pos, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Pos")))
    {
        return false;
    }
    a_Entity.SetPosition(Pos[0], Pos[1], Pos[2]);

    double Speed[3];
    if (!LoadDoublesListFromNBT(Speed, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Motion")))
    {
        return false;
    }
    a_Entity.SetSpeed(Speed[0], Speed[1], Speed[2]);

    double Rotation[3];
    if (!LoadDoublesListFromNBT(Rotation, 2, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Rotation")))
    {
        return false;
    }
    a_Entity.SetRotation(Rotation[0]);
    a_Entity.SetRoll    (Rotation[1]);

    return true;
}
开发者ID:stpinker,项目名称:MCServer,代码行数:26,代码来源:WSSAnvil.cpp


示例4:

char cProtocol125::GetEntityMetadataFlags(const cEntity & a_Entity)
{
	char Flags = 0;
	if (a_Entity.IsOnFire())
	{
		Flags |= 1;
	}
	if (a_Entity.IsCrouched())
	{
		Flags |= 2;
	}
	if (a_Entity.IsRiding())
	{
		Flags |= 4;
	}
	if (a_Entity.IsSprinting())
	{
		Flags |= 8;
	}
	if (a_Entity.IsRclking())
	{
		Flags |= 16;
	}
	return Flags;
}
开发者ID:Xury,项目名称:MCServer,代码行数:25,代码来源:Protocol125.cpp


示例5: Lock

void cProtocol125::SendEntityHeadLook(const cEntity & a_Entity)
{
	ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID());  // Must not send for self
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ENT_HEAD_LOOK);
	WriteInt (a_Entity.GetUniqueID());
	WriteChar((char)((a_Entity.GetHeadYaw() / 360.f) * 256));
	Flush();
}
开发者ID:FX-Master,项目名称:MCServer,代码行数:10,代码来源:Protocol125.cpp


示例6: Lock

void cProtocol125::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
	ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID());  // Must not send for self
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ENT_REL_MOVE_LOOK);
	WriteInt (a_Entity.GetUniqueID());
	WriteByte(a_RelX);
	WriteByte(a_RelY);
	WriteByte(a_RelZ);
	WriteByte((char)((a_Entity.GetRotation() / 360.f) * 256));
	WriteByte((char)((a_Entity.GetPitch()    / 360.f) * 256));
	Flush();
}
开发者ID:Xury,项目名称:MCServer,代码行数:14,代码来源:Protocol125.cpp


示例7: Lock

void cProtocol132::SendDestroyEntity(const cEntity & a_Entity)
{
	if (a_Entity.GetUniqueID() == m_Client->GetPlayer()->GetUniqueID())
	{
		// Do not send "destroy self" to the client, the client would crash (FS #254)
		return;
	}
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_DESTROY_ENTITIES);
	WriteByte(1);  // entity count
	WriteInt (a_Entity.GetUniqueID());
	Flush();
}
开发者ID:wang108,项目名称:MCServer,代码行数:14,代码来源:Protocol132.cpp


示例8: cNotifyWolves

void cProjectileEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	if (a_EntityHit.IsPawn() && (GetCreatorName() != ""))  // If we're hitting a mob or a player and we were created by a player
	{

		class cNotifyWolves : public cEntityCallback
		{
		public:
			cPawn * m_EntityHit;

			cNotifyWolves(cPawn * a_Entity) :
				m_EntityHit(a_Entity)
			{
			}

			virtual bool Item(cEntity * a_Player) override
			{
				static_cast<cPlayer*>(a_Player)->NotifyFriendlyWolves(m_EntityHit);
				return true;
			}
		} Callback(static_cast<cPawn*>(&a_EntityHit));

		m_World->DoWithEntityByID(GetCreatorUniqueID(), Callback);
	}
}
开发者ID:SteveWinfield,项目名称:cuberite,代码行数:25,代码来源:ProjectileEntity.cpp


示例9: OnHitEntity

void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	int TotalDamage = 0;
	if (a_EntityHit.IsMob())
	{
		eMonsterType MobType = static_cast<cMonster &>(a_EntityHit).GetMobType();
		if (MobType == mtBlaze)
		{
			TotalDamage = 3;
		}
	}
	// TODO: If entity is Ender Crystal, destroy it
	a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
	
	m_DestroyTimer = 5;
}
开发者ID:36451,项目名称:MCServer,代码行数:16,代码来源:ThrownSnowballEntity.cpp


示例10: OnHitEntity

void cFireChargeEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	Destroy();
	Explode((int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z));
	
	// TODO: Some entities are immune to hits
	a_EntityHit.StartBurning(5 * 20);  // 5 seconds of burning
}
开发者ID:DjKiDD,项目名称:MCServer,代码行数:8,代码来源:FireChargeEntity.cpp


示例11: OnHitEntity

void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	int TotalDamage = 0;
	// If entity is an Ender Dragon or Ender Crystal, it is damaged.
	if (
		(a_EntityHit.IsMob() && (static_cast<cMonster &>(a_EntityHit).GetMobType() == mtEnderDragon)) ||
		a_EntityHit.IsEnderCrystal()
	)
	{
		TotalDamage = 1;
	}

	TrySpawnChicken(a_HitPos);
	a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);

	m_DestroyTimer = 5;
}
开发者ID:SamJBarney,项目名称:cuberite,代码行数:17,代码来源:ThrownEggEntity.cpp


示例12: OnHitEntity

void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer())
	{
		// Not an entity that interacts with an arrow
		return;
	}
	
	int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 1);
	
	Destroy();
}
开发者ID:jimfinnis,项目名称:MCServer,代码行数:17,代码来源:ProjectileEntity.cpp


示例13: OnHitEntity

void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	super::OnHitEntity(a_EntityHit, a_HitPos);

	int Damage = static_cast<int>(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
	if (m_IsCritical)
	{
		Damage += m_World->GetTickRandomNumber(Damage / 2 + 2);
	}

	unsigned int PowerLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPower);
	if (PowerLevel > 0)
	{
		int ExtraDamage = static_cast<int>(ceil(0.25 * (PowerLevel + 1)));
		Damage += ExtraDamage;
	}

	// int KnockbackAmount = 1;
	unsigned int PunchLevel = m_CreatorData.m_Enchantments.GetLevel(cEnchantments::enchPunch);
	if (PunchLevel > 0)
	{
		Vector3d LookVector = GetLookVector();
		Vector3f FinalSpeed = Vector3f(0, 0, 0);
		switch (PunchLevel)
		{
			case 1: FinalSpeed = LookVector * Vector3d(5, 0.3, 5); break;
			case 2: FinalSpeed = LookVector * Vector3d(8, 0.3, 8); break;
			default: break;
		}
		a_EntityHit.SetSpeed(FinalSpeed);
	}

	// a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, KnockbackAmount);  // TODO fix knockback.
	a_EntityHit.TakeDamage(dtRangedAttack, this, Damage, 0);  // Until knockback is fixed.

	if (IsOnFire() && !a_EntityHit.IsSubmerged() && !a_EntityHit.IsSwimming())
	{
		a_EntityHit.StartBurning(100);
	}

	// Broadcast successful hit sound
	GetWorld()->BroadcastSoundEffect("random.successful_hit", GetPosX(), GetPosY(), GetPosZ(), 0.5, static_cast<float>(0.75 + (static_cast<float>((GetUniqueID() * 23) % 32)) / 64));

	Destroy();
}
开发者ID:Haxi52,项目名称:cuberite,代码行数:45,代码来源:ArrowEntity.cpp


示例14: Pkt

void cProtocol_1_11_0::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player, int a_Count)
{
	ASSERT(m_State == 3);  // In game mode?

	cPacketizer Pkt(*this, GetPacketId(sendCollectEntity));  // Collect Item packet
	Pkt.WriteVarInt32(a_Entity.GetUniqueID());
	Pkt.WriteVarInt32(a_Player.GetUniqueID());
	Pkt.WriteVarInt32(static_cast<UInt32>(a_Count));
}
开发者ID:lkolbly,项目名称:MCServer,代码行数:9,代码来源:Protocol_1_11.cpp


示例15: Lock

void cProtocol161::SendAttachEntity(const cEntity & a_Entity, const cEntity * a_Vehicle)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ATTACH_ENTITY);
	WriteInt(a_Entity.GetUniqueID());
	WriteInt((a_Vehicle == NULL) ? -1 : a_Vehicle->GetUniqueID());
	WriteBool(false);  // TODO: "Should use leash?" -> no
	Flush();
}
开发者ID:Xury,项目名称:MCServer,代码行数:9,代码来源:Protocol16x.cpp


示例16: OnHitEntity

void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	int TotalDamage = 0;
	// TODO: If entity is Ender Crystal, destroy it
	
	TrySpawnChicken(a_HitPos);
	a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);
	
	m_DestroyTimer = 5;
}
开发者ID:hallucino,项目名称:cuberite,代码行数:10,代码来源:ThrownEggEntity.cpp


示例17: OnHitEntity

void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	// TODO: If entity is Ender Crystal, destroy it
	a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);

	// TODO: Explode
	// TODO: Apply wither effect to entity and others nearby

	Destroy(true);
}
开发者ID:1285done,项目名称:cuberite,代码行数:10,代码来源:WitherSkullEntity.cpp


示例18: OnHitEntity

void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
	int TotalDamage = 0;
	// TODO: If entity is Ender Crystal, destroy it

	TeleportCreator(a_HitPos);
	a_EntityHit.TakeDamage(dtRangedAttack, this, TotalDamage, 1);

	m_DestroyTimer = 5;
}
开发者ID:1285done,项目名称:cuberite,代码行数:10,代码来源:ThrownEnderPearlEntity.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cFrequencyCounter类代码示例发布时间:2022-05-31
下一篇:
C++ cDVector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap