public override void Awake() { TimingManager.UpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedUpdate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedFixedUpdate); base.Awake(); }
public override void OnStart(StartState state) { MP = GetComponent <ModuleParachute>(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Early, EarlyFixedUpdate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Late, LateFixedUpdate); UI_FloatRange uI_Altitude = (UI_FloatRange)(MP.Fields)["deployAltitude"].uiControlFlight; UI_FloatRange uI_Pressure = (UI_FloatRange)(MP.Fields)["minAirPressureToOpen"].uiControlFlight; if (HighLogic.LoadedScene == GameScenes.EDITOR) { uI_Altitude = (UI_FloatRange)(MP.Fields)["deployAltitude"].uiControlEditor; uI_Pressure = (UI_FloatRange)(MP.Fields)["minAirPressureToOpen"].uiControlEditor; } uI_Altitude.minValue = altitudeSliderMin; uI_Altitude.maxValue = altitudeSliderMax; uI_Altitude.stepIncrement = altitudeSliderStep; MP.clampMinAirPressure = pressureSliderMin >= 0 ? pressureSliderMin : MP.clampMinAirPressure; uI_Pressure.minValue = pressureSliderMin >= 0 ? pressureSliderMin : MP.clampMinAirPressure; uI_Pressure.maxValue = pressureSliderMax; uI_Pressure.stepIncrement = pressureSliderStep; base.OnStart(state); }
public override void Awake() { TimingManager.UpdateAdd(TimingManager.TimingStage.Precalc, TimedUpdate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, TimedFixedUpdate); base.Awake(); }
public void Start() { TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, TimingManagerFixedUpdate); dmpDir = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins"); dmpDataDir = Path.Combine(dmpDir, "Data"); gameDataDir = Path.Combine(KSPUtil.ApplicationRootPath, "GameData"); kspRootPath = KSPUtil.ApplicationRootPath; //Fix DarkLog time/thread marker in the log during init. DarkLog.SetMainThread(); lastClockTicks = DateTime.UtcNow.Ticks; lastRealTimeSinceStartup = 0f; dmpClient = this; dmpSettings = new Settings(); toolbarSupport = new ToolbarSupport(dmpSettings); universeSyncCache = new UniverseSyncCache(dmpSettings); modWindow = new ModWindow(); modWorker = new ModWorker(modWindow); modWindow.SetDependenices(modWorker); universeConverter = new UniverseConverter(dmpSettings); universeConverterWindow = new UniverseConverterWindow(universeConverter); optionsWindow = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport); connectionWindow = new ConnectionWindow(dmpSettings, optionsWindow); disclaimerWindow = new DisclaimerWindow(dmpSettings); dmpModInterface = new DMPModInterface(); SafetyBubble.RegisterDefaultLocations(); if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled()) { modDisabled = true; } if (dmpSettings.disclaimerAccepted != 1) { modDisabled = true; disclaimerWindow.SpawnDialog(); } Profiler.DMPReferenceTime.Start(); DontDestroyOnLoad(this); // Prevents symlink warning for development. SetupDirectoriesIfNeeded(); // UniverseSyncCache needs to run expiry here universeSyncCache.ExpireCache(); GameEvents.onHideUI.Add(() => { showGUI = false; }); GameEvents.onShowUI.Add(() => { showGUI = true; }); HandleCommandLineArgs(); DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!"); }
protected override void OnStart() { base.OnStart(); //print ("HEWWO WORLD x3 " + vessel.GetName() + " " + (vessel.state == Vessel.State.ACTIVE)); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Late, FixedUpdateLateLate); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, HandleVesselUpdates); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, SendVesselPositionUpdates); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselUpdatesSendMsInterval, RoutineExecution.Update, SendSecondaryVesselPositionUpdates)); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselUpdatesSendMsInterval, RoutineExecution.Update, SendUnloadedSecondaryVesselPositionUpdates)); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, HandleVesselUpdates); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, SendVesselPositionUpdates); //It's important that SECONDARY vessels send their position in the UPDATE as their parameters will NOT be updated on the fixed update if the are packed. //https://forum.kerbalspaceprogram.com/index.php?/topic/173885-packed-vessels-position-isnt-reliable-from-fixedupdate/ SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselPositionUpdatesMsInterval, RoutineExecution.Update, SendSecondaryVesselPositionUpdates)); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselPositionUpdatesMsInterval, RoutineExecution.Update, SendUnloadedSecondaryVesselPositionUpdates)); }
protected override void OnStart() { base.OnStart(); gameBreaker = new GameObject("F****r"); print("Activation: " + base.GetActivation()); // nothing is really done here //print ("HEWWO WORLD x3 " + vessel.GetName() + " " + (vessel.state == Vessel.State.ACTIVE)); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Late, FixedUpdateLateLate); }
/// <summary> /// Hook up to any vessel/game events that might be needed. /// </summary> private void HookEvents() { ConnectivityManager.AddAutopilotHook(parentVessel, UpdateAutopilot); // HACK: The following events and their methods are a hack to work around KSP's limitation that // blocks our autopilot from having control of the vessel if out of signal and the setting // "Require Signal for Control" is enabled. It's very hacky, and my have unexpected results. if (Vessel.vesselType != VesselType.Unknown && Vessel.vesselType != VesselType.SpaceObject) { TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, cacheControllable); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, resetControllable); } }
protected override void OnStart() { print("MFI Start"); base.OnStart(); string msg = "Start. VesselModule on vessel : \n"; foreach (VesselModule vm in vessel.gameObject.GetComponents <VesselModule>()) { msg += " " + vm.GetType().Name + "\n"; } TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FashionablyLate, base.FixedUpdate); print(msg); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, CheckVesselsToRefresh); GameEvents.onVesselCreate.Add(VesselProtoEvents.VesselCreate); GameEvents.onVesselGoOnRails.Add(VesselProtoEvents.VesselGoOnRails); GameEvents.onFlightReady.Add(VesselProtoEvents.FlightReady); GameEvents.onPartDie.Add(VesselProtoEvents.OnPartDie); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, RemoveBadDebrisWhileSpectating)); SetupRoutine(new RoutineDefinition(2000, RoutineExecution.Update, CheckVesselsToLoad)); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, UpdateBannedPartsMessage)); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.VesselDefinitionSendMsInterval, RoutineExecution.Update, SendVesselDefinition)); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(HandlePositionsStage, HandleVesselUpdates); //Send the position updates after all the calculations are done. If you send it in the fixed update sometimes weird rubber banding appear (specially in space) TimingManager.LateUpdateAdd(SendPositionsStage, SendVesselPositionUpdates); //It's important that SECONDARY vessels send their position in the UPDATE as their parameters will NOT be updated on the fixed update if the are packed. //https://forum.kerbalspaceprogram.com/index.php?/topic/173885-packed-vessels-position-isnt-reliable-from-fixedupdate/ SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselUpdatesMsInterval, RoutineExecution.Update, SendSecondaryVesselPositionUpdates)); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselUpdatesMsInterval, RoutineExecution.Update, SendUnloadedSecondaryVesselPositionUpdates)); WarpEvent.onTimeWarpStopped.Add(PositionEvents.WarpStopped); }
protected override void OnStart() { print("MFI Start"); base.OnStart(); string msg = "Start. VesselModule on vessel : \n"; foreach (VesselModule vm in vessel.gameObject.GetComponents <VesselModule>()) { msg += " " + vm.GetType().Name + "\n"; } // Register our replacement FixedUpdate to run at the same timing as the stock FlightIntegrator TimingManager.UpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedUpdate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedFixedUpdate); print(msg); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, CheckVesselsToRefresh); GameEvents.onVesselCreate.Add(VesselProtoEvents.VesselCreate); GameEvents.onFlightReady.Add(VesselProtoEvents.FlightReady); GameEvents.onPartDie.Add(VesselProtoEvents.OnPartDie); GameEvents.onGameSceneLoadRequested.Add(VesselProtoEvents.OnSceneRequested); GameEvents.onVesselPartCountChanged.Add(VesselProtoEvents.VesselPartCountChangedinSpectatingVessel); GameEvents.onVesselPartCountChanged.Add(VesselProtoEvents.VesselPartCountChanged); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, RemoveBadDebrisWhileSpectating)); SetupRoutine(new RoutineDefinition(2000, RoutineExecution.Update, CheckVesselsToLoad)); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, CheckRefreshOwnVesselWhileSpectating)); SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.VesselPartsSyncMsInterval, RoutineExecution.Update, SendVesselDefinition)); }
protected override void OnEnabled() { if (!SettingsSystem.CurrentSettings.UseAlternativePositionSystem) { return; } base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, DisableVesselPrecalculate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, HandleVesselUpdates); SetupRoutine(new RoutineDefinition(FastVesselUpdatesSendMsInterval, RoutineExecution.LateUpdate, SendVesselPositionUpdates)); //SetupRoutine(new RoutineDefinition(SettingsSystem.ServerSettings.SecondaryVesselUpdatesSendMsInterval, // RoutineExecution.Update, SendSecondaryVesselPositionUpdates)); }
public override void OnStart(StartState state) { if (HighLogic.LoadedSceneIsFlight) { TimingManager.LateUpdateAdd(TimingManager.TimingStage.Early, EarlyLateUpdate); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Late, LatePostCalculateTracking); SPs = GetComponents <ModuleDeployableSolarPanel>(); if (SPs.Any(p => p.isTracking)) { Fields["trackingBodyName"].guiActive = true; Events["ManualTracking"].guiActive = true; } } base.OnStart(state); }
protected override void OnEnabled() { base.OnEnabled(); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, CheckVesselsToRefresh); GameEvents.onVesselCreate.Add(VesselProtoEvents.VesselCreate); GameEvents.onFlightReady.Add(VesselProtoEvents.FlightReady); GameEvents.onPartDie.Add(VesselProtoEvents.OnPartDie); GameEvents.onGameSceneLoadRequested.Add(VesselProtoEvents.OnSceneRequested); GameEvents.onVesselPartCountChanged.Add(VesselProtoEvents.VesselPartCountChangedinSpectatingVessel); GameEvents.onVesselPartCountChanged.Add(VesselProtoEvents.VesselPartCountChanged); GameEvents.OnTriggeredDataTransmission.Add(VesselProtoEvents.TriggeredDataTransmission); GameEvents.OnExperimentStored.Add(VesselProtoEvents.ExperimentStored); ExperimentEvent.onExperimentReset.Add(VesselProtoEvents.ExperimentReset); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, RemoveBadDebrisWhileSpectating)); SetupRoutine(new RoutineDefinition(2000, RoutineExecution.Update, CheckVesselsToLoad)); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, CheckRefreshOwnVesselWhileSpectating)); SetupRoutine(new RoutineDefinition(1000, RoutineExecution.Update, SendVesselDefinition)); }
protected override void OnEnabled() { base.OnEnabled(); //Refresh it at TimingManager.TimingStage.Precalc so it's updated JUST after KSP updates it's time TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, SetGameTime); //Uncomment to check if the TimingManager.TimingStage.Precalc is the correct time. All the operations should give "0" //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.ObscenelyEarly, ()=> LunaLog.Log($"ObscenelyEarly {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Early, () => LunaLog.Log($"Early {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, () => LunaLog.Log($"Precalc {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Earlyish, () => LunaLog.Log($"Earlyish {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Normal, () => LunaLog.Log($"Normal {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FashionablyLate, () => LunaLog.Log($"FashionablyLate {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FlightIntegrator, () => LunaLog.Log($"FlightIntegrator {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Late, () => LunaLog.Log($"Late {Planetarium.GetUniversalTime() - UniversalTime}")); //TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, () => LunaLog.Log($"BetterLateThanNever {Planetarium.GetUniversalTime() - UniversalTime}")); TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, SyncTimeScale); SpectateEvent.onStartSpectating.Add(TimerSyncerEvents.OnStartSpectating); }
public void Init(CatOrbiter parent, float soi) { TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Earlyish, DoForces); orbiters.Add(this); rb = gameObject.AddComponent <Rigidbody2D>(); rb.isKinematic = true; if (orbiters.Count == 1) { sun = this; Vector3 spos = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, -1); transform.position = KSP.UI.UIMainCamera.Camera.ScreenToWorldPoint(spos); Mass = 2E17; pos.x = transform.position.x; pos.y = transform.position.y; } else { Vector2 relativePos = Random.insideUnitCircle; if (relativePos.magnitude < 0.2) { relativePos = relativePos.normalized * 0.3f; } Vector3 spos = UIMainCamera.Camera.WorldToScreenPoint(parent.transform.position) + (Vector3)(relativePos * soi); spos.z = -1; transform.position = UIMainCamera.Camera.ScreenToWorldPoint(spos); pos.x = transform.position.x; pos.y = transform.position.y; //int scaleRange = 10; // //float factor = (1 + (scaleRange - 1) * Random.value); // //scale = parent.scale * factor / scaleRange; scale = parent.scale * 0.6f; transform.localScale *= scale; TrailRenderer trail = gameObject.GetComponent <TrailRenderer>(); trail.colorGradient = new Gradient() { alphaKeys = new GradientAlphaKey[3] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 0.7f), new GradientAlphaKey(0, 1) } }; trail.startWidth *= scale; //trail.endWidth *= scale; trail.widthCurve = new AnimationCurve(new Keyframe(0, trail.startWidth), new Keyframe(0.7f, trail.startWidth), new Keyframe(1, trail.startWidth * 0.9f)); //Mass = factor * 2E16; Mass = parent.Mass * 0.025; Vector2d dist = parent.pos - pos; double circularVel = Math.Sqrt(G * (Mass + parent.Mass) / dist.magnitude); if (parent == sun) { circularVel *= Random.Range(0.9f, 1.1f); } Debug.Log("CatOrbiter " + circularVel.ToString("F3") + " " + Mass.ToString("F2") + " " + orbiters[0].Mass.ToString("F2") + " " + dist.magnitude.ToString("F2")); Vector3d normal = (Random.value >= 0.3) ? Vector3d.back : Vector3d.forward; Vector3d vel3d = Vector3d.Cross(dist, normal).normalized *circularVel; vel.x = parent.vel.x + vel3d.x; vel.y = parent.vel.y + vel3d.y; } rb.MovePosition(new Vector2((float)pos.x, (float)pos.y)); }
public void Start() { //Set buffered UDPMesh UDPMeshLib.UdpMeshCommon.USE_BUFFERS = true; //Set pool sizes for ByteRecycler ByteRecycler.AddPoolSize(SMALL_MESSAGE_SIZE); ByteRecycler.AddPoolSize(MEDIUM_MESSAGE_SIZE); ByteRecycler.AddPoolSize(LARGE_MESSAGE_SIZE); MessageWriter.RegisterType <ByteArray>(WriteByteArrayToStream); MessageReader.RegisterType <ByteArray>(ReadByteArrayFromStream); //Prevent loads if multiple copies of DMP are installed. KSP will instantate us twice. if (dmpClient != null) { warnDuplicateInstall = true; return; } if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled()) { modDisabled = true; enabled = false; return; } TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, TimingManagerFixedUpdate); dmpDir = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins"); dmpDataDir = Path.Combine(dmpDir, "Data"); gameDataDir = Path.Combine(KSPUtil.ApplicationRootPath, "GameData"); kspRootPath = KSPUtil.ApplicationRootPath; //Fix DarkLog time/thread marker in the log during init. DarkLog.SetMainThread(); lastClockTicks = DateTime.UtcNow.Ticks; lastRealTimeSinceStartup = 0f; dmpClient = this; profiler = new Profiler(); kspTime = profiler.GetCurrentTime; kspMemory = profiler.GetCurrentMemory; dmpSettings = new Settings(); toolbarSupport = new ToolbarSupport(dmpSettings); universeSyncCache = new UniverseSyncCache(dmpSettings); modWindow = new ModWindow(); modWorker = new ModWorker(modWindow); modWindow.SetDependenices(modWorker); universeConverter = new UniverseConverter(dmpSettings); universeConverterWindow = new UniverseConverterWindow(universeConverter); serverListDisclaimerWindow = new ServerListDisclaimerWindow(dmpSettings); optionsWindow = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport, serverListDisclaimerWindow); serverListConnection = new ServerListConnection(dmpSettings); serversWindow = new ServersWindow(dmpSettings, optionsWindow, serverListConnection); serverListConnection.SetDependancy(serversWindow); connectionWindow = new ConnectionWindow(dmpSettings, optionsWindow, serversWindow, serverListDisclaimerWindow); disclaimerWindow = new DisclaimerWindow(dmpSettings); dmpModInterface = new DMPModInterface(); //SafetyBubble.RegisterDefaultLocations(); if (dmpSettings.disclaimerAccepted != 1) { modDisabled = true; disclaimerWindow.SpawnDialog(); } Application.wantsToQuit += WantsToQuit; DontDestroyOnLoad(this); // Prevents symlink warning for development. SetupDirectoriesIfNeeded(); // UniverseSyncCache needs to run expiry here universeSyncCache.ExpireCache(); GameEvents.onHideUI.Add(() => { showGUI = false; }); GameEvents.onShowUI.Add(() => { showGUI = true; }); HandleCommandLineArgs(); DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!"); }