1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

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

    HellArea Trainee Engineer

    Messages:
    29
    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;


    [MyEntityComponentDescriptor(typeof(MyObjectBuilder_MedicalRoom))]
    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.