public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            var blockDefinition = BlockDefinition as MyProgrammableBlockDefinition;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                blockDefinition.ResourceSinkGroup,
                0.0005f,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
            sinkComp.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);
            var programmableBlockBuilder = (MyObjectBuilder_MyProgrammableBlock)objectBuilder;

            m_editorData  = m_programData = programmableBlockBuilder.Program;
            m_storageData = programmableBlockBuilder.Storage;
            this.m_terminalRunArgument = programmableBlockBuilder.DefaultRunArgument;

            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;

            ResourceSink.Update();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            IsWorkingChanged += MyProgrammableBlock_IsWorkingChanged;

            if (Sync.IsServer && Sync.Clients != null)
            {
                Sync.Clients.ClientRemoved += ProgrammableBlock_ClientRemoved;
            }
        }
示例#2
0
        void UpdateTexts()
        {
            DetailedInfo.Clear();
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MyCommonTexts.BlockPropertiesText_Type));
            DetailedInfo.Append(BlockDefinition.DisplayNameText);
            DetailedInfo.Append("\n");
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput));
            MyValueFormatter.AppendWorkInBestUnit(ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId), DetailedInfo);
            DetailedInfo.Append("\n");

            if (!MySession.Static.Settings.EnableOxygen || !MySession.Static.Settings.EnableOxygenPressurization)
            {
                DetailedInfo.Append("Oxygen disabled in world settings!");
            }
            else
            {
                var oxygenBlock = GetOxygenBlock();
                if (oxygenBlock.Room == null || !oxygenBlock.Room.IsPressurized)
                {
                    DetailedInfo.Append("Room pressure: Not pressurized");
                }
                else
                {
                    DetailedInfo.Append("Room pressure: " + (oxygenBlock.Room.OxygenLevel(CubeGrid.GridSize) * 100f).ToString("F") + "%");
                }
            }
            RaisePropertiesChanged();
        }
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0.0f);
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink.Update();

            var ob = objectBuilder as MyObjectBuilder_PistonBase;

            Velocity.Value = ob.Velocity * BlockDefinition.MaxVelocity;
            MaxLimit.Value = ob.MaxLimit.HasValue ? Math.Min(DenormalizeDistance(ob.MaxLimit.Value), BlockDefinition.Maximum) : BlockDefinition.Maximum;
            MinLimit.Value = ob.MinLimit.HasValue ? Math.Max(DenormalizeDistance(ob.MinLimit.Value), BlockDefinition.Minimum) : BlockDefinition.Minimum;

            m_currentPos.Value = ob.CurrentPosition;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
示例#4
0
        public override void Register(MyEntity entity, Vector3I forwardVector)
        {
            var character = entity as MyCharacter;

            if (character == null)
            {
                return;
            }

            base.Register(entity, forwardVector);

            MyDefinitionId fuelType   = FuelType(entity);
            int            typeIndex  = GetTypeIndex(ref fuelType);
            float          efficiency = 1.0f;

            if (MyFakes.ENABLE_HYDROGEN_FUEL)
            {
                efficiency = Jetpack.FuelConverterDefinition.Efficiency;
            }

            m_dataByFuelType[typeIndex].Efficiency    = efficiency;
            m_dataByFuelType[typeIndex].EnergyDensity = Jetpack.FuelDefinition.EnergyDensity;
            ResourceSink.SetMaxRequiredInputByType(fuelType, ResourceSink.MaxRequiredInputByType(fuelType) + PowerAmountToFuel(ref fuelType, Jetpack.MaxPowerConsumption));

            SlowdownFactor = Math.Max(character.Definition.Jetpack.ThrustProperties.SlowdownFactor, SlowdownFactor);
        }
