public virtual void RegisterInSystems(MyCubeBlock block) { if (ResourceDistributor != null) { var powerProducer = block.Components.Get <MyResourceSourceComponent>(); if (powerProducer != null) { ResourceDistributor.AddSource(powerProducer); } var powerConsumer = block.Components.Get <MyResourceSinkComponent>(); if (!(block is MyThrust) && powerConsumer != null) { ResourceDistributor.AddSink(powerConsumer); } var socketOwner = block as IMyRechargeSocketOwner; if (socketOwner != null) { socketOwner.RechargeSocket.ResourceDistributor = ResourceDistributor; } } if (WeaponSystem != null) { var weapon = block as IMyGunObject <MyDeviceBase>; if (weapon != null) { WeaponSystem.Register(weapon); } } if (TerminalSystem != null) { var functionalBlock = block as MyTerminalBlock; if (functionalBlock != null) { TerminalSystem.Add(functionalBlock); } } // CH: We probably don't need to register controller blocks here. Block that's being added to a grid should not have a controller set var controllableBlock = block as MyShipController; Debug.Assert(controllableBlock == null || controllableBlock.ControllerInfo.Controller == null, "Controller of added block is not null. Call Cestmir"); /*if (ControlSystem != null) * { * var controllableBlock = block as MyShipController; * if (controllableBlock != null && controllableBlock.ControllerInfo.Controller != null) * ControlSystem.AddControllerBlock(controllableBlock); * }*/ var inventoryBlock = (block != null && block.HasInventory) ? block : null; if (inventoryBlock != null) { ConveyorSystem.Add(inventoryBlock); } var conveyorBlock = block as IMyConveyorEndpointBlock; if (conveyorBlock != null) { conveyorBlock.InitializeConveyorEndpoint(); ConveyorSystem.AddConveyorBlock(conveyorBlock); } var segmentBlock = block as IMyConveyorSegmentBlock; if (segmentBlock != null) { segmentBlock.InitializeConveyorSegment(); ConveyorSystem.AddSegmentBlock(segmentBlock); } var reflectorLight = block as MyReflectorLight; if (reflectorLight != null) { ReflectorLightSystem.Register(reflectorLight); } if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { var wheel = block as MyMotorSuspension; if (wheel != null) { WheelSystem.Register(wheel); } } var landingGear = block as IMyLandingGear; if (landingGear != null) { LandingSystem.Register(landingGear); } var gyro = block as MyGyro; if (gyro != null) { GyroSystem.Register(gyro); } var camera = block as MyCameraBlock; if (camera != null) { CameraSystem.Register(camera); } block.OnRegisteredToGridSystems(); }