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


C# EntityComponents.MyResourceSourceComponent类代码示例

本文整理汇总了C#中Sandbox.Game.EntityComponents.MyResourceSourceComponent的典型用法代码示例。如果您正苦于以下问题:C# MyResourceSourceComponent类的具体用法?C# MyResourceSourceComponent怎么用?C# MyResourceSourceComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MyResourceSourceComponent类属于Sandbox.Game.EntityComponents命名空间,在下文中一共展示了MyResourceSourceComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MySolarPanel

	    public MySolarPanel()
	    {
            SourceComp = new MyResourceSourceComponent();

            m_soundEmitter = new MyEntity3DSoundEmitter(this, true);
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
	    }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:7,代码来源:MySolarPanel.cs

示例2: MyGasTank

	    public MyGasTank()
	    {
            CreateTerminalControls();

			SourceComp = new MyResourceSourceComponent();
			ResourceSink = new MyResourceSinkComponent(2);
	    }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:7,代码来源:MyGasTank.cs

示例3: MyBattery

        public MyBattery(MyCharacter owner)
        {
            m_owner = owner;
            SyncObject = new MySyncBattery(this);
			ResourceSink = new MyResourceSinkComponent();
			ResourceSource = new MyResourceSourceComponent();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyBattery.cs

示例4: MyReactor

        public MyReactor()
        {
            CreateTerminalControls();

			SourceComp = new MyResourceSourceComponent();
            m_remainingPowerCapacity.ValueChanged += (x) => RemainingCapacityChanged();
            m_remainingPowerCapacity.ValidateNever();
        }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:8,代码来源:MyReactor.cs

示例5: MyGasGenerator

 public MyGasGenerator()
 {
     #if XB1 // XB1_SYNC_NOREFLECTION
     m_useConveyorSystem = SyncType.CreateAndAddProp<bool>();
     #endif // XB1
     CreateTerminalControls();
     SourceComp = new MyResourceSourceComponent(2);
     ResourceSink = new MyResourceSinkComponent();
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyGasGenerator.cs

示例6: MyPhysicalDistributionGroup

            public MyPhysicalDistributionGroup(MyDefinitionId typeId, MyResourceSourceComponent tempConnectedSource)
            {
                SinksByPriority = null; SourcesByPriority = null; SinkSourcePairs = null; FirstEndpoint = null;
                SinkDataByPriority = null; SourceDataByPriority = null; StockpilingStorage = null; OtherStorage = null;
                InputOutputData = new MyTuple<MySinkGroupData, MySourceGroupData>();
                MaxAvailableResources = 0f; ResourceState = MyResourceStateEnum.NoPower;
                AllocateData();

                InitFromTempConnected(typeId, tempConnectedSource);
            }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:10,代码来源:MyResourceDistributorComponent.cs

示例7: MyAirVent

        public MyAirVent()
        {
            #if XB1 // XB1_SYNC_NOREFLECTION
            m_isDepressurizing = SyncType.CreateAndAddProp<bool>();
            #endif // XB1
            CreateTerminalControls();

            ResourceSink = new MyResourceSinkComponent(2);
            SourceComp = new MyResourceSourceComponent();
            m_isDepressurizing.ValueChanged += (x) => SetDepressurizing();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:11,代码来源:MyAirVent.cs

示例8: MyReactor

        public MyReactor()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_remainingPowerCapacity = SyncType.CreateAndAddProp<float>();
            m_useConveyorSystem = SyncType.CreateAndAddProp<bool>();
#endif // XB1
            CreateTerminalControls();

			SourceComp = new MyResourceSourceComponent();
            m_remainingPowerCapacity.ValueChanged += (x) => RemainingCapacityChanged();
            m_remainingPowerCapacity.ValidateNever();
        }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:12,代码来源:MyReactor.cs

示例9: RemoveSourceLazy

        private void RemoveSourceLazy(MyResourceSourceComponent source)
        {
            foreach (var resourceTypeId in source.ResourceTypes)
		    {
                MyDefinitionId typeId = resourceTypeId;
			    var sourcesOfType = GetSourcesOfType(ref typeId, source.Group);
                if (sourcesOfType == null)
                {
                    Debug.Fail("SourcesOfType is null on removal of " + typeId.ToString());
                    continue;
                }
			    var typeIndex = GetTypeIndex(ref typeId);

                if (!sourcesOfType.Remove(source))
                {
                    int foundIndex = -1;
                    for (int pairIndex = 0; pairIndex < m_dataPerType[typeIndex].InputOutputList.Count; ++pairIndex)
                    {
                        if (m_dataPerType[typeIndex].InputOutputList[pairIndex].Item2 != source)
                            continue;

                        foundIndex = pairIndex;
                        break;
                    }

                    if (foundIndex != -1)
                    {
                        var matchingSink = m_dataPerType[typeIndex].InputOutputList[foundIndex].Item1;
                        m_dataPerType[typeIndex].InputOutputList.RemoveAtFast(foundIndex);
                        m_dataPerType[typeIndex].SinksByPriority[GetPriority(matchingSink)].Add(matchingSink);
                    }
                }

			    m_dataPerType[typeIndex].NeedsRecompute = true;
                m_dataPerType[typeIndex].GroupsDirty = true;

			    --m_dataPerType[typeIndex].SourceCount;
				if (m_dataPerType[typeIndex].SourceCount == 0)
				{
					m_dataPerType[typeIndex].SourcesEnabled= MyMultipleEnabledEnum.NoObjects;
				}
				else if (m_dataPerType[typeIndex].SourceCount== 1)
				{
				    var firstSourceOfType = GetFirstSourceOfType(ref typeId);
                    if (firstSourceOfType != null)
                        ChangeSourcesState(typeId, (firstSourceOfType.Enabled) ? MyMultipleEnabledEnum.AllEnabled : MyMultipleEnabledEnum.AllDisabled, MySession.Static.LocalPlayerId);
                    else
                    {
                        // Bug Fix - When battery is on grid it somehow leaves Sources = 1 even tought that no sources are present
                        --m_dataPerType[typeIndex].SourceCount;
                        m_dataPerType[typeIndex].SourcesEnabled = MyMultipleEnabledEnum.NoObjects;
                    }
				}
				else if (m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.Mixed)
				{
					// We were in mixed state and need to check whether we still are.
					m_dataPerType[typeIndex].SourcesEnabledDirty = true;
				}
				m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
		    }
	        source.ProductionEnabledChanged -= source_ProductionEnabledChanged;
		    source.MaxOutputChanged -= source_MaxOutputChanged;
		    source.HasCapacityRemainingChanged -= source_HasRemainingCapacityChanged;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:64,代码来源:MyResourceDistributorComponent.cs

示例10: AddSourceLazy

        private void AddSourceLazy(MyResourceSourceComponent source)
        {
            foreach (var resourceType in source.ResourceTypes)
		    {
                var typeId = resourceType;
				if(!m_initializedTypes.Contains(typeId))
					InitializeNewType(ref typeId);

			    var sourcesOfType = GetSourcesOfType(ref typeId, source.Group);
                if (sourcesOfType == null)
                {
                    Debug.Fail("SourcesOfType is null on add of " + typeId.ToString());
                    continue;
                }
			    int typeIndex = GetTypeIndex(ref typeId);
				Debug.Assert(!sourcesOfType.Contains(source));
				Debug.Assert(MatchesInfiniteCapacity(sourcesOfType, source), "All producers in the same group must have same 'infinite capacity' state.");

                MyResourceSinkComponent matchingSink = null;
                if (source.Container != null)
                {
                    foreach (var sinks in m_dataPerType[typeIndex].SinksByPriority)
                    {
                        foreach (var sink in sinks)
                        {
                            if (sink.Container == null)
                                continue;

                            var sourceInContainer = sink.Container.Get<MyResourceSourceComponent>();
                            if (sourceInContainer == source)
                            {
                                m_dataPerType[typeIndex].InputOutputList.Add(MyTuple.Create(sink, source));
                                matchingSink = sink;
                                break;
                            }
                        }
                        if (matchingSink == null)
                            continue;

                        sinks.Remove(matchingSink);
                        break;
                    }
                }

                if (matchingSink == null)
				    sourcesOfType.Add(source);

			    m_dataPerType[typeIndex].NeedsRecompute = true;
                m_dataPerType[typeIndex].GroupsDirty = true;
			    ++m_dataPerType[typeIndex].SourceCount;

				if (m_dataPerType[typeIndex].SourceCount == 1)
				{
					// This is the only source we have, so the state of all is the same as of this one.
					m_dataPerType[typeIndex].SourcesEnabled = (source.Enabled) ? MyMultipleEnabledEnum.AllEnabled : MyMultipleEnabledEnum.AllDisabled;
				}
				else if ((m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.AllEnabled && !source.Enabled) || (m_dataPerType[typeIndex].SourcesEnabled == MyMultipleEnabledEnum.AllDisabled && source.Enabled))
				{
					m_dataPerType[typeIndex].SourcesEnabled = MyMultipleEnabledEnum.Mixed;
				}
			    m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
		    }
		    source.HasCapacityRemainingChanged += source_HasRemainingCapacityChanged;
		    source.MaxOutputChanged += source_MaxOutputChanged;
	        source.ProductionEnabledChanged += source_ProductionEnabledChanged;
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:66,代码来源:MyResourceDistributorComponent.cs

示例11: MyReactor

        public MyReactor()
        {
            m_soundEmitter = new MyEntity3DSoundEmitter(this);
			SourceComp = new MyResourceSourceComponent();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:5,代码来源:MyReactor.cs

示例12: source_ProductionEnabledChanged

        private void source_ProductionEnabledChanged(MyDefinitionId changedResourceTypeId, MyResourceSourceComponent obj)
        {
            int typeIndex = GetTypeIndex(ref changedResourceTypeId);
            m_dataPerType[typeIndex].NeedsRecompute = true;
            m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
            m_dataPerType[typeIndex].SourcesEnabledDirty = true;

            if (m_dataPerType[typeIndex].SourceCount == 1)
                RecomputeResourceDistribution(ref changedResourceTypeId);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:10,代码来源:MyResourceDistributorComponent.cs

示例13: RemoveSource

	    public void RemoveSource(MyResourceSourceComponent source)
	    {
		    Debug.Assert(source != null);

            lock (m_sourcesToAdd)
            {
                if (m_sourcesToAdd.Contains(source))
                {
                    m_sourcesToAdd.Remove(source);
                    RemoveTypesFromChanges(source.ResourceTypes);
                    return;
                }
            }

            lock (m_sourcesToRemove)
            {
                m_sourcesToRemove.Add(source);
            }

            foreach (var resourceType in source.ResourceTypes)
            {
                int existingCount;
                if (!m_changedTypes.TryGetValue(resourceType, out existingCount))
                    m_changedTypes.Add(resourceType, 1);
                else
                    m_changedTypes[resourceType] = existingCount+1;
            }
	    }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:28,代码来源:MyResourceDistributorComponent.cs

示例14: GetPriority

		static internal int GetPriority(MyResourceSourceComponent source)
		{
			return m_sourceSubtypeToPriority[source.Group];
		}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:4,代码来源:MyResourceDistributorComponent.cs

示例15: source_HasRemainingCapacityChanged

	    private void source_HasRemainingCapacityChanged(MyDefinitionId changedResourceTypeId, MyResourceSourceComponent source)
	    {
		    int typeIndex = GetTypeIndex(ref changedResourceTypeId);
			m_dataPerType[typeIndex].NeedsRecompute = true;
			m_dataPerType[typeIndex].RemainingFuelTimeDirty = true;
	    }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:6,代码来源:MyResourceDistributorComponent.cs


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