本文整理汇总了C++中cItem函数的典型用法代码示例。如果您正苦于以下问题:C++ cItem函数的具体用法?C++ cItem怎么用?C++ cItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cItem函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LOGWARNING
cItem cItemGrid::RemoveOneItem(int a_SlotNum)
{
if ((a_SlotNum < 0) || (a_SlotNum >= m_NumSlots))
{
LOGWARNING("%s: Invalid slot number %d out of %d slots, ignoring the call, returning empty item",
__FUNCTION__, a_SlotNum, m_NumSlots
);
return cItem();
}
// If the slot is empty, return an empty item
if (m_Slots[a_SlotNum].IsEmpty())
{
return cItem();
}
// Make a copy of the item in slot, set count to 1 and remove one from the slot
cItem res = m_Slots[a_SlotNum];
res.m_ItemCount = 1;
m_Slots[a_SlotNum].m_ItemCount -= 1;
// Emptying the slot correctly if appropriate
if (m_Slots[a_SlotNum].m_ItemCount == 0)
{
m_Slots[a_SlotNum].Empty();
}
// Notify everyone of the change
TriggerListeners(a_SlotNum);
// Return the stored one item
return res;
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:33,代码来源:ItemGrid.cpp
示例2: SetSlot
void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
{
if (!a_Player.IsGameModeCreative())
{
a_Player.DeltaExperience(-cPlayer::XpForLevel(m_MaximumCost));
}
SetSlot(0, a_Player, cItem());
if (m_StackSizeToBeUsedInRepair > 0)
{
const cItem * Item = GetSlot(1, a_Player);
if (!Item->IsEmpty() && (Item->m_ItemCount > m_StackSizeToBeUsedInRepair))
{
cItem NewSecondItem(*Item);
NewSecondItem.m_ItemCount -= m_StackSizeToBeUsedInRepair;
m_StackSizeToBeUsedInRepair = 0;
SetSlot(1, a_Player, NewSecondItem);
}
else
{
SetSlot(1, a_Player, cItem());
}
}
else
{
SetSlot(1, a_Player, cItem());
}
m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
m_MaximumCost = 0;
((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL);
int PosX, PosY, PosZ;
((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ);
BLOCKTYPE Block;
NIBBLETYPE BlockMeta;
a_Player.GetWorld()->GetBlockTypeMeta(PosX, PosY, PosZ, Block, BlockMeta);
cFastRandom Random;
if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
{
NIBBLETYPE Orientation = BlockMeta & 0x3;
NIBBLETYPE AnvilDamage = BlockMeta >> 2;
++AnvilDamage;
if (AnvilDamage > 2)
{
// Anvil will break
a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, (NIBBLETYPE)0);
a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0);
a_Player.CloseWindow(false);
}
else
{
a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
}
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:59,代码来源:SlotArea.cpp
示例3: Destroy
bool cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{
if ((TDI.Attacker != nullptr) && TDI.Attacker->IsPlayer() && static_cast<cPlayer *>(TDI.Attacker)->IsGameModeCreative())
{
Destroy();
TDI.FinalDamage = GetMaxHealth(); // Instant hit for creative
SetInvulnerableTicks(0);
return super::DoTakeDamage(TDI); // No drops for creative
}
m_LastDamage = TDI.FinalDamage;
if (!super::DoTakeDamage(TDI))
{
return false;
}
m_World->BroadcastEntityMetadata(*this);
if (GetHealth() <= 0)
{
Destroy();
cItems Drops;
switch (m_Payload)
{
case mpNone:
{
Drops.push_back(cItem(E_ITEM_MINECART, 1, 0));
break;
}
case mpChest:
{
Drops.push_back(cItem(E_ITEM_CHEST_MINECART, 1, 0));
break;
}
case mpFurnace:
{
Drops.push_back(cItem(E_ITEM_FURNACE_MINECART, 1, 0));
break;
}
case mpTNT:
{
Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0));
break;
}
case mpHopper:
{
Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0));
break;
}
}
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
}
return true;
}
开发者ID:gjzskyland,项目名称:cuberite,代码行数:56,代码来源:Minecart.cpp
示例4: Destroy
void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
{
m_LastDamage = TDI.FinalDamage;
super::DoTakeDamage(TDI);
m_World->BroadcastEntityMetadata(*this);
if (GetHealth() <= 0)
{
Destroy(true);
cItems Drops;
switch (m_Payload)
{
case mpNone:
{
Drops.push_back(cItem(E_ITEM_MINECART, 1, 0));
break;
}
case mpChest:
{
Drops.push_back(cItem(E_ITEM_CHEST_MINECART, 1, 0));
break;
}
case mpFurnace:
{
Drops.push_back(cItem(E_ITEM_FURNACE_MINECART, 1, 0));
break;
}
case mpTNT:
{
Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0));
break;
}
case mpHopper:
{
Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0));
break;
}
default:
{
ASSERT(!"Unhandled minecart type when spawning pickup!");
return;
}
}
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ());
}
}
开发者ID:Hillvith,项目名称:MCServer,代码行数:49,代码来源:Minecart.cpp
示例5: GetRandomProvider
void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (!IsTicking())
{
// The base class tick destroyed us
return;
}
if (IsBaby())
{
return; // Babies don't lay eggs
}
if (
((m_EggDropTimer == 6000) && GetRandomProvider().RandBool()) ||
m_EggDropTimer == 12000
)
{
cItems Drops;
m_EggDropTimer = 0;
Drops.push_back(cItem(E_ITEM_EGG, 1));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
}
else
{
m_EggDropTimer++;
}
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:29,代码来源:Chicken.cpp
示例6: doNpcFill
void cGameServer::doNpcFill(int id)
{
if(player[id].type!=NPC)
return;
cItem item;
int slot=0;
//clear any items already in inventory
for(int i=0; i<MAX_INV; i++)
if(player[id].inventory[i]>-1)
{
ml_items.item[player[id].inventory[i]]=cItem();
player[id].inventory[i]=-1;
}
for(int i=0; i<MAX_INV; i++)
{
if( ml_loot.loot[player[id].player_template].loot[i].qty!=0 &&
((rand()%1000)+1)<=ml_loot.loot[player[id].player_template].loot[i].chance)
{
item = mil[ml_loot.loot[player[id].player_template].loot[i].index];
item.qty=ml_loot.loot[player[id].player_template].loot[i].qty;
player[id].inventory[slot]=ml_items.addInventoryItem(id,slot,item);
slot++;
}
}
}
开发者ID:Sonicadvance1,项目名称:OpenMystera,代码行数:28,代码来源:gs_players.cpp
示例7: SetIsCooking
void cFurnaceEntity::BurnNewFuel(void)
{
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel));
if (NewTime == 0)
{
// The item in the fuel slot is not suitable
m_FuelBurnTime = 0;
m_TimeBurned = 0;
SetIsCooking(false);
return;
}
// Is the input and output ready for cooking?
if (!CanCookInputToOutput())
{
return;
}
// Burn one new fuel:
m_FuelBurnTime = NewTime;
m_TimeBurned = 0;
SetIsCooking(true);
if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET)
{
m_Contents.SetSlot(fsFuel, cItem(E_ITEM_BUCKET));
}
else
{
m_Contents.ChangeSlotCount(fsFuel, -1);
}
}
开发者ID:Jothle12,项目名称:MCServer,代码行数:32,代码来源:FurnaceEntity.cpp
示例8: OnRightClicked
void cSheep::OnRightClicked(cPlayer & a_Player)
{
if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_SHEARS) && (!m_IsSheared))
{
m_IsSheared = true;
m_World->BroadcastEntityMetadata(*this);
if (!a_Player.IsGameModeCreative())
{
a_Player.UseEquippedItem();
}
cItems Drops;
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
}
if ((a_Player.GetEquippedItem().m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - a_Player.GetEquippedItem().m_ItemDamage))
{
m_WoolColor = 15 - a_Player.GetEquippedItem().m_ItemDamage;
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
}
m_World->BroadcastEntityMetadata(*this);
}
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:27,代码来源:Sheep.cpp
示例9: GetDrops
void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
if (!m_IsSheared)
{
a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor));
}
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:7,代码来源:Sheep.cpp
示例10: switch
void cMooshroom::OnRightClicked(cPlayer & a_Player)
{
switch (a_Player.GetEquippedItem().m_ItemType)
{
case E_ITEM_BUCKET:
{
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
a_Player.GetInventory().AddItem(E_ITEM_MILK);
}
} break;
case E_ITEM_BOWL:
{
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
a_Player.GetInventory().AddItem(E_ITEM_MUSHROOM_SOUP);
}
} break;
case E_ITEM_SHEARS:
{
if (!a_Player.IsGameModeCreative())
{
a_Player.UseEquippedItem();
}
cItems Drops;
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow, false);
Destroy();
} break;
}
}
开发者ID:UltraCoderRU,项目名称:MCServer,代码行数:35,代码来源:Mooshroom.cpp
示例11: GetDrops
void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !static_cast<cPlayer *>(a_Killer)->IsGameModeCreative())
{
a_Items.push_back(cItem(E_ITEM_PAINTING));
}
}
开发者ID:1285done,项目名称:cuberite,代码行数:7,代码来源:Painting.cpp
示例12: OnRightClicked
void cSheep::OnRightClicked(cPlayer & a_Player)
{
const cItem & EquippedItem = a_Player.GetEquippedItem();
if ((EquippedItem.m_ItemType == E_ITEM_SHEARS) && !IsSheared() && !IsBaby())
{
m_IsSheared = true;
m_World->BroadcastEntityMetadata(*this);
a_Player.UseEquippedItem();
cItems Drops;
int NumDrops = m_World->GetTickRandomNumber(2) + 1;
Drops.push_back(cItem(E_BLOCK_WOOL, NumDrops, m_WoolColor));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
m_World->BroadcastSoundEffect("mob.sheep.shear", GetPosX(), GetPosY(), GetPosZ(), 1.0f, 1.0f);
}
else if ((EquippedItem.m_ItemType == E_ITEM_DYE) && (m_WoolColor != 15 - EquippedItem.m_ItemDamage))
{
m_WoolColor = 15 - EquippedItem.m_ItemDamage;
if (!a_Player.IsGameModeCreative())
{
a_Player.GetInventory().RemoveOneEquippedItem();
}
m_World->BroadcastEntityMetadata(*this);
}
}
开发者ID:Floppy012,项目名称:MCServer,代码行数:25,代码来源:Sheep.cpp
示例13: SetBurnTimes
void cFurnaceEntity::BurnNewFuel(void)
{
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
int NewTime = FR->GetBurnTime(m_Contents.GetSlot(fsFuel));
if ((NewTime == 0) || !CanCookInputToOutput())
{
// The item in the fuel slot is not suitable
// or the input and output isn't available for cooking
SetBurnTimes(0, 0);
SetIsCooking(false);
return;
}
// Burn one new fuel:
SetBurnTimes(NewTime, 0);
SetIsCooking(true);
if (m_Contents.GetSlot(fsFuel).m_ItemType == E_ITEM_LAVA_BUCKET)
{
m_Contents.SetSlot(fsFuel, cItem(E_ITEM_BUCKET));
}
else
{
m_Contents.ChangeSlotCount(fsFuel, -1);
}
}
开发者ID:4264,项目名称:cuberite,代码行数:25,代码来源:FurnaceEntity.cpp
示例14: GetDrops
void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
{
a_Items.push_back(cItem(E_ITEM_ITEM_FRAME));
}
}
开发者ID:Kortak,项目名称:MCServer,代码行数:7,代码来源:ItemFrame.cpp
示例15: LOGWARNING
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
if (Furnace == NULL)
{
LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false;
}
// Try move from the output slot:
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
{
cItem NewOutput(Furnace->GetOutputSlot());
Furnace->SetOutputSlot(NewOutput.AddCount(-1));
return true;
}
// No output moved, check if we can move an empty bucket out of the fuel slot:
if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
{
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsFuel, true))
{
Furnace->SetFuelSlot(cItem());
return true;
}
}
// Nothing can be moved
return false;
}
开发者ID:ChriPiv,项目名称:MCServer,代码行数:31,代码来源:HopperEntity.cpp
示例16: ASSERT
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
ASSERT(Furnace != NULL);
// Try move from the output slot:
if (MoveItemsFromSlot(Furnace->GetOutputSlot(), true))
{
cItem NewOutput(Furnace->GetOutputSlot());
Furnace->SetOutputSlot(NewOutput.AddCount(-1));
return true;
}
// No output moved, check if we can move an empty bucket out of the fuel slot:
if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
{
if (MoveItemsFromSlot(Furnace->GetFuelSlot(), true))
{
Furnace->SetFuelSlot(cItem());
return true;
}
}
// Nothing can be moved
return false;
}
开发者ID:l0ud,项目名称:MCServer,代码行数:27,代码来源:HopperEntity.cpp
示例17: AddRandomDropItem
void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
unsigned int LootingLevel = 0;
if (a_Killer != nullptr)
{
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
}
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH);
cItems RareDrops;
RareDrops.Add(cItem(E_ITEM_IRON));
RareDrops.Add(cItem(E_ITEM_CARROT));
RareDrops.Add(cItem(E_ITEM_POTATO));
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
AddRandomArmorDropItem(a_Drops, LootingLevel);
AddRandomWeaponDropItem(a_Drops, LootingLevel);
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:16,代码来源:Zombie.cpp
示例18: Noise
void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, size_t a_CountLootProbabs, int a_NumSlots, int a_Seed)
{
// Calculate the total weight:
int TotalProbab = 1;
for (size_t i = 0; i < a_CountLootProbabs; i++)
{
TotalProbab += a_LootProbabs[i].m_Weight;
}
// Pick the loot items:
cNoise Noise(a_Seed);
for (int i = 0; i < a_NumSlots; i++)
{
int Rnd = (Noise.IntNoise1DInt(i) / 7);
int LootRnd = Rnd % TotalProbab;
Rnd >>= 8;
cItem CurrentLoot = cItem(E_ITEM_BOOK, 1, 0); // TODO: enchantment
for (size_t j = 0; j < a_CountLootProbabs; j++)
{
LootRnd -= a_LootProbabs[i].m_Weight;
if (LootRnd < 0)
{
CurrentLoot = a_LootProbabs[i].m_Item;
CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
Rnd >>= 8;
break;
}
} // for j - a_LootProbabs[]
SetSlot(Rnd % m_NumSlots, CurrentLoot);
} // for i - NumSlots
开发者ID:JoeClacks,项目名称:MCServer,代码行数:30,代码来源:ItemGrid.cpp
示例19: AddRandomDropItem
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
MTRand r1;
int Count = static_cast<int>(static_cast<unsigned int>(r1.randInt()) % (a_Max + 1 - a_Min) + a_Min);
if (Count > 0)
{
a_Drops.push_back(cItem(a_Item, static_cast<char>(Count), a_ItemHealth));
}
}
开发者ID:rhamilton1415,项目名称:cuberite,代码行数:9,代码来源:Monster.cpp
示例20: AddRandomDropItem
void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
MTRand r1;
int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min;
if (Count > 0)
{
a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth));
}
}
开发者ID:4264,项目名称:cuberite,代码行数:9,代码来源:Monster.cpp
注:本文中的cItem函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论