private void MoveKerbal(KerbalEVA kerbalEva, ref MotionSettings currentMotion) { Animation currentAnimation = null; kerbalEva.GetComponentCached <Animation>(ref currentAnimation); Rigidbody rigidbody = null; kerbalEva.GetComponentCached <Rigidbody>(ref rigidbody); if ((currentAnimation == null) || (rigidbody == null)) { return; } currentMotion = GetNewMotionSettings(kerbalEva, currentMotion); var orientation = kerbalEva.part.vessel.transform.rotation; var deltaPosition = orientation * Vector3.forward.normalized * (TimeWarp.deltaTime * currentMotion.Speed); currentAnimation.CrossFade(currentMotion.Animation); rigidbody.interpolation = RigidbodyInterpolation.Extrapolate; RemoveRBAnchor(kerbalEva); rigidbody.MovePosition(rigidbody.position + deltaPosition); }
///<summary> /// Updates the time of impact for the pair. ///</summary> ///<param name="requester">Collidable requesting the update.</param> ///<param name="dt">Timestep duration.</param> public override void UpdateTimeOfImpact(Collidable requester, float dt) { timeOfImpact = 1; foreach (CollidablePairHandler pair in subPairs.Values) //The system uses the identity of the requester to determine if it needs to do handle the TOI calculation. //Use the child pair's own entries as a proxy. { if (MotionSettings.CCDFilter(pair)) { if (BroadPhaseOverlap.entryA == requester) { pair.UpdateTimeOfImpact((Collidable)pair.BroadPhaseOverlap.entryA, dt); } else { pair.UpdateTimeOfImpact((Collidable)pair.BroadPhaseOverlap.entryB, dt); } if (pair.timeOfImpact < timeOfImpact) { timeOfImpact = pair.timeOfImpact; } } } }
public ProgramSettingMotionForm(MotionSettings settings) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; this.propertyGrid1.SelectedObject = settings; this.ReadLanguageResources(); }
private void AlterMotionAsPerUserKeystrokes(MotionSettings motion, KeyCombination perpetualMotionKeys) { if (IsKeyCombinationPressed(perpetualMotionKeys)) { motion.State = (motion.State == MotionState.perpetual) ? MotionState.stopping : MotionState.perpetual; $"Set motion state to {motion.State}".Debug(); } if (GameSettings.EVA_Run.GetKeyDown()) { motion.IsRunning = !motion.IsRunning; } }
void ICCDPositionUpdateable.UpdateTimesOfImpact(float dt) { //I am a continuous object. If I am in a pair with another object, even if I am inactive, //I must order the pairs to compute a time of impact. //The pair method works in such a way that, when this method is run asynchronously, there will be no race conditions. for (int i = 0; i < collisionInformation.pairs.Count; i++) { //Only perform CCD if we're either supposed to test against no solver pairs or if this isn't a no solver pair. if (MotionSettings.PairAllowsCCD(this, collisionInformation.pairs.Elements[i])) { collisionInformation.pairs.Elements[i].UpdateTimeOfImpact(collisionInformation, dt); } } }
private MotionSettings GetNewMotionSettings(KerbalEVA kerbal, MotionSettings currentMotion) { var gforce = FlightGlobals.currentMainBody.GeeASL; var newMotion = new MotionSettings { Animation = currentMotion.Animation, IsRunning = currentMotion.IsRunning, Speed = currentMotion.Speed, State = currentMotion.State, }; if (currentMotion.State == MotionState.stopping) { newMotion.Animation = (kerbal.part.WaterContact) ? "swim_idle" : "idle"; newMotion.Speed = 0; newMotion.State = MotionState.normal; } else if (kerbal.part.WaterContact) { newMotion.Animation = "swim_forward"; newMotion.Speed = kerbal.swimSpeed; } else if (currentMotion.IsRunning && (gforce >= kerbal.minRunningGee)) { newMotion.Animation = "wkC_run"; newMotion.Speed = kerbal.runSpeed; } else if (gforce < kerbal.minWalkingGee) { newMotion.Animation = "wkC_loG_forward"; newMotion.Speed = kerbal.boundSpeed; } else { newMotion.Animation = "wkC_forward"; newMotion.IsRunning = false; newMotion.Speed = kerbal.walkSpeed; }; return(newMotion); }
/// <summary>Detects if the scene is for a kerbal on EVA and adds any outstanding inventory items.</summary> public void Start() { var kerbalEva = GetKerbalEva(); if (kerbalEva == null) { "WalkAboutEva deactivated: not a valid Kerbal EVA".Debug(); return; } SetPerpetualMotionKeyCombo(); _currentMotion = new MotionSettings() { State = MotionState.normal, IsRunning = false, }; var kerbalPcm = FlightGlobals.ActiveVessel.GetVesselCrew()[0]; $"Flight scene started for {kerbalPcm.name}".Debug(); System.Reflection.Assembly KisMod = null; if (!WalkAboutKspAccess.TryGetKisMod(ref KisMod)) { $"KIS not installed".Debug(); return; } $"obtained KIS mod assembly [{KisMod}]".Debug(); if (WalkAboutPersistent.AllocatedItems.ContainsKey(kerbalPcm.name)) { AddInventoryItems(kerbalPcm); //, KisMod); } else { $"{kerbalPcm.name} has no items to add to inventory".Debug(); } }