示例#5
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            var ob = objectBuilder as MyObjectBuilder_SmallGatlingGun;

            var weaponBlockDefinition = BlockDefinition as MyWeaponBlockDefinition;

            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                FixSingleInventory();
            }
            m_soundEmitterRotor = new MyEntity3DSoundEmitter(this);

            if (this.GetInventory() == null)
            {
                MyInventory inventory = null;
                if (weaponBlockDefinition != null)
                {
                    inventory = new MyInventory(weaponBlockDefinition.InventoryMaxVolume, new Vector3(0.4f, 0.4f, 0.4f), MyInventoryFlags.CanReceive);
                }
                else
                {
                    inventory = new MyInventory(64.0f / 1000, new Vector3(0.4f, 0.4f, 0.4f), MyInventoryFlags.CanReceive);
                }

                Components.Add <MyInventoryBase>(inventory);

                this.GetInventory().Init(ob.Inventory);
            }

            Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!");

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                weaponBlockDefinition.ResourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_SHIP_GUN,
                () => ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId));
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            m_gunBase.Init(ob.GunBase, BlockDefinition, this);

            GetBarrelAndMuzzle();
            //if (m_ammoPerShotConsumption == 0)
            //    m_ammoPerShotConsumption = (MyFixedPoint)((45.0f / (1000.0f / MyGatlingConstants.SHOT_INTERVAL_IN_MILISECONDS)) / m_gunBase.WeaponProperties.AmmoMagazineDefinition.Capacity);


            ResourceSink.Update();
            AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            m_useConveyorSystem.Value = ob.UseConveyorSystem;
        }
示例#6
0
        float ComputeRequiredGas()
        {
            if (!IsWorking)
            {
                return(0f);
            }

            float inputRequiredToFillIn100Updates = OxygenAmountMissing * MyEngineConstants.UPDATE_STEPS_PER_SECOND / 100f;

            return(Math.Min(inputRequiredToFillIn100Updates, ResourceSink.MaxRequiredInputByType(MyCharacterOxygenComponent.OxygenId) * 0.1f));
        }
示例#7
0
        private void UpdateDetailedInfo()
        {
            DetailedInfo.Clear();
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MyCommonTexts.BlockPropertiesText_Type));
            DetailedInfo.Append(BlockDefinition.DisplayNameText);
            DetailedInfo.AppendFormat("\n");
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput));
            MyValueFormatter.AppendWorkInBestUnit(ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId), DetailedInfo);
            DetailedInfo.AppendFormat("\n");

            RaisePropertiesChanged();
        }
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            var timerBlockDefinition = BlockDefinition as MyTimerBlockDefinition;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                timerBlockDefinition.ResourceSinkGroup,
                0.0000001f,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            var ob = objectBuilder as MyObjectBuilder_TimerBlock;

            Toolbar = new MyToolbar(MyToolbarType.ButtonPanel, 9, 10);
            Toolbar.Init(ob.Toolbar, this);
            Toolbar.ItemChanged += Toolbar_ItemChanged;

            if (ob.JustTriggered)
            {
                NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
            }

            IsCountingDown       = ob.IsCountingDown;
            m_countdownMsStart   = ob.Delay;
            m_countdownMsCurrent = ob.CurrentTime;
            Silent = ob.Silent;

            if (m_countdownMsCurrent > 0)
            {
                NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME;
            }

            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink.Update();

            AddDebugRenderComponent(new Sandbox.Game.Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            m_beepStart   = new MySoundPair(timerBlockDefinition.TimerSoundStart);
            m_beepMid     = new MySoundPair(timerBlockDefinition.TimerSoundMid);
            m_beepEnd     = new MySoundPair(timerBlockDefinition.TimerSoundEnd);
            m_beepEmitter = new MyEntity3DSoundEmitter(this);
        }
        private void UpdateText()
        {
            DetailedInfo.Clear();
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MyCommonTexts.BlockPropertiesText_Type));
            DetailedInfo.Append(BlockDefinition.DisplayNameText);
            DetailedInfo.Append("\n");
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput));
            MyValueFormatter.AppendWorkInBestUnit(ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId), DetailedInfo);

            if (!MySession.Static.Settings.EnableOxygen)
            {
                DetailedInfo.Append("\n");
                DetailedInfo.Append("Oxygen disabled in world settings!");
            }
        }
示例#10
0
        private float Sink_ComputeRequiredPower()
        {
            bool  canRecharge    = Enabled && IsFunctional && !m_isFull;
            bool  shouldRecharge = OnlyRecharge || !OnlyDischarge;
            float inputToFillInUpdateInterval = (MaxStoredPower - CurrentStoredPower) * VRage.Game.MyEngineConstants.UPDATE_STEPS_PER_SECOND / m_productionUpdateInterval * SourceComp.ProductionToCapacityMultiplierByType(MyResourceDistributorComponent.ElectricityId);
            float currentOutput = SourceComp.CurrentOutputByType(MyResourceDistributorComponent.ElectricityId);

            float requiredInput = 0;

            if (canRecharge && shouldRecharge)
            {
                float maxRequiredInput = ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId);
                requiredInput = Math.Min(inputToFillInUpdateInterval + currentOutput, maxRequiredInput);
            }
            return(requiredInput);
        }
