public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent<DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent<DragManager>(); DragManager.SetPart(part); } anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) s.layer = i++; } animState.normalizedSpeed = 0; if (engaged) { animState.normalizedTime = Drag / 100; spoilerState = ModuleLandingGear.GearStates.DEPLOYED; } else { animState.normalizedTime = 0; spoilerState = ModuleLandingGear.GearStates.RETRACTED; } anim.Play(AnimationName); }
private void Update() { if (part.packed && HighLogic.LoadedSceneIsFlight) { return; } if (!Deployed && gearState == ModuleLandingGear.GearStates.DEPLOYED) { gearState = ModuleLandingGear.GearStates.RETRACTING; animState.normalizedTime = 1; animState.speed = -Math.Abs(animState.speed); anim.Play(AnimationName); } else if (!Deployed && gearState == ModuleLandingGear.GearStates.DEPLOYING) { gearState = ModuleLandingGear.GearStates.RETRACTING; animState.speed = -Math.Abs(animState.speed); anim.Play(AnimationName); } else if (Deployed && gearState == ModuleLandingGear.GearStates.RETRACTED) { gearState = ModuleLandingGear.GearStates.DEPLOYING; animState.normalizedTime = 0; animState.speed = Math.Abs(animState.speed); anim.Play(AnimationName); } else if (Deployed && gearState == ModuleLandingGear.GearStates.RETRACTING) { gearState = ModuleLandingGear.GearStates.DEPLOYING; animState.speed = Math.Abs(animState.speed); anim.Play(AnimationName); } if (!anim.IsPlaying(AnimationName)) { if (gearState == ModuleLandingGear.GearStates.DEPLOYING) { gearState = ModuleLandingGear.GearStates.DEPLOYED; DragManager.SetDrag(this, new DragValue(MaxDragMinMax.y, MinDragMinMax.y)); } else if (gearState == ModuleLandingGear.GearStates.RETRACTING) { gearState = ModuleLandingGear.GearStates.RETRACTED; gearHandler.ResetSuspension(); DragManager.SetDrag(this, new DragValue(MaxDragMinMax.x, MinDragMinMax.x)); } } else { UpdateDrag(); } gearHandler.UpdateBrakes(Brakes); }
public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent <DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent <DragManager>(); DragManager.SetPart(part); } gearHandler.Start(ID, part); anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) { s.layer = i++; } } part.PhysicsSignificance = 1; Transform bounds = part.FindModelTransform("Bounds"); if (bounds != null) { UnityEngine.Object.DestroyImmediate(bounds.gameObject); } gearState = Deployed ? ModuleLandingGear.GearStates.DEPLOYED : ModuleLandingGear.GearStates.RETRACTED; animState.normalizedTime = Deployed ? 1 : 0; animState.speed = Deployed ? Mathf.Abs(animState.speed) : -Mathf.Abs(animState.speed); UpdateDrag(); anim.Play(AnimationName); HashSet <WheelCollider> tmp = new HashSet <WheelCollider>(); part.transform.FindWheelColliders(ref tmp); foreach (WheelCollider w in tmp) { w.enabled = true; } }
public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent <DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent <DragManager>(); DragManager.SetPart(part); } anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) { s.layer = i++; } } animState.normalizedSpeed = 0; if (engaged) { animState.normalizedTime = Drag / 100; spoilerState = ModuleLandingGear.GearStates.DEPLOYED; } else { animState.normalizedTime = 0; spoilerState = ModuleLandingGear.GearStates.RETRACTED; } anim.Play(AnimationName); }
private void Update() { if (part.packed && HighLogic.LoadedSceneIsFlight) return; float animSpeed = (HighLogic.LoadedSceneIsFlight ? TimeWarp.deltaTime * 60 : 1) / animState.clip.frameRate; if (engaged && Drag == 0) { engaged = false; spoilerState = ModuleLandingGear.GearStates.RETRACTING; } float DragPercentage = Drag / 100; switch (spoilerState) { case ModuleLandingGear.GearStates.DEPLOYED: if (!engaged) spoilerState = ModuleLandingGear.GearStates.RETRACTING; else { if (animState.normalizedTime != DragPercentage) { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime + ((animState.normalizedTime < DragPercentage ? 1 : -1) * animSpeed) , 0, animState.normalizedTime < DragPercentage ? DragPercentage : 1); } } break; case ModuleLandingGear.GearStates.DEPLOYING: if (!engaged) spoilerState = ModuleLandingGear.GearStates.RETRACTING; else { if (animState.normalizedTime == DragPercentage) { spoilerState = ModuleLandingGear.GearStates.DEPLOYED; } else { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime + ((animState.normalizedTime < DragPercentage ? 1 : -1) * animSpeed) , 0, animState.normalizedTime < DragPercentage ? DragPercentage : 1); } } break; case ModuleLandingGear.GearStates.RETRACTING: if (engaged) spoilerState = ModuleLandingGear.GearStates.DEPLOYING; else { if (animState.normalizedTime == 0) { spoilerState = ModuleLandingGear.GearStates.RETRACTED; } else { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime - animSpeed , 0, DragPercentage); } } break; case ModuleLandingGear.GearStates.RETRACTED: if (engaged) spoilerState = ModuleLandingGear.GearStates.DEPLOYING; break; } if (animState.normalizedTime != lastNormalizedTime) { lastNormalizedTime = animState.normalizedTime; DragManager.SetDrag(this, new DragValue( (MaxDragMinMax.x * (1 - animState.normalizedTime)) + (MaxDragMinMax.y * animState.normalizedTime), (MinDragMinMax.x * (1 - animState.normalizedTime)) + (MinDragMinMax.y * animState.normalizedTime) )); } }
private void Update() { if (part.packed && HighLogic.LoadedSceneIsFlight) return; if (!Deployed && gearState == ModuleLandingGear.GearStates.DEPLOYED) { gearState = ModuleLandingGear.GearStates.RETRACTING; animState.normalizedTime = 1; animState.speed = -Math.Abs(animState.speed); anim.Play(AnimationName); } else if (!Deployed && gearState == ModuleLandingGear.GearStates.DEPLOYING) { gearState = ModuleLandingGear.GearStates.RETRACTING; animState.speed = -Math.Abs(animState.speed); anim.Play(AnimationName); } else if (Deployed && gearState == ModuleLandingGear.GearStates.RETRACTED) { gearState = ModuleLandingGear.GearStates.DEPLOYING; animState.normalizedTime = 0; animState.speed = Math.Abs(animState.speed); anim.Play(AnimationName); } else if (Deployed && gearState == ModuleLandingGear.GearStates.RETRACTING) { gearState = ModuleLandingGear.GearStates.DEPLOYING; animState.speed = Math.Abs(animState.speed); anim.Play(AnimationName); } if (!anim.IsPlaying(AnimationName)) { if (gearState == ModuleLandingGear.GearStates.DEPLOYING) { gearState = ModuleLandingGear.GearStates.DEPLOYED; DragManager.SetDrag(this, new DragValue(MaxDragMinMax.y, MinDragMinMax.y)); } else if (gearState == ModuleLandingGear.GearStates.RETRACTING) { gearState = ModuleLandingGear.GearStates.RETRACTED; gearHandler.ResetSuspension(); DragManager.SetDrag(this, new DragValue(MaxDragMinMax.x, MinDragMinMax.x)); } } else UpdateDrag(); gearHandler.UpdateBrakes(Brakes); }
public override void OnStart(PartModule.StartState state) { DragManager = part.gameObject.GetComponent<DragManager>(); if (DragManager == null) { DragManager = part.gameObject.AddComponent<DragManager>(); DragManager.SetPart(part); } gearHandler.Start(ID,part); anim = part.FindModelAnimators(AnimationName)[0]; animState = anim[AnimationName]; animState.wrapMode = WrapMode.Clamp; if (FixAnimLayers) { int i = 0; foreach (AnimationState s in anim) s.layer = i++; } part.PhysicsSignificance = 1; Transform bounds = part.FindModelTransform("Bounds"); if (bounds != null) UnityEngine.Object.DestroyImmediate(bounds.gameObject); gearState = Deployed ? ModuleLandingGear.GearStates.DEPLOYED : ModuleLandingGear.GearStates.RETRACTED; animState.normalizedTime = Deployed ? 1 : 0; animState.speed = Deployed ? Mathf.Abs(animState.speed) : -Mathf.Abs(animState.speed); UpdateDrag(); anim.Play(AnimationName); HashSet<WheelCollider> tmp = new HashSet<WheelCollider>(); part.transform.FindWheelColliders(ref tmp); foreach (WheelCollider w in tmp) w.enabled = true; }
private void Update() { if (part.packed && HighLogic.LoadedSceneIsFlight) { return; } float animSpeed = (HighLogic.LoadedSceneIsFlight ? TimeWarp.deltaTime * 60 : 1) / animState.clip.frameRate; if (engaged && Drag == 0) { engaged = false; spoilerState = ModuleLandingGear.GearStates.RETRACTING; } float DragPercentage = Drag / 100; switch (spoilerState) { case ModuleLandingGear.GearStates.DEPLOYED: if (!engaged) { spoilerState = ModuleLandingGear.GearStates.RETRACTING; } else { if (animState.normalizedTime != DragPercentage) { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime + ((animState.normalizedTime < DragPercentage ? 1 : -1) * animSpeed) , 0, animState.normalizedTime < DragPercentage ? DragPercentage : 1); } } break; case ModuleLandingGear.GearStates.DEPLOYING: if (!engaged) { spoilerState = ModuleLandingGear.GearStates.RETRACTING; } else { if (animState.normalizedTime == DragPercentage) { spoilerState = ModuleLandingGear.GearStates.DEPLOYED; } else { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime + ((animState.normalizedTime < DragPercentage ? 1 : -1) * animSpeed) , 0, animState.normalizedTime < DragPercentage ? DragPercentage : 1); } } break; case ModuleLandingGear.GearStates.RETRACTING: if (engaged) { spoilerState = ModuleLandingGear.GearStates.DEPLOYING; } else { if (animState.normalizedTime == 0) { spoilerState = ModuleLandingGear.GearStates.RETRACTED; } else { animState.normalizedTime = Mathf.Clamp( animState.normalizedTime - animSpeed , 0, DragPercentage); } } break; case ModuleLandingGear.GearStates.RETRACTED: if (engaged) { spoilerState = ModuleLandingGear.GearStates.DEPLOYING; } break; } if (animState.normalizedTime != lastNormalizedTime) { lastNormalizedTime = animState.normalizedTime; DragManager.SetDrag(this, new DragValue( (MaxDragMinMax.x * (1 - animState.normalizedTime)) + (MaxDragMinMax.y * animState.normalizedTime), (MinDragMinMax.x * (1 - animState.normalizedTime)) + (MinDragMinMax.y * animState.normalizedTime) )); } }