Example #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);
            m_thrustComponent.ResourceSink.IsPoweredChanged += Sink_IsPoweredChanged;
        }
Example #2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            BlockDefinition = (MyThrustDefinition)base.BlockDefinition;

            var builder = (MyObjectBuilder_Thrust)objectBuilder;

            ThrustColor = BlockDefinition.FlameIdleColor;

            ThrustOverride = builder.ThrustOverride;

            LoadDummies();

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

            m_glareSize = BlockDefinition.FlameGlareSize;
            m_maxBillboardDistanceSquared = BlockDefinition.FlameVisibilityDistance*BlockDefinition.FlameVisibilityDistance;
            m_maxLightDistanceSquared = m_maxBillboardDistanceSquared / 100;

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1);
            SyncObject = new MySyncThruster(this);

            UpdateDetailedInfo();

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

            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,
            };

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

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

            m_thrustComponent = entityThrustComponent;
        }