示例#1
0
        private void SetStockpilingState(bool newState)
        {
            m_isStockpiling = newState;

            SourceComp.SetProductionEnabledByType(BlockDefinition.StoredGasId, !m_isStockpiling && CanStore);
            ResourceSink.Update();
        }
示例#2
0
        private void SetDepressurizing(bool newValue)
        {
            m_isDepressurizing = newValue;

            SourceComp.SetProductionEnabledByType(m_oxygenGasId, newValue);
            ResourceSink.Update();
        }
示例#3
0
        private void SetDepressurizing()
        {
            if (m_isDepressurizing)
            {
                var tmpGasId = m_oxygenGasId;
                ResourceSink.RemoveType(ref tmpGasId);
            }
            else
            {
                ResourceSink.AddType(ref OxygenSinkInfo);
            }

            SourceComp.SetProductionEnabledByType(m_oxygenGasId, m_isDepressurizing);
            ResourceSink.Update();
        }
示例#4
0
 void ProducerEnadChanged()
 {
     SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, m_producerEnabled.Value);
 }
示例#5
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            var sourceDataList = new List <MyResourceSourceInfo>
            {
                new MyResourceSourceInfo {
                    ResourceTypeId = MyResourceDistributorComponent.ElectricityId, DefinedOutput = BlockDefinition.MaxPowerOutput, ProductionToCapacityMultiplier = 60 * 60
                }
            };

            SourceComp.Init(BlockDefinition.ResourceSourceGroup, sourceDataList);
            SourceComp.HasCapacityRemainingChanged += (id, source) => UpdateIsWorking();
            SourceComp.ProductionEnabledChanged    += Source_ProductionEnabledChanged;

            var batteryBuilder = (MyObjectBuilder_BatteryBlock)objectBuilder;

            SourceComp.SetProductionEnabledByType(MyResourceDistributorComponent.ElectricityId, batteryBuilder.ProducerEnabled);

            MaxStoredPower = BlockDefinition.MaxStoredPower;

            ResourceSink.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                Sink_ComputeRequiredPower);

            base.Init(objectBuilder, cubeGrid);

            ResourceSink.Update();

            MyDebug.AssertDebug(BlockDefinition != null);
            MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_BatteryBlock));

            if (batteryBuilder.CurrentStoredPower >= 0)
            {
                CurrentStoredPower = batteryBuilder.CurrentStoredPower;
            }
            else
            {
                CurrentStoredPower = BlockDefinition.InitialStoredPowerRatio * BlockDefinition.MaxStoredPower;
            }

            m_storedPower.Value = CurrentStoredPower;


            SemiautoEnabled = batteryBuilder.SemiautoEnabled;
            OnlyRecharge    = !batteryBuilder.ProducerEnabled;
            OnlyDischarge   = batteryBuilder.OnlyDischargeEnabled;
            UpdateMaxOutputAndEmissivity();

            UpdateText();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            IsWorkingChanged += MyBatteryBlock_IsWorkingChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_lastUpdateTime = MySession.Static.GameplayFrameCounter;

            if (IsWorking)
            {
                OnStartWorking();
            }
        }