• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# EntityComponents.MyResourceSourceComponent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: MyBatteryBlock

        public MyBatteryBlock()
        {
#if XB1 // XB1_SYNC_NOREFLECTION
            m_isFull = SyncType.CreateAndAddProp<bool>();
            m_onlyRecharge = SyncType.CreateAndAddProp<bool>();
            m_onlyDischarge = SyncType.CreateAndAddProp<bool>();
            m_semiautoEnabled = SyncType.CreateAndAddProp<bool>();
            m_producerEnabled = SyncType.CreateAndAddProp<bool>();
            m_storedPower = SyncType.CreateAndAddProp<float>();
#endif // XB1
            CreateTerminalControls();

            SourceComp = new MyResourceSourceComponent();
            ResourceSink = new MyResourceSinkComponent();
            m_semiautoEnabled.ValueChanged += (x) => UpdateMaxOutputAndEmissivity();
            m_onlyRecharge.ValueChanged += (x) => { if (m_onlyRecharge.Value) m_onlyDischarge.Value = false; UpdateMaxOutputAndEmissivity(); };
            m_onlyDischarge.ValueChanged += (x) => { if (m_onlyDischarge.Value) m_onlyRecharge.Value = false; UpdateMaxOutputAndEmissivity(); };

            m_producerEnabled.ValueChanged += (x) => ProducerEnadChanged();
            m_storedPower.ValueChanged += (x) => CapacityChanged();
	    }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:21,代码来源:MyBatteryBlock.cs


示例17: MatchesInfiniteCapacity

	    private bool MatchesInfiniteCapacity(HashSet<MyResourceSourceComponent> group, MyResourceSourceComponent producer)
	    {
		    foreach (MyResourceSourceComponent source in group)
		    {
			    if (producer.IsInfiniteCapacity != source.IsInfiniteCapacity)
				    return false;
		    }
		    return true;
	    }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:9,代码来源:MyResourceDistributorComponent.cs


示例18: MyAirVent

        public MyAirVent()
        {
            CreateTerminalControls();

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


示例19: MyBatteryBlock

        public MyBatteryBlock()
        {
            CreateTerminalControls();

            SourceComp = new MyResourceSourceComponent();
            ResourceSink = new MyResourceSinkComponent();
            m_semiautoEnabled.ValueChanged += (x) => UpdateMaxOutputAndEmissivity();
            m_onlyRecharge.ValueChanged += (x) => { if (m_onlyRecharge.Value) m_onlyDischarge.Value = false; UpdateMaxOutputAndEmissivity(); };
            m_onlyDischarge.ValueChanged += (x) => { if (m_onlyDischarge.Value) m_onlyRecharge.Value = false; UpdateMaxOutputAndEmissivity(); };

            m_producerEnabled.ValueChanged += (x) => ProducerEnadChanged();
            m_storedPower.ValueChanged += (x) => CapacityChanged();
	    }
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:13,代码来源:MyBatteryBlock.cs


示例20: Source_CurrentOutputChanged

        private void Source_CurrentOutputChanged(MyDefinitionId changedResourceId, float oldOutput, MyResourceSourceComponent source)
        {
            int typeIndex;
            if (!TryGetTypeIndex(ref changedResourceId, out typeIndex))
                return;

            float timeSinceLastOutputSeconds = (MySession.Static.GameplayFrameCounter - m_storedGases[typeIndex].LastOutputTime) * VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
            m_storedGases[typeIndex].LastOutputTime = MySession.Static.GameplayFrameCounter;
            float outputAmount = oldOutput*timeSinceLastOutputSeconds;

            m_storedGases[typeIndex].NextGasTransfer -= outputAmount;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:12,代码来源:MyCharacterOxygenComponent.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Gui.MyHudNotification类代码示例发布时间:2022-05-26
下一篇:
C# EntityComponents.MyResourceSinkComponent类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap