Esempio n. 1
0
        public override void OnRegisteredToGridSystems()
        {
            base.OnRegisteredToGridSystems();

            MyEntityThrustComponent entityThrustComponent;

            if (!CubeGrid.Components.TryGet(out entityThrustComponent))
            {
                entityThrustComponent = new MyThrusterBlockThrustComponent();

                entityThrustComponent.Init();
                CubeGrid.Components.Add <MyEntityThrustComponent>(entityThrustComponent);
            }
            m_thrustComponent = entityThrustComponent;
            m_thrustComponent.Register(this, ThrustForwardVector, OnRegisteredToThrustComponent);
        }
Esempio n. 2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            MyEntityThrustComponent entityThrustComponent;

            if (!cubeGrid.Components.TryGet(out entityThrustComponent))
            {
                entityThrustComponent = new MyThrusterBlockThrustComponent();

                entityThrustComponent.Init();
                cubeGrid.Components.Add <MyEntityThrustComponent>(entityThrustComponent);
            }

            m_thrustComponent = entityThrustComponent;

            BlockDefinition = (MyThrustDefinition)base.BlockDefinition;

            MyDefinitionId fuelId = new MyDefinitionId();

            if (!BlockDefinition.FuelConverter.FuelId.IsNull())
            {
                fuelId = BlockDefinition.FuelConverter.FuelId;
            }

            MyGasProperties fuelDef = null;

            if (MyFakes.ENABLE_HYDROGEN_FUEL)
            {
                MyDefinitionManager.Static.TryGetDefinition(fuelId, out fuelDef);
            }

            FuelDefinition = fuelDef ?? new MyGasProperties // Use electricity by default
            {
                Id            = MyResourceDistributorComponent.ElectricityId,
                EnergyDensity = 1f,
            };

            base.Init(objectBuilder, cubeGrid);



            var builder = (MyObjectBuilder_Thrust)objectBuilder;

            ThrustColor = BlockDefinition.FlameIdleColor;

            m_thrustOverride.Value = (builder.ThrustOverride * 100f) / BlockDefinition.ForceMagnitude;

            LoadDummies();
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_light = MyLights.AddLight();
            m_light.ReflectorDirection = WorldMatrix.Forward;
            m_light.ReflectorUp        = WorldMatrix.Up;
            m_light.ReflectorRange     = CubeGrid.GridScale;
            m_light.Color          = ThrustColor;
            m_light.GlareMaterial  = BlockDefinition.FlameGlareMaterial;
            m_light.GlareQuerySize = BlockDefinition.FlameGlareQuerySize * CubeGrid.GridScale;

            m_glareSize = BlockDefinition.FlameGlareSize * CubeGrid.GridScale;
            m_maxBillboardDistanceSquared = BlockDefinition.FlameVisibilityDistance * BlockDefinition.FlameVisibilityDistance;
            m_maxLightDistanceSquared     = m_maxBillboardDistanceSquared;

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1);

            UpdateDetailedInfo();

            FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo {
                Efficiency = 1.0f
            } : BlockDefinition.FuelConverter;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
        }