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


C++ cPlayer::GetUniqueID方法代码示例

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


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

示例1: OnRightClicked

void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
{
	super::OnRightClicked(a_Player);

	if (m_Attachee != NULL)
	{
		if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
		{
			// This player is already sitting in, they want out.
			a_Player.Detach();
			return;
		}
		
		if (m_Attachee->IsPlayer())
		{
			// Another player is already sitting in here, cannot attach
			return;
		}
		
		// Detach whatever is sitting in this minecart now:
		m_Attachee->Detach();
	}
	
	// Attach the player to this minecart
	a_Player.AttachTo(this);
}
开发者ID:w00tc0d3,项目名称:MCServer,代码行数:26,代码来源:Minecart.cpp

示例2: TossItems

void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End)
{
	cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
	if (itr == m_Items.end())
	{
		LOGWARNING("Player tossing items (%s) not found in the item map", a_Player.GetName().c_str());
		return;
	}
	
	cItems Drops;
	for (int i = a_Begin; i < a_End; i++)
	{
		cItem & Item = itr->second[i];
		if (!Item.IsEmpty())
		{
			Drops.push_back(Item);
		}
		Item.Empty();
	}  // for i - itr->second[]
	
	double vX = 0, vY = 0, vZ = 0;
	EulerToVector(-a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY);
	vY = -vY * 2 + 1.f;
	a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 2, vY * 2, vZ * 2);
}
开发者ID:l0ud,项目名称:MCServer,代码行数:25,代码来源:SlotArea.cpp

示例3: Lock

void cProtocol125::SendPlayerAnimation(const cPlayer & a_Player, char a_Animation)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ANIMATION);
	WriteInt (a_Player.GetUniqueID());
	WriteByte(a_Animation);
	Flush();
}
开发者ID:Xury,项目名称:MCServer,代码行数:8,代码来源:Protocol125.cpp

示例4: Lock

void cProtocol132::SendCollectEntity(const cEntity & a_Entity, const cPlayer & a_Player)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_COLLECT_PICKUP);
	WriteInt (a_Entity.GetUniqueID());
	WriteInt (a_Player.GetUniqueID());
	Flush();
}
开发者ID:wang108,项目名称:MCServer,代码行数:8,代码来源:Protocol132.cpp

示例5: Lock

void cProtocol125::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_COLLECT_PICKUP);
	WriteInt (a_Pickup.GetUniqueID());
	WriteInt (a_Player.GetUniqueID());
	Flush();
}
开发者ID:FX-Master,项目名称:MCServer,代码行数:8,代码来源:Protocol125.cpp

示例6: 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

示例7: Lock

void cProtocol132::SendCollectPickup(const cPickup & a_Pickup, const cPlayer & a_Player)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_COLLECT_PICKUP);
	WriteInt (a_Pickup.GetUniqueID());
	WriteInt (a_Player.GetUniqueID());
	Flush();
	
	// Also send the "pop" sound effect with a somewhat random pitch (fast-random using EntityID ;)
	SendSoundEffect(
		"random.pop",
		(int)(a_Pickup.GetPosX() * 8), (int)(a_Pickup.GetPosY() * 8), (int)(a_Pickup.GetPosZ() * 8),
		0.5, (float)(0.75 + ((float)((a_Pickup.GetUniqueID() * 23) % 32)) / 64)
	);
}
开发者ID:l0ud,项目名称:MCServer,代码行数:15,代码来源:Protocol132.cpp

示例8: OnPlayerRemoved

void cSlotAreaCrafting::OnPlayerRemoved(cPlayer & a_Player)
{
	// Toss all items on the crafting grid:
	TossItems(a_Player, 1, m_NumSlots);
	
	// Remove the current recipe from the player -> recipe map:
	for (cRecipeMap::iterator itr = m_Recipes.begin(), end = m_Recipes.end(); itr != end; ++itr)
	{
		if (itr->first == a_Player.GetUniqueID())
		{
			// Remove the player from the recipe map:
			m_Recipes.erase(itr);
			return;
		}
	}  // for itr - m_Recipes[]
	// Player not found - that is acceptable
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:17,代码来源:SlotArea.cpp

示例9: OnRightClicked

void cHorse::OnRightClicked(cPlayer & a_Player)
{
	super::OnRightClicked(a_Player);

	if (!m_bIsSaddled && m_bIsTame)
	{
		if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE)
		{
			// Saddle the horse:
			if (!a_Player.IsGameModeCreative())
			{
				a_Player.GetInventory().RemoveOneEquippedItem();
			}
			m_bIsSaddled = true;
			m_World->BroadcastEntityMetadata(*this);
		}
		else if (!a_Player.GetEquippedItem().IsEmpty())
		{
			// The horse doesn't like being hit, make it rear:
			m_bIsRearing = true;
			m_RearTickCount = 0;
		}
	}
	else
	{
		if (m_Attachee != nullptr)
		{
			if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
			{
				a_Player.Detach();
				return;
			}

			if (m_Attachee->IsPlayer())
			{
				return;
			}

			m_Attachee->Detach();
		}

		m_TameAttemptTimes++;
		a_Player.AttachTo(this);
	}
}
开发者ID:gjzskyland,项目名称:cuberite,代码行数:45,代码来源:Horse.cpp

