本文整理汇总了C#中Sandbox.Game.EntityComponents.MyResourceSinkComponent.SetInputFromDistributor方法的典型用法代码示例。如果您正苦于以下问题:C# MyResourceSinkComponent.SetInputFromDistributor方法的具体用法?C# MyResourceSinkComponent.SetInputFromDistributor怎么用?C# MyResourceSinkComponent.SetInputFromDistributor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sandbox.Game.EntityComponents.MyResourceSinkComponent
的用法示例。
在下文中一共展示了MyResourceSinkComponent.SetInputFromDistributor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveSinkLazy
private void RemoveSinkLazy(MyResourceSinkComponent sink, bool resetSinkInput = true)
{
foreach (var acceptedResourceId in sink.AcceptedResources)
{
MyDefinitionId typeId = acceptedResourceId;
var sinksOfType = GetSinksOfType(ref typeId, sink.Group);
if (sinksOfType == null)
{
//Debug.Fail("SinksOfType is null on removal of " + typeId.ToString());
continue;
}
int typeIndex = GetTypeIndex(ref typeId);
if (!sinksOfType.Remove(sink))
{
int foundIndex = -1;
for(int pairIndex = 0; pairIndex < m_dataPerType[typeIndex].InputOutputList.Count; ++pairIndex)
{
if (m_dataPerType[typeIndex].InputOutputList[pairIndex].Item1 != sink)
continue;
foundIndex = pairIndex;
break;
}
if (foundIndex != -1)
{
var matchingSource = m_dataPerType[typeIndex].InputOutputList[foundIndex].Item2;
m_dataPerType[typeIndex].InputOutputList.RemoveAtFast(foundIndex);
m_dataPerType[typeIndex].SourcesByPriority[GetPriority(matchingSource)].Add(matchingSource);
}
}
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].GroupsDirty = true;
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
if (resetSinkInput)
sink.SetInputFromDistributor(typeId, 0.0f, IsAdaptible(sink), false);
}
sink.OnRemoveType -= Sink_OnRemoveType;
sink.OnAddType -= Sink_OnAddType;
sink.RequiredInputChanged -= Sink_RequiredInputChanged;
sink.ResourceAvailable -= Sink_IsResourceAvailable;
}
示例2: RemoveSink
public void RemoveSink(MyResourceSinkComponent sink, bool resetSinkInput = true, bool markedForClose = false)
{
if (markedForClose)
return;
Debug.Assert(sink != null);
foreach (var typeId in sink.AcceptedResources)
{
var sinksOfType = GetSinksOfType(typeId, sink.Group);
int typeIndex = GetTypeIndex(typeId);
if (!sinksOfType.Remove(sink))
{
int foundIndex = -1;
for(int pairIndex = 0; pairIndex < m_dataPerType[typeIndex].InputOutputList.Count; ++pairIndex)
{
if (m_dataPerType[typeIndex].InputOutputList[pairIndex].Item1 != sink)
continue;
foundIndex = pairIndex;
break;
}
if (foundIndex != -1)
{
var matchingSource = m_dataPerType[typeIndex].InputOutputList[foundIndex].Item2;
m_dataPerType[typeIndex].InputOutputList.RemoveAtFast(foundIndex);
m_dataPerType[typeIndex].SourcesByPriority[GetPriority(matchingSource)].Add(matchingSource);
}
}
m_dataPerType[typeIndex].NeedsRecompute = true;
m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
if (resetSinkInput)
sink.SetInputFromDistributor(typeId, 0.0f, IsAdaptible(sink));
}
sink.OnAddType -= Sink_OnAddType;
sink.RequiredInputChanged -= Sink_RequiredInputChanged;
sink.ResourceAvailable -= Sink_IsResourceAvailable;
}