本文整理汇总了C#中IMyConveyorEndpointBlock.GetPushInformation方法的典型用法代码示例。如果您正苦于以下问题:C# IMyConveyorEndpointBlock.GetPushInformation方法的具体用法?C# IMyConveyorEndpointBlock.GetPushInformation怎么用?C# IMyConveyorEndpointBlock.GetPushInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyConveyorEndpointBlock
的用法示例。
在下文中一共展示了IMyConveyorEndpointBlock.GetPushInformation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeMappingForBlock
//.........这里部分代码省略.........
// Ignore blocks without inventory
if (!conveyorEndpoint.CubeBlock.HasInventory) continue;
// Ignore blocks that do not implement IMyConveyorEndpointBlock interface
IMyConveyorEndpointBlock endpointBlock = conveyorEndpoint.CubeBlock as IMyConveyorEndpointBlock;
if (endpointBlock == null) continue;
// Iterate inventories to make sure we can take the items
bool isInventoryAvailable = false;
for (int i = 0; i < conveyorEndpoint.CubeBlock.InventoryCount; ++i)
{
var inventory = conveyorEndpoint.CubeBlock.GetInventory(i) as MyInventory;
System.Diagnostics.Debug.Assert(inventory != null, "Null or other inventory type!");
if ((inventory.GetFlags() & MyInventoryFlags.CanSend) == 0)
continue;
isInventoryAvailable = true;
break;
}
if (isInventoryAvailable)
{
if (!endpointMap.pullElements.Contains(endpointBlock))
endpointMap.pullElements.Add(endpointBlock);
}
}
}
}
}
}
// Process push mapping
PullInformation pushInformation = processedBlock.GetPushInformation();
if (pushInformation != null)
{
endpointMap.pushElements = new List<IMyConveyorEndpointBlock>();
lock (Pathfinding)
{
SetTraversalPlayerId(pushInformation.OwnerID);
HashSet<MyDefinitionId> definitions = new HashSet<MyDefinitionId>();
if (pushInformation.ItemDefinition != default(MyDefinitionId))
{
definitions.Add(pushInformation.ItemDefinition);
}
if (pushInformation.Constraint != null)
{
foreach (MyDefinitionId definition in pushInformation.Constraint.ConstrainedIds)
definitions.Add(definition);
foreach (MyObjectBuilderType constrainedType in pushInformation.Constraint.ConstrainedTypes)
{
MyDefinitionManager.Static.TryGetDefinitionsByTypeId(constrainedType, definitions);
}
}
// Empty constraint, no need to check, anything that can take items is okay, push requests will re-test anyway
if (definitions.Count == 0 && (pushInformation.Constraint == null || pushInformation.Constraint.Description == "Empty constraint"))
{
SetTraversalInventoryItemDefinitionId();
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate);
foreach (var conveyorEndpoint in MyGridConveyorSystem.Pathfinding)
示例2: ComputeMappingForBlock
private ConveyorEndpointMapping ComputeMappingForBlock(IMyConveyorEndpointBlock processedBlock)
{
ConveyorEndpointMapping endpointMap = new ConveyorEndpointMapping();
// Process pull mapping
PullInformation pullInformation = processedBlock.GetPullInformation();
if (pullInformation != null)
{
endpointMap.pullElements = new List<IMyConveyorEndpointBlock>();
lock (Pathfinding)
{
SetTraversalPlayerId(pullInformation.OwnerID);
// Pulling one specific item?
if (pullInformation.ItemDefinition != default(MyDefinitionId))
{
SetTraversalInventoryItemDefinitionId(pullInformation.ItemDefinition);
using (var invertedConductivity = new MyConveyorLine.InvertedConductivity())
{
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate, NeedsLargeTube(pullInformation.ItemDefinition) ? IsConveyorLargePredicate : null);
AddReachableEndpoints(processedBlock, endpointMap.pullElements, MyInventoryFlags.CanSend);
}
}
else if (pullInformation.Constraint != null)
{
SetTraversalInventoryItemDefinitionId();
using (var invertedConductivity = new MyConveyorLine.InvertedConductivity())
{
// Once for small tubes
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate, IsConveyorSmallPredicate);
AddReachableEndpoints(processedBlock, endpointMap.pullElements, MyInventoryFlags.CanSend);
// Once for large tubes
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate, null);
AddReachableEndpoints(processedBlock, endpointMap.pullElements, MyInventoryFlags.CanSend);
}
}
}
}
// Process push mapping
PullInformation pushInformation = processedBlock.GetPushInformation();
if (pushInformation != null)
{
endpointMap.pushElements = new List<IMyConveyorEndpointBlock>();
lock (Pathfinding)
{
SetTraversalPlayerId(pushInformation.OwnerID);
HashSet<MyDefinitionId> definitions = new HashSet<MyDefinitionId>();
if (pushInformation.ItemDefinition != default(MyDefinitionId))
{
definitions.Add(pushInformation.ItemDefinition);
}
if (pushInformation.Constraint != null)
{
foreach (MyDefinitionId definition in pushInformation.Constraint.ConstrainedIds)
definitions.Add(definition);
foreach (MyObjectBuilderType constrainedType in pushInformation.Constraint.ConstrainedTypes)
{
MyDefinitionManager.Static.TryGetDefinitionsByTypeId(constrainedType, definitions);
}
}
// Empty constraint, no need to check, anything that can take items is okay, push requests will re-test anyway
if (definitions.Count == 0 && (pushInformation.Constraint == null || pushInformation.Constraint.Description == "Empty constraint"))
{
SetTraversalInventoryItemDefinitionId();
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate);
AddReachableEndpoints(processedBlock, endpointMap.pushElements, MyInventoryFlags.CanReceive);
}
else
{
// Iterate through all the constrained item definitions
foreach (MyDefinitionId definitionId in definitions)
{
SetTraversalInventoryItemDefinitionId(definitionId);
if (NeedsLargeTube(definitionId))
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate, IsConveyorLargePredicate);
else
PrepareTraversal(processedBlock.ConveyorEndpoint, null, IsAccessAllowedPredicate);
AddReachableEndpoints(processedBlock, endpointMap.pushElements, MyInventoryFlags.CanReceive, definitionId);
}
}
}
}
return endpointMap;
}