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);
        }
Ejemplo n.º 2
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);
     }
 }