public virtual void Init(MyObjectBuilder_Character characterBuilder)
        {
            if (characterBuilder == null)
            {
                return;
            }

            m_inertiaDampenersNotification = new MyHudNotification();
            m_jetpackToggleNotification    = new MyHudNotification();

            CurrentAutoEnableDelay = characterBuilder.AutoenableJetpackDelay;

            if (ThrustComp != null)
            {
                Character.Components.Remove <MyJetpackThrustComponent>();
            }

            var thrustProperties = Character.Definition.Jetpack.ThrustProperties;

            FuelConverterDefinition = null;;
            FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo {
                Efficiency = 1.0f
            } : Character.Definition.Jetpack.ThrustProperties.FuelConverter;

            MyDefinitionId fuelId = new MyDefinitionId();

            if (!FuelConverterDefinition.FuelId.IsNull())
            {
                fuelId = thrustProperties.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,
            };

            ForceMagnitude              = thrustProperties.ForceMagnitude;
            MinPowerConsumption         = thrustProperties.MinPowerConsumption;
            MaxPowerConsumption         = thrustProperties.MaxPowerConsumption;
            MinPlanetaryInfluence       = thrustProperties.MinPlanetaryInfluence;
            MaxPlanetaryInfluence       = thrustProperties.MaxPlanetaryInfluence;
            EffectivenessAtMinInfluence = thrustProperties.EffectivenessAtMinInfluence;
            EffectivenessAtMaxInfluence = thrustProperties.EffectivenessAtMaxInfluence;
            NeedsAtmosphereForInfluence = thrustProperties.NeedsAtmosphereForInfluence;
            ConsumptionFactorPerG       = thrustProperties.ConsumptionFactorPerG;

            MyEntityThrustComponent thrustComp = new MyJetpackThrustComponent();

            thrustComp.Init();
            Character.Components.Add(thrustComp);


            ThrustComp.DampenersEnabled = characterBuilder.DampenersEnabled;

            foreach (Vector3I direction in Base6Directions.IntDirections)
            {
                ThrustComp.Register(Character, direction);                      // Preferably there should be a jetpack entity (equipment) that could hold the thrusts instead of the character
            }
            thrustComp.ResourceSink(Character).TemporaryConnectedEntity = Character;
            Character.SuitRechargeDistributor.AddSink(thrustComp.ResourceSink(Character));
            TurnOnJetpack(characterBuilder.JetpackEnabled, true, true, true);
        }
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;
        }
Esempio n. 3
0
 public virtual void Init(MyObjectBuilder_Character characterBuilder)
 {
     if (characterBuilder != null)
     {
         MyFuelConverterInfo fuelConverter;
         this.CurrentAutoEnableDelay = characterBuilder.AutoenableJetpackDelay;
         if (this.ThrustComp != null)
         {
             base.Character.Components.Remove <MyJetpackThrustComponent>();
         }
         MyObjectBuilder_ThrustDefinition thrustProperties = base.Character.Definition.Jetpack.ThrustProperties;
         this.FuelConverterDefinition = null;
         if (MyFakes.ENABLE_HYDROGEN_FUEL)
         {
             fuelConverter = base.Character.Definition.Jetpack.ThrustProperties.FuelConverter;
         }
         else
         {
             MyFuelConverterInfo info1 = new MyFuelConverterInfo();
             info1.Efficiency = 1f;
             fuelConverter    = info1;
         }
         this.FuelConverterDefinition = fuelConverter;
         MyDefinitionId defId = new MyDefinitionId();
         if (!this.FuelConverterDefinition.FuelId.IsNull())
         {
             defId = thrustProperties.FuelConverter.FuelId;
         }
         MyGasProperties definition = null;
         if (MyFakes.ENABLE_HYDROGEN_FUEL)
         {
             MyDefinitionManager.Static.TryGetDefinition <MyGasProperties>(defId, out definition);
         }
         MyGasProperties properties2 = definition;
         if (definition == null)
         {
             MyGasProperties local1      = definition;
             MyGasProperties properties1 = new MyGasProperties();
             properties1.Id            = MyResourceDistributorComponent.ElectricityId;
             properties1.EnergyDensity = 1f;
             properties2 = properties1;
         }
         this.FuelDefinition              = properties2;
         this.ForceMagnitude              = thrustProperties.ForceMagnitude;
         this.MinPowerConsumption         = thrustProperties.MinPowerConsumption;
         this.MaxPowerConsumption         = thrustProperties.MaxPowerConsumption;
         this.MinPlanetaryInfluence       = thrustProperties.MinPlanetaryInfluence;
         this.MaxPlanetaryInfluence       = thrustProperties.MaxPlanetaryInfluence;
         this.EffectivenessAtMinInfluence = thrustProperties.EffectivenessAtMinInfluence;
         this.EffectivenessAtMaxInfluence = thrustProperties.EffectivenessAtMaxInfluence;
         this.NeedsAtmosphereForInfluence = thrustProperties.NeedsAtmosphereForInfluence;
         this.ConsumptionFactorPerG       = thrustProperties.ConsumptionFactorPerG;
         MyEntityThrustComponent component = new MyJetpackThrustComponent();
         component.Init();
         base.Character.Components.Add <MyEntityThrustComponent>(component);
         this.ThrustComp.DampenersEnabled = characterBuilder.DampenersEnabled;
         foreach (Vector3I vectori in Base6Directions.IntDirections)
         {
             this.ThrustComp.Register(base.Character, vectori, null);
         }
         component.ResourceSink(base.Character).TemporaryConnectedEntity = base.Character;
         base.Character.SuitRechargeDistributor.AddSink(component.ResourceSink(base.Character));
         this.TurnOnJetpack(characterBuilder.JetpackEnabled, true, true);
     }
 }