Example #1
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);
        }
Example #2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            m_cameraDummy    = Matrix.Identity;
            m_characterDummy = Matrix.Identity;

            base.Init(objectBuilder, cubeGrid);

            if (ResourceSink == null)
            {
                // we've already created ResourceSink in ancestor!
                var sinkComp = new MyResourceSinkComponent();
                sinkComp.Init(
                    MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup),
                    BlockDefinition.IdlePowerConsumption,
                    this.CalculateRequiredPowerInput);
                sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
                ResourceSink = sinkComp;
            }
            else
            {
                // override electricity settings
                ResourceSink.SetMaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId, BlockDefinition.IdlePowerConsumption);
                ResourceSink.SetRequiredInputFuncByType(MyResourceDistributorComponent.ElectricityId, this.CalculateRequiredPowerInput);
                ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            }

            var chamberOb = objectBuilder as MyObjectBuilder_CryoChamber;

            if (chamberOb.SteamId != null && chamberOb.SerialId != null)
            {
                m_currentPlayerId = new MyPlayer.PlayerId(chamberOb.SteamId.Value, chamberOb.SerialId.Value);
            }
            else
            {
                m_currentPlayerId = null;
            }


            var overlayTexture = BlockDefinition.OverlayTexture;

            if (!string.IsNullOrEmpty(overlayTexture))
            {
                m_overlayTextureName = overlayTexture;
            }


            HorizonIndicatorEnabled = false;

            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;
        }
Example #3
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);
        }