コード例 #1
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            IsWorkingChanged += OnIsWorkingChanged;
            NeedsUpdate      |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            InitializeConveyorEndpoint();

            SourceComp.Init(
                BlockDefinition.ResourceSourceGroup,
                new MyResourceSourceInfo
            {
                ResourceTypeId = BlockDefinition.ProducedGas,
                DefinedOutput  = BlockDefinition.MaxGasOutput,
                ProductionToCapacityMultiplier = 1,
                IsInfiniteCapacity             = true,
            });
            SourceComp.Enabled = IsWorking;

            ResourceSink.Init(
                BlockDefinition.ResourceSinkGroup,
                new MyResourceSinkInfo
            {
                ResourceTypeId    = MyResourceDistributorComponent.ElectricityId,
                MaxRequiredInput  = BlockDefinition.OperationalPowerConsumption,
                RequiredInputFunc = ComputeRequiredPower,
            });
            ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
            ResourceSink.Update();

            GameLogic      = new MySolarGameLogicComponent();
            SolarComponent = GameLogic as MySolarGameLogicComponent;

            SolarComponent.Initialize(BlockDefinition.PanelOrientation, BlockDefinition.IsTwoSided, BlockDefinition.PanelOffset, this);

            AddDebugRenderComponent(new MyDebugRenderComponentSolarPanel(this));

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_OnIsFunctionalChanged;

            UpdateVisual();
            UpdateDisplay();
        }
コード例 #2
0
ファイル: MySolarPanel.cs プロジェクト: feiyuren233/vrage
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            SolarPanelDefinition = BlockDefinition as MySolarPanelDefinition;
            IsWorkingChanged    += OnIsWorkingChanged;
            NeedsUpdate          = MyEntityUpdateEnum.EACH_100TH_FRAME;

            var sourceDataList = new List <MyResourceSourceInfo>
            {
                new MyResourceSourceInfo {
                    ResourceTypeId = MyResourceDistributorComponent.ElectricityId, DefinedOutput = SolarPanelDefinition.MaxPowerOutput, IsInfiniteCapacity = true, ProductionToCapacityMultiplier = 60 * 60
                }
            };

            SourceComp.Init(SolarPanelDefinition.ResourceSourceGroup, sourceDataList);

            GameLogic      = new MySolarGameLogicComponent();
            SolarComponent = GameLogic as MySolarGameLogicComponent;

            SolarComponent.Initialize(SolarPanelDefinition.PanelOrientation, SolarPanelDefinition.IsTwoSided, SolarPanelDefinition.PanelOffset, this);

            AddDebugRenderComponent(new Sandbox.Game.Components.MyDebugRenderComponentSolarPanel(this));
        }