示例10: SetSlot

void cSlotAreaTemporary::SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item)
{
	cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
	if (itr == m_Items.end())
	{
		// Player not found
		LOGWARNING("cSlotAreaTemporary: player not found!");
		return;
	}
	
	if (a_SlotNum >= (int)(itr->second.size()))
	{
		LOGERROR("cSlotAreaTemporary: asking for more slots than actually stored!");
		return;
	}
	
	itr->second[a_SlotNum] = a_Item;
}
开发者ID:l0ud,项目名称:MCServer,代码行数:18,代码来源:SlotArea.cpp

示例11: OnRightClicked

void cPig::OnRightClicked(cPlayer & a_Player)
{
	super::OnRightClicked(a_Player);

	if (m_bIsSaddled)
	{
		if (m_Attachee != nullptr)
		{
			if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
			{
				// This player is already sitting in, they want out.
				a_Player.Detach();
				return;
			}

			if (m_Attachee->IsPlayer())
			{
				// Another player is already sitting in here, cannot attach
				return;
			}

			// Detach whatever is sitting in this pig now:
			m_Attachee->Detach();
		}

		// Attach the player to this pig
		a_Player.AttachTo(this);
	}
	else if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_SADDLE)
	{
		if (!a_Player.IsGameModeCreative())
		{
			a_Player.GetInventory().RemoveOneEquippedItem();
		}

		// Set saddle state & broadcast metadata
		m_bIsSaddled = true;
		m_World->BroadcastEntityMetadata(*this);
	}
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:40,代码来源:Pig.cpp

示例12: OnRightClicked

void cHorse::OnRightClicked(cPlayer & a_Player)
{
	super::OnRightClicked(a_Player);

	if (m_bIsTame)
	{
		if (a_Player.IsCrouched())
		{
			PlayerOpenWindow(a_Player);
			return;
		}

		auto EquipedItemType = a_Player.GetEquippedItem().m_ItemType;

		if (
			!IsSaddled() &&
			(
				(EquipedItemType == E_ITEM_SADDLE) ||
				ItemCategory::IsHorseArmor(EquipedItemType)
			)
		)
		{
			// Player is holding a horse inventory item, open the window:
			PlayerOpenWindow(a_Player);
		}
		else
		{
			a_Player.AttachTo(this);
		}
	}
	else if (a_Player.GetEquippedItem().IsEmpty())
	{
		// Check if leashed / unleashed to player before try to ride
		if (!m_IsLeashActionJustDone)
		{
			if (m_Attachee != nullptr)
			{
				if (m_Attachee->GetUniqueID() == a_Player.GetUniqueID())
				{
					a_Player.Detach();
					return;
				}

				if (m_Attachee->IsPlayer())
				{
					return;
				}

				m_Attachee->Detach();
			}

			m_TameAttemptTimes++;
			a_Player.AttachTo(this);
		}
	}
	else
	{
		m_bIsRearing = true;
		m_RearTickCount = 0;
		m_World->BroadcastSoundEffect("entity.horse.angry", GetPosition(), 1.0f, 0.8f);
	}
}
开发者ID:changyongGuo,项目名称:cuberite,代码行数:62,代码来源:Horse.cpp

示例13: OnPlayerAdded

void cSlotAreaTemporary::OnPlayerAdded(cPlayer & a_Player)
{
	ASSERT(m_Items.find(a_Player.GetUniqueID()) == m_Items.end());  // The player shouldn't be in the itemmap, otherwise we probably have a leak
	m_Items[a_Player.GetUniqueID()].resize(m_NumSlots);  // Make the vector the specified size of empty items
}
开发者ID:l0ud,项目名称:MCServer,代码行数:5,代码来源:SlotArea.cpp

示例14: OnPlayerRemoved

void cSlotAreaTemporary::OnPlayerRemoved(cPlayer & a_Player)
{
	cItemMap::iterator itr = m_Items.find(a_Player.GetUniqueID());
	ASSERT(itr != m_Items.end());  // The player should be in the list, otherwise a call to OnPlayerAdded() was mismatched
	m_Items.erase(itr);
}
开发者ID:l0ud,项目名称:MCServer,代码行数:6,代码来源:SlotArea.cpp


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