[1.190.101][ModAPI] IMyCubeBlock.ResourceSink is broken

Digi shared this bug 5 years ago
Outdated

It seems that the ResourceSink property from IMyCubeBlock is not really assigned properly internally... some blocks have it, some don't, making it quite misleading and unreliable.


I suggest having it as an abstract method on the base that simply returns Components.Get<MyResourceSinkComponent>() and thrusters override it to return their shared sink instead.


Steps to reproduce, with thrusters in particular:

1. Create a local mod for script:

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

namespace BugReport
{
    [MyEntityComponentDescriptor(typeof(MyObjectBuilder_Thrust), false)]
    public class BugReport_ResourceSinkThrust : MyGameLogicComponent
    {
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;
        }

        public override void UpdateAfterSimulation()
        {
            var block = (IMyCubeBlock)Entity;
            var sink = block.Components.Get<MyResourceSinkComponent>();

            MyAPIGateway.Utilities.ShowNotification($"ResourceSink={block.ResourceSink != null}; Components.Get<Sink>()={sink != null}", 16);
        }
    }
}


2. Create an empty world with that local mod.


3. Place 2+ thrusters of same type on the same grid.


It will show that ResourceSink is null on all of them while the components.Get one is not null only on one.

Replies (1)

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.

Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards

Keen Software House: QA Department

Leave a Comment
 
Attach a file