示例#11
0
        private void UpdateDisplay()
        {
            DetailedInfo.Clear();
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MyCommonTexts.BlockPropertiesText_Type));
            DetailedInfo.Append(BlockDefinition.DisplayNameText);
            DetailedInfo.Append("\n");

            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput));
            MyValueFormatter.AppendWorkInBestUnit(ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId), DetailedInfo);
            DetailedInfo.Append("\n");

            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_OxygenOutput));
            DetailedInfo.Append((SourceComp.MaxOutputByType(BlockDefinition.ProducedGas)*60).ToString("F"));
            DetailedInfo.Append(" L/min");

            RaisePropertiesChanged();
            UpdateEmissivity();
        }
示例#12
0
        private void UdpateText()
        {
            DetailedInfo.Clear();
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_Type));
            DetailedInfo.Append(BlockDefinition.DisplayNameText);
            DetailedInfo.Append("\n");
            DetailedInfo.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertiesText_MaxRequiredInput));
            MyValueFormatter.AppendWorkInBestUnit(ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId), DetailedInfo);
            DetailedInfo.Append("\n");
            if (!(MySession.Static.Settings.EnableOxygen || BlockDefinition.StoredGasId != m_oxygenGasId))
            {
                DetailedInfo.Append("Oxygen disabled in world settings!");
            }
            else
            {
                DetailedInfo.Append("Filled: " + (FilledRatio * 100f).ToString("F4") + "%");
            }

            RaisePropertiesChanged();
        }
示例#13
0
        public override void Register(MyEntity entity, Vector3I forwardVector)
        {
            var thrust = entity as MyThrust;

            if (thrust == null)
            {
                return;
            }

            base.Register(entity, forwardVector);

            MyDefinitionId fuelType  = FuelType(entity);
            int            typeIndex = GetTypeIndex(ref fuelType);

            m_dataByFuelType[typeIndex].EnergyDensity = thrust.FuelDefinition.EnergyDensity;
            m_dataByFuelType[typeIndex].Efficiency    = thrust.BlockDefinition.FuelConverter.Efficiency;

            ResourceSink.SetMaxRequiredInputByType(fuelType, ResourceSink.MaxRequiredInputByType(fuelType) + PowerAmountToFuel(ref fuelType, thrust.MaxPowerConsumption));

            thrust.EnabledChanged += thrust_EnabledChanged;
            thrust.SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            SlowdownFactor = Math.Max(thrust.BlockDefinition.SlowdownFactor, SlowdownFactor);
        }
示例#14
0
        public void UpdateOnServer()
        {
            if (!Sync.IsServer)
            {
                return;
            }

            MyEntity newParent = m_owner.Parent;

            if (m_lastParent != newParent)         // Need to rethink batteries
            {
                ResourceSink.Update();

                m_lastParent = newParent;
            }

            if (ResourceSource.HasCapacityRemainingByType(MyResourceDistributorComponent.ElectricityId) || ResourceSink.RequiredInputByType(MyResourceDistributorComponent.ElectricityId) > 0.0f)
            {
                float secondsSinceLastUpdate = (MySession.Static.GameplayFrameCounter - m_lastUpdateTime) * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS;
                m_lastUpdateTime = MySession.Static.GameplayFrameCounter;
                var   productionToCapacity = ResourceSource.ProductionToCapacityMultiplierByType(MyResourceDistributorComponent.ElectricityId);
                float consumptionPerSecond = ResourceSource.CurrentOutputByType(MyResourceDistributorComponent.ElectricityId) / productionToCapacity;
                float rechargePerSecond    = (MyFakes.ENABLE_BATTERY_SELF_RECHARGE ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : ResourceSink.CurrentInputByType(MyResourceDistributorComponent.ElectricityId) / productionToCapacity);
                float consumedEnergy       = (MySession.Static.CreativeMode) ? 0 : secondsSinceLastUpdate * consumptionPerSecond;
                float rechargedEnergy      = secondsSinceLastUpdate * rechargePerSecond;
                float energyTransfer       = rechargedEnergy - consumedEnergy;
                float newCapacity          = ResourceSource.RemainingCapacityByType(MyResourceDistributorComponent.ElectricityId) + energyTransfer;
                ResourceSource.SetRemainingCapacityByType(MyResourceDistributorComponent.ElectricityId, MathHelper.Clamp(newCapacity, 0f, MyEnergyConstants.BATTERY_MAX_CAPACITY));
            }

            if (!ResourceSource.HasCapacityRemainingByType(MyResourceDistributorComponent.ElectricityId))
            {
                ResourceSink.Update();
            }

            SyncObject.SendCapacitySync(Owner, ResourceSource.RemainingCapacityByType(MyResourceDistributorComponent.ElectricityId));
        }
