本文整理汇总了C#中Server.Items.Container.FindItemByType方法的典型用法代码示例。如果您正苦于以下问题:C# Container.FindItemByType方法的具体用法?C# Container.FindItemByType怎么用?C# Container.FindItemByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Items.Container
的用法示例。
在下文中一共展示了Container.FindItemByType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSortedItem
public static void AddSortedItem( Item item, Container cont )
{
Item item2 = cont.FindItemByType( item.GetType() );
if ( item2 != null && item2.Amount < 60000 )
{
item2.Amount++;
item.Delete();
}
else
cont.DropItem( item );
}
示例2: IncreaseTypeAmount
private static void IncreaseTypeAmount( Container c, Type type, double iMultiplyValue )
{
Item item = c.FindItemByType(type);
if( item != null && item.Stackable )
item.Amount = (int)(item.Amount * iMultiplyValue);
}
示例3: FindItemByType
//note: this only works for stackable items.
public static Item FindItemByType( Container pack, Type type, int amount )
{
//can't search a null pack!
if( pack == null )
{
return null;
}
//first check the backpack if it exists
Item bagitem = pack.FindItemByType( type );
//if not, then look to pull from keys
if( ( bagitem == null || bagitem.Amount < amount ) && CraftWithdraw( pack, new Type[]{ type }, amount - ( bagitem != null ? bagitem.Amount : 0 ) ) )
{
//the keys will have added this item to pack, so go looking for it again
return pack.FindItemByType( type );
}
//return either the item found from the bag, or null if they weren't found in keys either
return bagitem;
}