/// <summary> /// Creates a new PhysicsWatch from a certain amount of time, starts it, and returns the current instance /// </summary> /// <param name="seconds">Time to start the watch at, in seconds</param> public static PhysicsWatch StartNewFromTime(double seconds) { var watch = new PhysicsWatch(seconds); watch.Start(); return(watch); }
/// <summary> /// Creates a new PhysicsWatch, starts it, and returns the current instance /// </summary> public static PhysicsWatch StartNew() { var watch = new PhysicsWatch(); watch.Start(); return(watch); }
/// <summary> /// Creates a new PhysicsWatch from a certain amount of time, starts it, and returns the current instance /// </summary> /// <param name="seconds">Time to start the watch at, in seconds</param> public static PhysicsWatch StartNewFromTime(double seconds) { PhysicsWatch watch = new PhysicsWatch(seconds); watch.Start(); return watch; }
/// <summary> /// Creates a new PhysicsWatch, starts it, and returns the current instance /// </summary> public static PhysicsWatch StartNew() { PhysicsWatch watch = new PhysicsWatch(); watch.Start(); return watch; }
public override void OnStart(StartState startState) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (!CompatibilityChecker.IsAllCompatible()) { Actions.ForEach(a => a.active = false); Events.ForEach(e => { e.active = false; e.guiActive = false; e.guiActiveEditor = false; }); Fields["chuteCount"].guiActive = false; return; } //Staging icon part.stagingIcon = "PARACHUTES"; InitializeAnimationSystem(); //First initiation of the part if (!initiated) { initiated = true; armed = false; chuteCount = maxSpares; cap.gameObject.SetActive(true); } float tmpPartMass = TotalMass; massDelta = 0; if (!(part.partInfo?.partPrefab is null)) { massDelta = tmpPartMass - part.partInfo.partPrefab.mass; } //Flight loading if (HighLogic.LoadedSceneIsFlight) { var random = new Random(); randomTime = (float)random.NextDouble(); randomX = (float)(random.NextDouble() * 100); randomY = (float)(random.NextDouble() * 100); //Hide/show UI event addition GameEvents.onHideUI.Add(HideUI); GameEvents.onShowUI.Add(ShowUI); GameEvents.onStageActivate.Add(OnStageActivate); if (CanRepack) { SetRepack(); } if (!time.NearlyEqual(0)) { dragTimer = new PhysicsWatch(time); } if (DeploymentState != DeploymentStates.STOWED) { part.stackIcon.SetIconColor(XKCDColors.Red); cap.gameObject.SetActive(false); } if (staged && IsDeployed) { parachute.gameObject.SetActive(true); switch (DeploymentState) { case DeploymentStates.PREDEPLOYED: part.SkipToAnimationTime(semiDeployedAnimation, semiDeploymentSpeed, Mathf.Clamp01(time)); break; case DeploymentStates.DEPLOYED: part.SkipToAnimationTime(fullyDeployedAnimation, deploymentSpeed, Mathf.Clamp01(time)); break; } } DragCubeList cubes = part.DragCubes; //Set stock cubes to 0 cubes.SetCubeWeight("PACKED", 0); cubes.SetCubeWeight("SEMIDEPLOYED", 0); cubes.SetCubeWeight("DEPLOYED", 0); //Sets RC cubes if (DeploymentState == DeploymentStates.STOWED) { cubes.SetCubeWeight("PACKED", 1); cubes.SetCubeWeight("RCDEPLOYED", 0); } else { cubes.SetCubeWeight("PACKED", 0); cubes.SetCubeWeight("RCDEPLOYED", 1); } } //GUI window = new Rect(200, 100, 350, 400); drag = new Rect(0, 0, 350, 30); }