void Start() { // create subsystems cache = new Cache(); resource_cache = new ResourceCache(); background = new Background(); signal = new Signal(); storm = new Storm(); launcher = new Launcher(); info = new Info(); body_info = new BodyInfo(); message = new Message(); console = new Console(); editor = new Editor(); Radiation.init(); LineRenderer.init(); ParticleRenderer.init(); // prepare storm data foreach(CelestialBody body in FlightGlobals.Bodies) { if (Storm.skip_body(body)) continue; storm_data sd = new storm_data(); sd.body = body; storm_bodies.Add(sd); } }
public override void OnLoad(ConfigNode node) { // deserialize data DB.load(node); // initialize everything just once if (!initialized) { // add supply resources to pods Profile.SetupPods(); // initialize subsystems Cache.init(); ResourceCache.init(); Radiation.init(); Science.init(); LineRenderer.init(); ParticleRenderer.init(); Highlighter.init(); UI.init(); // prepare storm data foreach (CelestialBody body in FlightGlobals.Bodies) { if (Storm.skip_body(body)) { continue; } storm_data sd = new storm_data(); sd.body = body; storm_bodies.Add(sd); } // various tweaks to the part icons in the editor Misc.TweakPartIcons(); // setup callbacks callbacks = new Callbacks(); // everything was initialized initialized = true; } // detect if this is a different savegame if (DB.uid != savegame_uid) { // clear caches Cache.clear(); ResourceCache.clear(); // sync main window pos from db UI.sync(); // remember savegame id savegame_uid = DB.uid; } // force CommNet off when signal is enabled HighLogic.fetch.currentGame.Parameters.Difficulty.EnableCommNet &= !Features.Signal; }
public override void OnLoad(ConfigNode node) { // deserialize data DB.Load(node); // initialize everything just once if (!initialized) { // add supply resources to pods Profile.SetupPods(); // initialize subsystems Cache.Init(); ResourceCache.Init(); Radiation.Init(); Science.Init(); LineRenderer.Init(); ParticleRenderer.Init(); Highlighter.Init(); UI.Init(); // prepare storm data foreach (CelestialBody body in FlightGlobals.Bodies) { if (Storm.Skip_body(body)) { continue; } Storm_data sd = new Storm_data { body = body }; storm_bodies.Add(sd); } // various tweaks to the part icons in the editor Misc.TweakPartIcons(); // setup callbacks callbacks = new Callbacks(); // everything was initialized initialized = true; } // detect if this is a different savegame if (DB.uid != savegame_uid) { // clear caches Cache.Clear(); ResourceCache.Clear(); // sync main window pos from db UI.Sync(); // remember savegame id savegame_uid = DB.uid; } }
void OnPostRender() { // do nothing when not in map view // - avoid weird situation when in some user installation MapIsEnabled is true in the space center if (!MapView.MapIsEnabled || HighLogic.LoadedScene == GameScenes.SPACECENTER) { return; } // commit all geometry Radiation.Render(); // render all committed geometry LineRenderer.Render(); ParticleRenderer.Render(); }
void OnPostRender() { // do nothing if DB isn't ready for whatever reason if (!DB.Ready()) return; // do nothing when not in map view if (!MapView.MapIsEnabled) return; // commit all geometry Signal.render(); Radiation.render(); // render all committed geometry LineRenderer.render(); ParticleRenderer.render(); }
public override void OnLoad(ConfigNode node) { // everything in there will be called only one time : the first time a game is loaded from the main menu if (!IsCoreGameInitDone) { // core game systems Sim.Init(); // find suns (Kopernicus support) Radiation.Init(); // create the radiation fields ScienceDB.Init(); // build the science database (needs Sim.Init() and Radiation.Init() first) Science.Init(); // register the science hijacker // static graphic components LineRenderer.Init(); ParticleRenderer.Init(); Highlighter.Init(); // UI Textures.Init(); // set up the icon textures UI.Init(); // message system, main gui, launcher KsmGui.KsmGuiMasterController.Init(); // setup the new gui framework // part prefabs hacks Profile.SetupPods(); // add supply resources to pods Misc.TweakPartIcons(); // various tweaks to the part icons in the editor // Create KsmGui windows new ScienceArchiveWindow(); // GameEvents callbacks Callbacks = new Callbacks(); IsCoreGameInitDone = true; } // everything in there will be called every time a savegame (or a new game) is loaded from the main menu if (!IsSaveGameInitDone) { Cache.Init(); ResourceCache.Init(); // prepare storm data foreach (CelestialBody body in FlightGlobals.Bodies) { if (Storm.Skip_body(body)) { continue; } Storm_data sd = new Storm_data { body = body }; storm_bodies.Add(sd); } IsSaveGameInitDone = true; } // eveything else will be called on every OnLoad() call : // - save/load // - every scene change // - in various semi-random situations (thanks KSP) // Fix for background IMGUI textures being dropped on scene changes since KSP 1.8 Styles.ReloadBackgroundStyles(); // always clear the caches Cache.Clear(); ResourceCache.Clear(); // deserialize our database UnityEngine.Profiling.Profiler.BeginSample("Kerbalism.DB.Load"); DB.Load(node); UnityEngine.Profiling.Profiler.EndSample(); // I'm smelling the hacky mess in here. Communications.NetworkInitialized = false; Communications.NetworkInitializing = false; // detect if this is a different savegame if (DB.uid != savegame_uid) { // clear caches Message.all_logs.Clear(); // sync main window pos from db UI.Sync(); // remember savegame id savegame_uid = DB.uid; } Kerbalism.gameLoadTime = Time.time; }
public static void render() { // do nothing if signal mechanic is disabled if (!Features.Signal) { return; } // get home body position Vector3 home = ScaledSpace.LocalToScaledSpace(FlightGlobals.GetHomeBody().position); // for each vessel foreach (Vessel v in FlightGlobals.Vessels) { // get info from the cache vessel_info vi = Cache.VesselInfo(v); // skip invalid vessels if (!vi.is_valid) { continue; } // get data from db VesselData vd = DB.Vessel(v); // skip vessels with showlink disabled if (!vd.cfg_showlink) { continue; } // get connection info ConnectionInfo conn = vi.connection; // skip unlinked vessels // - we don't show the red line anymore if (!conn.linked) { continue; } // start of the line Vector3 a = ScaledSpace.LocalToScaledSpace(v.GetWorldPos3D()); // determine end of line and color Vector3 b; Color color; if (conn.status == LinkStatus.direct_link) { b = home; color = Color.green; } else //< indirect link { // get link path var path = conn.path; // use relay position b = ScaledSpace.LocalToScaledSpace(path[path.Count - 1].GetWorldPos3D()); color = Color.yellow; } // commit the line LineRenderer.commit(a, b, color); // if transmitting or relaying science data if (vi.transmitting.Length > 0 || vi.relaying.Length > 0) { // deduce number of particles and distance between them Vector3 dir = b - a; float len = dir.magnitude; int particle_count = Lib.Clamp((int)(len / 80.0f), 1, 256); dir /= (float)particle_count; // used for 'moving' effect float k = Time.realtimeSinceStartup / 3.0f; k -= Mathf.Floor(k); // particle color // - fade to avoid overlapping Color clr = Color.cyan; clr.a = Mathf.Min(Lib.Clamp(1.0f - 0.01f * PlanetariumCamera.fetch.Distance / dir.magnitude, 0.0f, 1.0f) * 2.0f, 1.0f); // for each particle for (int i = 0; i < particle_count; ++i) { // commit particle ParticleRenderer.commit(a + dir * ((float)i + k), 8.0f, clr); } } } }