本文整理汇总了C++中cPlayer::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ cPlayer::Detach方法的具体用法?C++ cPlayer::Detach怎么用?C++ cPlayer::Detach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cPlayer
的用法示例。
在下文中一共展示了cPlayer::Detach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}