本文整理汇总了C#中MyItemFlags类的典型用法代码示例。如果您正苦于以下问题:C# MyItemFlags类的具体用法?C# MyItemFlags怎么用?C# MyItemFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyItemFlags类属于命名空间,在下文中一共展示了MyItemFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CanStack
public virtual bool CanStack(MyObjectBuilderType typeId, MyStringId subtypeId, MyItemFlags flags)
{
if (flags == Flags &&
typeId == TypeId &&
subtypeId == SubtypeId)
{
return true;
}
return false;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:10,代码来源:MyObjectBuilder_PhysicalObject.cs
示例2: CanStack
public override bool CanStack(MyObjectBuilderType typeId, MyStringHash subtypeId, MyItemFlags flags)
{
return false;
}
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:4,代码来源:MyObjectBuilder_BlockItem.cs
示例3: RemoveItemsOfType
void VRage.Game.ModAPI.IMyInventory.RemoveItemsOfType(VRage.MyFixedPoint amount, SerializableDefinitionId contentId, MyItemFlags flags, bool spawn)
{
RemoveItemsOfType(amount, contentId, flags, spawn);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:4,代码来源:MyInventory_ModAPI.cs
示例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;
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:11,代码来源:MyInventory.cs
示例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);
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:4,代码来源:MyInventory.cs
示例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;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:11,代码来源:MyConstructionStockpile.cs
示例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;
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:96,代码来源:MyInventory.cs
示例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;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:12,代码来源:MyInventory.cs
示例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;
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:23,代码来源:MyInventory.cs
示例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;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:6,代码来源:MyObjectBuilder_BlockItem.cs
示例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;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:18,代码来源:MyInventory.cs
示例12: GetItemAmount
VRage.MyFixedPoint Sandbox.ModAPI.Interfaces.IMyInventory.GetItemAmount(SerializableDefinitionId contentId, MyItemFlags flags)
{
return GetItemAmount(contentId,flags);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:4,代码来源:MyInventory_ModAPI.cs
示例13: GetItemAmount
public abstract MyFixedPoint GetItemAmount(MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, bool substitute = false);
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:1,代码来源:MyInventoryBase.cs
示例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;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyInventoryAggregate.cs
示例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);
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:10,代码来源:MyConstructionStockpile.cs
示例16: RemoveItemsOfType
public void RemoveItemsOfType(MyFixedPoint amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, bool spawn = false)
{
TransferOrRemove(this, amount, contentId, flags, null, spawn);
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:4,代码来源:MyInventory.cs
示例17: RemoveItems
public bool RemoveItems(int count, MyDefinitionId id, MyItemFlags flags = MyItemFlags.None)
{
int index = 0;
foreach (var item in m_items)
{
if (item.Content.CanStack(id.TypeId, id.SubtypeId, flags))
break;
index++;
}
return RemoveItemsInternal(index, count);
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:11,代码来源:MyConstructionStockpile.cs
示例18: TransferOrRemove
private static void TransferOrRemove(MyInventory src, MyFixedPoint? amount, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, MyInventory dst = null, bool spawn = false)
{
//Debug.Assert(!amount.HasValue || amount.Value > 0, "Transfering 0 amount of item.");
if (src.ContainItems(amount, contentId, flags))
{
bool transferAll = !amount.HasValue;
MyFixedPoint remainingAmount = transferAll ? 0 : amount.Value;
int i = 0;
while (i < src.m_items.Count)
{
if (!transferAll && remainingAmount == 0)
break;
MyInventoryItem item = src.m_items[i];
//TODO(AF) Remove oxygen specific code from inventory.
//Will be fixed once MyInventory will support Entities.
var oxygenBottle = item.Content as MyObjectBuilder_OxygenContainerObject;
if (oxygenBottle != null && oxygenBottle.OxygenLevel == 1f)
{
i++;
continue;
}
// End of oxygen specific code
if (item.Content.GetObjectId() != contentId)
{
i++;
continue;
}
if (transferAll || remainingAmount >= item.Amount)
{
remainingAmount -= item.Amount;
Transfer(src, dst, item.ItemId, -1, spawn: spawn);
}
else
{
Transfer(src, dst, item.ItemId, -1, remainingAmount, spawn);
remainingAmount = 0;
}
}
}
}
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:46,代码来源:MyInventory.cs
示例19: Transfer
public static MyFixedPoint Transfer(MyInventory src, MyInventory dst, MyDefinitionId contentId, MyItemFlags flags = MyItemFlags.None, MyFixedPoint? amount = null, bool spawn = false)
{
return TransferOrRemove(src, amount, contentId, flags, dst);
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:4,代码来源:MyInventory.cs
示例20: CanStack
public override bool CanStack(MyObjectBuilderType type, MyStringId subtypeId, MyItemFlags flags)
{
return false; // weapons shouldn't stack
}
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:4,代码来源:MyObjectBuilder_PhysicalGunObject.cs
注:本文中的MyItemFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论