public SpeedHandler(CyclopsSpeedModule cyclopsSpeedModule, SubRoot cyclops) : base(cyclopsSpeedModule.TechType, cyclops)
        {
            speedModule   = cyclopsSpeedModule;
            this.MaxCount = MaxSpeedBoosters;

            // Store the original values before we start to change them
            originalSpeeds[0] = this.MotorMode.motorModeSpeeds[0];
            originalSpeeds[1] = this.MotorMode.motorModeSpeeds[1];
            originalSpeeds[2] = this.MotorMode.motorModeSpeeds[2];

            originalNoise[0] = this.MotorMode.motorModeNoiseValues[0];
            originalNoise[1] = this.MotorMode.motorModeNoiseValues[1];
            originalNoise[2] = this.MotorMode.motorModeNoiseValues[2];

            OnFirstTimeMaxCountReached = () =>
            {
                ErrorMessage.AddMessage(CyclopsSpeedModule.MaxRatingAchived);
            };

            OnFinishedUpgrades = () =>
            {
                this.EfficiencyPenalty = Mathf.Pow(EnginePowerPenalty, this.Count);

                this.RatingManager.ApplyPowerRatingModifier(TechType, this.EfficiencyPenalty);

                int speedIndex = this.Count;
                if (lastKnownSpeedIndex == speedIndex)
                {
                    return;
                }

                lastKnownSpeedIndex = speedIndex;

                float speedMultiplier = this.SpeedMultiplier = SpeedModifiers[speedIndex];
                float noiseMultiplier = this.NoisePenalty = 1f + 0.05f * speedIndex;

                // These will apply when changing speed modes
                this.MotorMode.motorModeSpeeds[0] = originalSpeeds[0] * speedMultiplier;
                this.MotorMode.motorModeSpeeds[1] = originalSpeeds[1] * speedMultiplier;
                this.MotorMode.motorModeSpeeds[2] = originalSpeeds[2] * speedMultiplier;

                this.MotorMode.motorModeNoiseValues[0] = originalNoise[0] * noiseMultiplier;
                this.MotorMode.motorModeNoiseValues[1] = originalNoise[1] * noiseMultiplier;
                this.MotorMode.motorModeNoiseValues[2] = originalNoise[2] * noiseMultiplier;

                // These will apply immediately
                CyclopsMotorMode.CyclopsMotorModes currentMode = this.MotorMode.cyclopsMotorMode;
                this.SubControl.BaseForwardAccel = this.MotorMode.motorModeSpeeds[(int)currentMode];

                ErrorMessage.AddMessage(CyclopsSpeedModule.SpeedRatingText(lastKnownSpeedIndex, speedMultiplier));
            };
        }
Ejemplo n.º 2
0
        public static void Patch()
        {
            QuickLogger.Info($"Started patching. Version {QuickLogger.GetAssemblyVersion()}");

            var speedUpgrade = new CyclopsSpeedModule();

            speedUpgrade.Patch();

            MCUServices.Register.CyclopsUpgradeHandler(speedUpgrade.CreateSpeedUpgradeHandler);
            MCUServices.Register.PdaIconOverlay(speedUpgrade.TechType, speedUpgrade.CreateSpeedIconOverlay);

            QuickLogger.Info($"Finished patching.");
        }
        public static void Patch()
        {
            QuickLogger.Info($"Started patching. Version {QuickLogger.GetAssemblyVersion()}");

            var speedUpgrade = new CyclopsSpeedModule();

            speedUpgrade.Patch();

            MCUServices.Register.CyclopsUpgradeHandler(speedUpgrade.CreateSpeedUpgradeHandler);
            MCUServices.Register.PdaIconOverlay(speedUpgrade.TechType, speedUpgrade.CreateSpeedIconOverlay);

            var harmony = HarmonyInstance.Create("com.cyclopsspeedupgrades.psmod");

            harmony.PatchAll(Assembly.GetExecutingAssembly());

            QuickLogger.Info($"Finished patching.");
        }
Ejemplo n.º 4
0
 public SpeedOverlay(uGUI_ItemIcon icon, InventoryItem upgradeModule, CyclopsSpeedModule speedBooster) : base(icon, upgradeModule)
 {
     speedHandler = MCUServices.Find.CyclopsUpgradeHandler <SpeedHandler>(base.Cyclops, speedBooster.TechType);
 }