示例#1
0
        // main block of code- runs every physics frame
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                // we wait ~60 frames before starting to add heat, to stop overheating bugs
                if (initFrames < 60)
                {
                    initFrames += 1;
                }
                else
                {
                    AddHeatToCore();
                }
                SyncAnimationState();

                // fail-safe mechanism (ie if amplify setting is set too high and craft runs out of power, amplifier will be shutdown)
                this.vessel.GetConnectedResourceTotals(EChash, out double amount, out double maxAmount);
                if (amount / maxAmount < 0.2d)
                {
                    IsEnabled = false;
                }

                receiver.Directional(this.part, transmitterCounter, IsEnabled, 100f, ReflectorDiameter, Reflectivity, false, false,
                                     State, out State, out TransmitterName, out double recvPower, out transmitterCounter);
                try
                {
                    Wavelength = receiver.wavelengthList[transmitterCounter];
                }
                catch
                {
                    Wavelength = "Long";
                }

                Excess = (float)Math.Round(recvPower, 1);
                this.part.AddSkinThermalFlux((Excess / Reflectivity) * (1 - Reflectivity) * (heatModifier / 100));

                if (CanAmplify == "True" && wavelength == Wavelength)
                {
                    bool background = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().BackgroundProcessing;
                    resourceConsumption = (float)(recvPower * (AmplifyMult - 1));
                    if (background == false)
                    {
                        this.part.RequestResource(EChash, (double)resourceConsumption * Time.fixedDeltaTime);
                    }
                    Excess += Mathf.Clamp((resourceConsumption * Efficiency), 0f, 50000f);
                }
                else
                {
                    AmplifyMult = 1f;
                }
                PowerReflected = (float)Math.Round(Excess, 1);

                Constant = (float)((Wavelength == "Long") ? 1.44 * Math.Pow(10, -3) / ReflectorDiameter :
                                   1.44 * 5 * Math.Pow(10, -8) / ReflectorDiameter);
                vesselFinder.ReceiverData(out receiverConfigList);
                TransmittingTo = receiverConfigList[receiverCounter].GetValue("name");
            }
        }
示例#2
0
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (initFrames < 60)
                {
                    initFrames += 1;
                }
                else
                {
                    AddHeatToCore();
                }
                SyncAnimationState();

                double recvPower;
                if (recvType == "Directional")
                {
                    receiver.Directional(this.part, counter, Listening, PowerLimiter, recvDiameter, recvEfficiency,
                                         false, false, State, out State, out ReceivingFrom, out recvPower, out counter);
                }
                else if (recvType == "Spherical")
                {
                    receiver.Spherical(this.part, Listening, PowerLimiter, recvDiameter, recvEfficiency, false,
                                       false, State, out State, out recvPower);
                }
                else
                {
                    counter = 0; recvPower = 0d;
                    Debug.LogWarning("BeamedPowerStandalone.WirelessReceiver : Invalid recvType set in part.cfg of " + this.part.partName);
                }

                ReceivedPower = (float)Math.Round(recvPower, 1);

                if (HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().BackgroundProcessing == false)
                {
                    this.part.RequestResource(EChash, -(double)ReceivedPower * TimeWarp.fixedDeltaTime);
                }
            }
        }
示例#3
0
        // main block of code- runs every physics frame
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (IsEnabled)
                {
                    // we wait ~60 frames before starting to add heat, to stop overheating bugs
                    if (initFrames < 60)
                    {
                        initFrames += 1;
                    }
                    else
                    {
                        AddHeatToCore();
                    }
                    SyncAnimationState();

                    // fail-safe mechanism (ie if amplify setting is set too high and craft runs out of power, amplifier will be shutdown)
                    this.vessel.GetConnectedResourceTotals(EChash, out double amount, out double maxAmount);
                    if (amount / maxAmount < 0.2d)
                    {
                        IsEnabled = false;
                    }

                    receiver.Directional(this.part, transmitterCounter, IsEnabled, 100f, ReflectorDiameter, Reflectivity, false, false,
                                         State, out State, out TransmitterName, out double recvPower, out transmitterCounter);
                    //try
                    //{
                    if (receiver.wavelengthList.Count > 0)
                    {
                        Wavelength = receiver.wavelengthList[transmitterCounter];
                    }
                    //}
                    //catch
                    //{
                    //Wavelength = "Ultraviolet";
                    //Debug.LogWarning("BeamedPowerStandalone.WirelessReflector : Wavelength set to default.");
                    //}

                    Excess = (float)Math.Round(recvPower, 1);
                    this.part.AddSkinThermalFlux((Excess / Reflectivity) * (1 - Reflectivity) * (heatModifier / 100));

                    if (CanAmplify == "True" && wavelength == Wavelength)
                    {
                        bool background = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().BackgroundProcessing;
                        resourceConsumption = (float)(recvPower * (AmplifyMult - 1));
                        if (background == false)
                        {
                            this.part.RequestResource(EChash, (double)resourceConsumption * Time.fixedDeltaTime);
                        }
                        Excess += Mathf.Clamp((resourceConsumption * Efficiency), 0f, 50000f);
                    }
                    else
                    {
                        AmplifyMult = 1f;
                    }
                    PowerReflected = (float)Math.Round(Excess, 1);

                    double wavelengthnum = wave.WavelengthNum(this.part, wavelength);
                    Constant = (float)(1.44 * wavelengthnum / ReflectorDiameter);

                    frames += 1;
                    List <ConfigNode> receiverConfigList = new List <ConfigNode>();
                    if (frames == 40)
                    {
                        try
                        {
                            vesselFinder.ReceiverData(this.vessel.GetDisplayName(), out receiverConfigList);
                        }
                        catch
                        {
                            Debug.LogError("BeamedPowerStandalone.WirelessReflector : Unable to load receiver vessel list.");
                        }
                        frames = 0;
                    }
                    if (receiverCounter >= receiverConfigList.Count)
                    {
                        receiverCounter = 0;
                    }
                    if (receiverConfigList.Count > 0)
                    {
                        TransmittingTo = receiverConfigList[receiverCounter].GetValue("name");
                    }
                    else
                    {
                        TransmittingTo = Localizer.Format("#LOC_BeamedPower_Vessel_None");
                    }
                }
                else
                {
                    Excess          = 0f;
                    Constant        = 0f;
                    Wavelength      = "Ultraviolet";
                    TransmittingTo  = Localizer.Format("#LOC_BeamedPower_Vessel_None");
                    TransmitterName = Localizer.Format("#LOC_BeamedPower_Vessel_None");
                    State           = Localizer.Format("#LOC_BeamedPower_Status_Offline");
                }
            }
        }