Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

SetRequiredInputByType for MyObjectBuilder_MedicalRoom

Discussion in 'Programming Questions and Suggestions' started by HellArea, Jun 9, 2020.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. HellArea Trainee Engineer

    Hi. There is a way to set a custom power consumption value for the MedicalRoom?

    I writed this one

    using System;
    using Sandbox.Game.EntityComponents;
    using Sandbox.Common.ObjectBuilders;
    using Sandbox.ModAPI;
    using VRage.ModAPI;
    using VRage.Game.Components;
    using VRage.ObjectBuilders;

    public class PowerManager : MyGameLogicComponent
    private IMyTerminalBlock Block;

    public override void Init(MyObjectBuilder_EntityBase objectBuilder)
    Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
    Block = Entity as IMyTerminalBlock;
    Block.OnMarkForClose += Block_OnMarkForClose;

    public override void UpdateAfterSimulation100()
    float Value = (float)DateTime.Now.Second; //Just some value for test
    Block.ResourceSink.SetRequiredInputByType(MyResourceDistributorComponent.ElectricityId, Value);

    private void Block_OnMarkForClose(VRage.ModAPI.IMyEntity obj)
    Block.OnMarkForClose -= Block_OnMarkForClose;
    Block.PropertiesChanged -= Block_OnMarkForClose;

    This works well for a Survival Kit or for a Beacon for example.
Thread Status:
This last post in this thread was made more than 31 days old.