示例#15
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            m_definition = BlockDefinition as MyOreDetectorDefinition;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                m_definition.ResourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_ORE_DETECTOR,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
            ResourceSink = sinkComp;

            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;

            base.Init(objectBuilder, cubeGrid);


            var ob = objectBuilder as MyObjectBuilder_OreDetector;

            m_oreDetectorComponent.DetectionRadius = ob.DetectionRadius;
            if (m_oreDetectorComponent.DetectionRadius == 0)
            {
                m_oreDetectorComponent.DetectionRadius = m_definition.MaximumRange;
            }

            m_oreDetectorComponent.BroadcastUsingAntennas = ob.BroadcastUsingAntennas;
            m_broadcastUsingAntennas.Value = m_oreDetectorComponent.BroadcastUsingAntennas;

            m_oreDetectorComponent.OnCheckControl += OnCheckControl;
            ResourceSink.Update();
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));
        }
示例#16
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);

            MyObjectBuilder_TextPanel ob = (MyObjectBuilder_TextPanel)objectBuilder;

            PrivateTitle.Append(ob.Title);
            PrivateDescription.Append(ob.Description);
            PublicDescription.Append(ob.PublicDescription);
            PublicTitle.Append(ob.PublicTitle);

            m_currentPos = ob.CurrentShownTexture;

            if (Sync.IsServer && Sync.Clients != null)
            {
                Sync.Clients.ClientRemoved += TextPanel_ClientRemoved;
            }

            FontColor                  = ob.FontColor;
            BackgroundColor            = ob.BackgroundColor;
            NeedsUpdate               |= MyEntityUpdateEnum.EACH_FRAME;
            Render.NeedsDrawFromParent = true;
            ChangeInterval             = ob.ChangeInterval;
            if (!ob.Font.IsNull())
            {
                Font = ob.Font;
            }
            FontSize     = ob.FontSize;
            ShowTextFlag = ob.ShowText;
            if (ob.SelectedImages != null)
            {
                foreach (var savedTextureName in ob.SelectedImages)
                {
                    foreach (var textureDefinition in m_definitions)
                    {
                        if (textureDefinition.Id.SubtypeName == savedTextureName)
                        {
                            m_selectedTexturesToDraw.Add(textureDefinition);
                            break;
                        }
                    }
                }
                m_currentPos = Math.Min(m_currentPos, m_selectedTexturesToDraw.Count);
                RaisePropertiesChanged();
            }


            ResourceSink.Update();
            ResourceSink.IsPoweredChanged += PowerReceiver_IsPoweredChanged;
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
        }
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);
            this.IsLargeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;

            var     builder    = (MyObjectBuilder_LightingBlock)objectBuilder;
            MyModel lightModel = VRage.Game.Models.MyModels.GetModelOnlyDummies(BlockDefinition.Model);

            foreach (var pair in lightModel.Dummies)
            {
                if (!pair.Key.ToLower().Contains("light"))
                {
                    continue;
                }

                m_lightLocalPosition = pair.Value.Matrix.Translation;
                break;
            }

            Vector4 color = (builder.ColorAlpha == -1)
                ? LightColorDef
                : new Vector4(builder.ColorRed, builder.ColorGreen, builder.ColorBlue, builder.ColorAlpha);

            float radius          = RadiusBounds.Clamp((builder.Radius == -1f) ? RadiusBounds.Default : builder.Radius);
            float reflectorRadius = ReflectorRadiusBounds.Clamp((builder.ReflectorRadius == -1f) ? ReflectorRadiusBounds.Default : builder.ReflectorRadius);
            float falloff         = FalloffBounds.Clamp(builder.Falloff);

            m_blinkIntervalSeconds.Value = BlinkIntervalSecondsBounds.Clamp((builder.BlinkIntervalSeconds == -1f) ? BlinkIntervalSecondsBounds.Default : builder.BlinkIntervalSeconds);

            m_blinkLength.Value = BlinkLenghtBounds.Clamp((builder.BlinkLenght == -1f) ? BlinkLenghtBounds.Default : builder.BlinkLenght);

            m_blinkOffset.Value = BlinkOffsetBounds.Clamp((builder.BlinkOffset == -1f) ? BlinkOffsetBounds.Default : builder.BlinkOffset);

            m_intesity.Value = IntensityBounds.Clamp((builder.Intensity == -1f) ? IntensityBounds.Default : builder.Intensity);


            m_positionDirty = true;
            m_light         = MyLights.AddLight();
            InitLight(m_light, color, radius, falloff);

            m_light.ReflectorRange = reflectorRadius;
            m_light.Range          = radius;
            m_light.ReflectorOn    = false;
            m_light.LightOn        = false;
            m_light.GlareOn        = false;

            UpdateRadius(m_light.IsTypeSpot ? reflectorRadius : radius);
            UpdateIntensity();
            UpdateLightPosition();

            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
            Render.NeedsDrawFromParent = true;


            AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));
            ResourceSink.Update();
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            IsWorkingChanged += CubeBlock_OnWorkingChanged;
        }
 private float ComputeRequiredPower()
 {
     return((IsFunctional && (Enabled || WantsToActivate)) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0f);
 }
        //[TerminalValues(MySpaceTexts.SwitchText_On, MySpaceTexts.SwitchText_Off)]
        //[Terminal(2, MyPropertyDisplayEnum.Switch, MySpaceTexts.Terminal_UseConveyorSystem, MySpaceTexts.Blank)]
        //[Obfuscation(Feature = Obfuscator.NoRename, Exclude = true)]
        //public MyStringId UseConveyorSystemGui
        //{
        //    get { return m_useConveyorSystem ? MySpaceTexts.SwitchText_On : MySpaceTexts.SwitchText_Off; }
        //    set
        //    {
        //        if (m_useConveyorSystem != (value == MySpaceTexts.SwitchText_On))
        //        {
        //            m_useConveyorSystem = (value == MySpaceTexts.SwitchText_On);
        //            OnPropertiesChanged();
        //        }
        //    }
        //}
        //[TerminalValueSetter(2)]
        //public void RequestUseConveyorSystemChange(MyStringId newVal)
        //{
        //    MySyncConveyors.SendChangeUseConveyorSystemRequest(EntityId, newVal == MySpaceTexts.SwitchText_On);
        //}

        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            var ob = builder as MyObjectBuilder_SmallMissileLauncher;


            MyStringHash resourceSinkGroup;
            var          weaponBlockDefinition = BlockDefinition as MyWeaponBlockDefinition;

            if (weaponBlockDefinition != null && this.GetInventory() == null)
            {
                MyInventory inventory = new MyInventory(weaponBlockDefinition.InventoryMaxVolume, new Vector3(1.2f, 0.98f, 0.98f), MyInventoryFlags.CanReceive);
                Components.Add <MyInventoryBase>(inventory);
                resourceSinkGroup = weaponBlockDefinition.ResourceSinkGroup;
            }
            else
            {
                if (this.GetInventory() == null) // this could be already inicialized object builder
                {
                    MyInventory inventory = null;
                    if (cubeGrid.GridSizeEnum == MyCubeSize.Small)
                    {
                        inventory = new MyInventory(240.0f / 1000, new Vector3(1.2f, 0.45f, 0.45f), MyInventoryFlags.CanReceive); // 4 missiles
                    }
                    else
                    {
                        inventory = new MyInventory(1140.0f / 1000, new Vector3(1.2f, 0.98f, 0.98f), MyInventoryFlags.CanReceive); // 19 missiles
                    }
                    Components.Add(inventory);
                }

                resourceSinkGroup = MyStringHash.GetOrCompute("Defense");
            }
            Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!");

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                resourceSinkGroup,
                MyEnergyConstants.MAX_REQUIRED_POWER_SHIP_GUN,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId) : 0.0f);
            ResourceSink = sinkComp;
            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;

            base.Init(builder, cubeGrid);

            if (MyFakes.ENABLE_INVENTORY_FIX)
            {
                FixSingleInventory();
            }
            ResourceSink.Update();
            this.GetInventory().Init(ob.Inventory);
            m_gunBase.Init(ob.GunBase, BlockDefinition, this);
            m_shotsLeftInBurst = m_gunBase.ShotsInBurst;

            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            m_useConveyorSystem.Value = ob.UseConveyorSystem;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            LoadDummies();

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
        }