private void MotorGoTo(float angle) { KAS_Shared.DebugLog("MotorGoTo(Rotor) - Go to angle : " + angle); if (!KAS_Shared.RequestPower(this.part, powerDrain)) { return; } fxSndMotorStart.audio.Play(); if (!fxSndMotor.audio.isPlaying) { fxSndMotor.audio.Play(); } rotorGoingTo = true; hingeJnt.useSpring = true; hingeJnt.useMotor = false; hingeJnt.useLimits = hasLimit; rotorActivated = true; JointSpring spr = new JointSpring(); spr.spring = spring; spr.targetPosition = angle; spr.damper = damper; hingeJnt.spring = spr; }
private void UpdateExtend() { if (extend.active && !extend.full) { if (KAS_Shared.RequestPower(this.part, powerDrain)) { extend.isrunning = true; if (!extend.starting) { retract.full = false; retract.active = false; extend.starting = true; stateField = "Extending..."; fxSndMotorStart.audio.loop = false; fxSndMotorStart.audio.Play(); } if (headPos < sectionTotalLenght) { if (!fxSndMotor.audio.isPlaying) { fxSndMotor.audio.Play(); } if (targetPos < sectionTotalLenght) { SetTargetPos(targetPos + speed * TimeWarp.deltaTime); } else { SetTargetPos(sectionTotalLenght); } } else { extend.full = true; extend.active = false; SetTargetPos(sectionTotalLenght); } } else { if (this.part.vessel == FlightGlobals.ActiveVessel) { ScreenMessages.PostScreenMessage(part.partInfo.title + " stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER); } stateField = "Insufficient Power"; StopExtend(); } } else { StopExtend(); } }
private void AttachMagnet(Part partToAttach) { if (KAS_Shared.RequestPower(this.part, powerDrain)) { //Disable all collisions this.part.collider.isTrigger = true; // Create joint AttachFixed(this.part, partToAttach, breakForce); // Set reference MagnetActive = true; } else { ScreenMessages.PostScreenMessage("Magnet not powered !", 5, ScreenMessageStyle.UPPER_CENTER); } }
void UpdateMagnet() { if (!MagnetActive) { return; } //Drain power and stop if no energy if (!KAS_Shared.RequestPower(this.part, powerDrain)) { state = "Insufficient Power"; if (this.part.vessel == FlightGlobals.ActiveVessel) { ScreenMessages.PostScreenMessage("Magnet stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER); } MagnetActive = false; } }
private void MotorStart(motorWay way) { KAS_Shared.DebugLog("MotorStart(Rotor) - Start motor..."); if (!hingeJnt) { return; } if (KAS_Shared.RequestPower(this.part, powerDrain)) { //Sound if (hingeJnt.motor.targetVelocity == 0) { fxSndMotorStart.audio.Play(); } if (!fxSndMotor.audio.isPlaying) { fxSndMotor.audio.Play(); } //Limit config ResetLimitsConfig(); hingeJnt.useLimits = hasLimit; JointMotor mtr = new JointMotor(); //Motor config mtr.force = force; mtr.freeSpin = freeSpin; if (way == motorWay.Negative) { if (controlInverted) { mtr.targetVelocity = speed; } else { mtr.targetVelocity = -speed; } stateField = "Going " + negativeWayText; } if (way == motorWay.Positive) { if (controlInverted) { mtr.targetVelocity = -speed; } else { mtr.targetVelocity = speed; } stateField = "Going " + positiveWayText; } hingeJnt.motor = mtr; //misc hingeJnt.useSpring = false; hingeJnt.useMotor = true; rotorActivated = true; } else { if (this.part.vessel == FlightGlobals.ActiveVessel) { ScreenMessages.PostScreenMessage(this.part.partInfo.title + " stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER); } stateField = "Insufficient Power"; } }