当前位置: 首页>>代码示例>>C#>>正文


C# MyResourceSinkComponent.SetInputFromDistributor方法代码示例

本文整理汇总了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;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:45,代码来源:MyResourceDistributorComponent.cs

示例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;
	    }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:41,代码来源:MyResourceDistributorComponent.cs


注:本文中的Sandbox.Game.EntityComponents.MyResourceSinkComponent.SetInputFromDistributor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。