本文整理汇总了C#中MyItemFlags类的典型用法代码示例。如果您正苦于以下问题:C# MyItemFlags类的具体用法?C# MyItemFlags怎么用?C# MyItemFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyItemFlags类属于命名空间,在下文中一共展示了MyItemFlags类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanStack
public virtual bool CanStack(MyObjectBuilderType typeId, MyStringId subtypeId, MyItemFlags flags)
{
if (flags == Flags &&
typeId == TypeId &&
subtypeId == SubtypeId)
{
return true;
}
return false;
}
示例2: CanStack
public override bool CanStack(MyObjectBuilderType typeId, MyStringHash subtypeId, MyItemFlags flags)
{
return false;
}
示例3: RemoveItemsOfType
void VRage.Game.ModAPI.IMyInventory.RemoveItemsOfType(VRage.MyFixedPoint amount, SerializableDefinitionId contentId, MyItemFlags flags, bool spawn)
{
RemoveItemsOfType(amount, contentId, flags, spawn);
}
示例4: FindFirstPositionOfType
private int? FindFirstPositionOfType(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
for (int i = 0; i < m_items.Count; ++i)
{
var content = m_items[i].Content;
if (content.GetObjectId() == contentId &&
content.Flags == flags) return i;
}
return null;
}
示例5: RemoveItemsOfType
public override MyFixedPoint RemoveItemsOfType(MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, bool spawn = false)
{
return TransferOrRemove(this, amount, contentId, flags, null, spawn, onlyWhole: false);
}
示例6: GetItemAmount
public int GetItemAmount(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
foreach (var item in m_items)
{
if (item.Content.CanStack(contentId.TypeId, contentId.SubtypeId, flags))
{
return item.Amount;
}
}
return 0;
}
示例7: TransferOrRemove
private static MyFixedPoint TransferOrRemove(MyInventory src, MyFixedPoint? amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, MyInventory dst = null, bool spawn = false, bool onlyWhole = true)
{
MyFixedPoint removedAmount = 0;
if (!onlyWhole)
{
amount = MyFixedPoint.Min(amount.Value, src.GetItemAmount(contentId, flags));
}
//Debug.Assert(!amount.HasValue || amount.Value > 0, "Transfering 0 amount of item.");
if (!onlyWhole || src.ContainItems(amount, contentId, flags))
{
bool transferAll = !amount.HasValue;
MyFixedPoint remainingAmount = transferAll ? 0 : amount.Value;
//TODO(AF) Remove oxygen specific code from inventory.
//Will be fixed once MyInventory will support Entities.
// If the requested item is an oxygen container, do a preliminary loop to pull any non-full items first.
if (contentId.TypeId == typeof(MyObjectBuilder_OxygenContainerObject) || contentId.TypeId == typeof(MyObjectBuilder_GasContainerObject))
{
int k = 0;
while (k < src.m_items.Count)
{
if (!transferAll && remainingAmount == 0)
break;
MyPhysicalInventoryItem item = src.m_items[k];
// Skip full oxygen bottles in this loop. They will not be skipped in the next one.
var oxygenBottle = item.Content as MyObjectBuilder_GasContainerObject;
if (oxygenBottle != null && oxygenBottle.GasLevel == 1f)
{
k++;
continue;
}
if (item.Content.GetObjectId() != contentId)
{
k++;
continue;
}
if (transferAll || remainingAmount >= item.Amount)
{
removedAmount += item.Amount;
remainingAmount -= item.Amount;
Transfer(src, dst, item.ItemId, -1, spawn: spawn);
}
else
{
removedAmount += item.Amount;
Transfer(src, dst, item.ItemId, -1, remainingAmount, spawn);
remainingAmount = 0;
}
}
}
// End of oxygen specific code
int i = 0;
while (i < src.m_items.Count)
{
if (!transferAll && remainingAmount == 0)
break;
MyPhysicalInventoryItem item = src.m_items[i];
var objectId = item.Content.GetId();
if (objectId != contentId && item.Content.TypeId == typeof(MyObjectBuilder_BlockItem))
{
//objectId = MyDefinitionManager.Static.GetComponentId(item.Content.GetObjectId());
objectId = item.Content.GetObjectId();
}
if (objectId != contentId)
{
i++;
continue;
}
if (transferAll || remainingAmount >= item.Amount)
{
removedAmount += item.Amount;
remainingAmount -= item.Amount;
Transfer(src, dst, item.ItemId, -1, spawn: spawn);
}
else
{
removedAmount += remainingAmount;
Transfer(src, dst, item.ItemId, -1, remainingAmount, spawn);
remainingAmount = 0;
}
}
}
return removedAmount;
}
示例8: GetItemAmount
public MyFixedPoint GetItemAmount(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
MyFixedPoint amount = 0;
foreach (var item in m_items)
{
if (item.Content.GetObjectId() == contentId &&
item.Content.Flags == flags)
amount += item.Amount;
}
return amount;
}
示例9: ContainItems
public bool ContainItems(MyFixedPoint? amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
int? itemPos = FindFirstPositionOfType(contentId, flags);
if (!itemPos.HasValue)
return false;
int i = itemPos.Value;
MyFixedPoint amountPresent = m_items[i].Amount;
if (!amount.HasValue || amountPresent >= amount)
return true;
for (i++; i < m_items.Count; ++i)
{
var content = m_items[i].Content;
if (contentId == content.GetObjectId() &&
flags == content.Flags)
{
amountPresent += m_items[i].Amount;
}
}
return amountPresent >= amount;
}
示例10: CanStack
public override bool CanStack(MyObjectBuilderType typeId, MyStringHash subtypeId, MyItemFlags flags)
{
MyDefinitionId defId = new MyDefinitionId(typeId, subtypeId);
MyDefinitionId myId = new MyDefinitionId(BlockDefId.TypeId, BlockDefId.SubtypeId);
return myId == BlockDefId && flags == this.Flags;
}
示例11: GetItemAmount
public override MyFixedPoint GetItemAmount(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
MyFixedPoint amount = 0;
foreach (var item in m_items)
{
var objectId = item.Content.GetObjectId();
if (contentId != objectId && item.Content.TypeId == typeof(MyObjectBuilder_BlockItem))
{
objectId = MyDefinitionManager.Static.GetComponentId(item.Content.GetObjectId());
}
if (objectId == contentId &&
item.Content.Flags == flags)
amount += item.Amount;
}
return amount;
}
示例12: GetItemAmount
VRage.MyFixedPoint Sandbox.ModAPI.Interfaces.IMyInventory.GetItemAmount(SerializableDefinitionId contentId, MyItemFlags flags)
{
return GetItemAmount(contentId,flags);
}
示例13: GetItemAmount
public abstract MyFixedPoint GetItemAmount(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, bool substitute = false);
示例14: RemoveItemsOfType
public override MyFixedPoint RemoveItemsOfType(MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, bool spawn = false)
{
var restAmount = amount;
foreach (MyInventoryBase inventory in m_children.Reader)
{
restAmount -= inventory.RemoveItemsOfType(restAmount, contentId, flags, spawn);
}
return amount - restAmount;
}
示例15: AddItems
public bool AddItems(int count, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None)
{
var componentBuilder = (MyObjectBuilder_PhysicalObject)Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.CreateNewObject(contentId);
Debug.Assert(componentBuilder != null, "Could not cast object builder to physical object");
if (componentBuilder == null) return false;
componentBuilder.Flags = flags;
return AddItems(count, componentBuilder);
}