Git Product home page Git Product logo

alarmenhancements's People

Contributors

severedsolo avatar

Watchers

 avatar  avatar

Forkers

marr75

alarmenhancements's Issues

Escape node gone, alarms stays

Mun encounter with flyby and escape, also Kerbin escape.
Two alarms are created, for each escape.
As soon as the Mun orbit is secure, the Mun escape alarm is automatically deleted, but the Kerbin escape alarm persists.

Unused references

AFAICT, you've got over 50 unused references. The dependencies needed are (fairly typical for a KSP mod):

  • Assembly-CSharp
  • System
  • System.Core
  • UnityEngine
  • UnityEngine.CoreModule

You can save time on the build, storage space, and simplify setup for any other developer contributing by eliminating the unused ones.

Switch to using Harmony to augment game code

Harmony is a library that lets the user pre-fix, post-fix, and transpile .net methods. A few prominent KSP mods use it, including KSP Community Fixes, Kerbalism, and Luna Multiplayer.

With Harmony, you can override the "GetDefaultTItle" method of the alarm classes and get the behavior many users have asked for (allowing them to change the alarm names) plus better performance (don't have to respond to added alarms, which includes edited alarms), plus because you're overriding the default title, the user can actually use your improved default title to make whatever edits they want from the template. For example, I might want to edit my maneuver alarm from "My Vessel Maneuver" to "My Vessel Circularization".

The code is very simple to do this, I might turn this into a PR to contribute, by proof of concept:

using HarmonyLib;
using UnityEngine;

namespace AlarmEnhancements
{
    [KSPAddon(KSPAddon.Startup.Instantly, true)]
    public class AlarmEnhancements : MonoBehaviour
    {
        private void Start() {
            var harmony = new Harmony("com.marr75.alarmEnhancements");
            harmony.PatchAll();
        }
    }

    [HarmonyPatch(typeof(AlarmTypeManeuver))]
    class ManeuverAlarmPatch {
        
        [HarmonyPrefix]
        static bool GetDefaultTitle(AlarmTypeManeuver __instance, ref string __result) {
            __result = $"{__instance.vesselName} Maneuver"; // Overwrite the old result
            return false;  // don't bother running the old method, it was a simple localization call of the word, "Maneuver", anyway
        }
    }
}

You'll also catch the alarms created from the map view shortcut with this approach, obviously.

game lag when auto add atmosphere alarm

when auto add atmosphere alarm enabled, game lag for every few seconds.

double latestTime = FlightGlobals.ActiveVessel.orbit.timeToPe + Planetarium.GetUniversalTime();
double alarmTime = Planetarium.GetUniversalTime();
for (alarmTime = Planetarium.GetUniversalTime(); alarmTime < latestTime; alarmTime++)
{
if (FlightGlobals.ActiveVessel.orbit.GetRadiusAtUT(alarmTime)-FlightGlobals.ActiveVessel.mainBody.Radius < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth) break;
}

using bisection method can improve performance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.