diff --git a/MechJeb2/MechJeb2.csproj b/MechJeb2/MechJeb2.csproj index 0b6e104e9..66dc3f28d 100644 --- a/MechJeb2/MechJeb2.csproj +++ b/MechJeb2/MechJeb2.csproj @@ -211,7 +211,6 @@ - diff --git a/MechJeb2/MechJebPod.cs b/MechJeb2/MechJebPod.cs deleted file mode 100644 index 19ecad179..000000000 --- a/MechJeb2/MechJebPod.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System.Linq; -using UnityEngine; - -namespace MuMech -{ - public class MechJebPod : PartModule - { - public enum State - { - OFF, - AWAKENING, - AWAKE, - SLEEPING - } - - private MechJebCore core; - private Transform eye_base, eye_ball; - private AerodynamicsFX afx; - private float lastBlink, lastAction; - private float[] lastFlaps; - public State state; - - public override void OnStart(StartState state) - { - core = part.Modules.OfType().FirstOrDefault(); - eye_base = part.FindModelTransform("r4m0n_Control_point_socket"); // Rotation: 0, 0, Z Azimuth - eye_ball = part.FindModelTransform("r4m0n_Control_point_Eye"); // Rotation: X, 0, 0 Altitude - lastFlaps = new float[] { 0, 0, 0, 0 }; - } - - public float AdvanceAnimationTo(Animation anim, string clip, float to, float dt, float last = -1) - { - float ret = to; - - AnimationState st = anim[clip]; - st.enabled = true; - st.weight = 1; - if (last < 0) - { - last = st.normalizedTime; - } - - ret = st.normalizedTime = Mathf.MoveTowards(last, to, dt * st.length); - anim.Sample(); - st.enabled = false; - - return ret; - } - - public void Update() - { - if (afx == null) - { - var fx = GameObject.Find("FXLogic"); - if (fx != null) - { - afx = fx.GetComponent(); - } - } - - Animation flapsAnim = part.FindModelAnimators("Flap_Top_Right")[0]; - if (vessel != null && vessel.mainBody.atmosphere && vessel.altitude < vessel.mainBody.RealMaxAtmosphereAltitude()) - { - float direction = vessel.GetSrfVelocity().magnitude > 25 && Vector3.Angle(vessel.transform.up, vessel.GetSrfVelocity()) > 90 ? -1 : 1; - - lastFlaps[0] = AdvanceAnimationTo(flapsAnim, "Flap_Top_Right", - Mathf.Clamp01(direction * (vessel.ctrlState.pitch - vessel.ctrlState.yaw) / 2), TimeWarp.deltaTime, lastFlaps[0]); - lastFlaps[1] = AdvanceAnimationTo(flapsAnim, "Flap_Top_Left", - Mathf.Clamp01(direction * (vessel.ctrlState.pitch + vessel.ctrlState.yaw) / 2), TimeWarp.deltaTime, lastFlaps[1]); - lastFlaps[2] = AdvanceAnimationTo(flapsAnim, "Flap_Bottom_Right", - Mathf.Clamp01(direction * (-vessel.ctrlState.pitch - vessel.ctrlState.yaw) / 2), TimeWarp.deltaTime, lastFlaps[2]); - lastFlaps[3] = AdvanceAnimationTo(flapsAnim, "Flap_Bottom_Left", - Mathf.Clamp01(direction * (-vessel.ctrlState.pitch + vessel.ctrlState.yaw) / 2), TimeWarp.deltaTime, lastFlaps[3]); - } - else - { - lastFlaps[0] = AdvanceAnimationTo(flapsAnim, "Flap_Top_Right", 0, TimeWarp.deltaTime, lastFlaps[0]); - lastFlaps[1] = AdvanceAnimationTo(flapsAnim, "Flap_Top_Left", 0, TimeWarp.deltaTime, lastFlaps[1]); - lastFlaps[2] = AdvanceAnimationTo(flapsAnim, "Flap_Bottom_Right", 0, TimeWarp.deltaTime, lastFlaps[2]); - lastFlaps[3] = AdvanceAnimationTo(flapsAnim, "Flap_Bottom_Left", 0, TimeWarp.deltaTime, lastFlaps[3]); - } - - switch (state) - { - case State.OFF: - if (HighLogic.LoadedSceneIsEditor || - (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && vessel != null && core.attitude.enabled)) - { - state = State.AWAKENING; - part.FindModelAnimators("Waking")[0].Play("Waking"); - } - - break; - case State.AWAKENING: - if (!part.FindModelAnimators("Waking")[0].isPlaying) - { - AdvanceAnimationTo(part.FindModelAnimators("Waking")[0], "Waking", 1, 100); - - state = State.AWAKE; - lastBlink = lastAction = Time.time; - } - - break; - case State.AWAKE: - if (!part.FindModelAnimators("Blink")[0].isPlaying) - { - if (Random.Range(0, 10.0F / (HighLogic.LoadedSceneIsEditor ? Time.deltaTime : TimeWarp.deltaTime)) < Time.time - lastBlink) - { - part.FindModelAnimators("Blink")[0].Play("Blink"); - lastBlink = Time.time; - } - - GameObject cam = HighLogic.LoadedSceneIsEditor ? EditorLogic.fetch.editorCamera.gameObject : FlightCamera.fetch.gameObject; - Vector3 target = (cam.transform.position - part.transform.position).normalized; - if (core.attitude.enabled) - { - target = core.attitude.attitudeGetReferenceRotation(core.attitude.attitudeReference) * core.attitude.attitudeTarget * - Quaternion.Euler(90, 0, 0) * Vector3.up; - lastAction = Time.time; - } - - Vector3 localTarget = part.transform.InverseTransformDirection(target); - Vector2 polarTarget = CartesianToPolar(localTarget); - if (Mathfx.Approx(polarTarget.x, -90, 1) || Mathfx.Approx(polarTarget.x, 90, 1)) - { - polarTarget.y = eye_base.localEulerAngles.z + 90; - } - - if (!HighLogic.LoadedSceneIsEditor && Time.time - lastAction > 30) - { - if (Mathfx.Approx(eye_base.localEulerAngles.z, 0, 1) && Mathfx.Approx(eye_ball.localEulerAngles.x, 0, 1)) - { - state = State.SLEEPING; - part.FindModelAnimators("Sleeping")[0].Play("Sleeping"); - } - else - { - polarTarget = new Vector2(-90, 90); - } - } - - if (afx != null && afx.FxScalar > 0) - { - polarTarget = new Vector2(90, 90); - } - - eye_base.localEulerAngles = new Vector3(0, 0, - Mathf.MoveTowardsAngle(eye_base.localEulerAngles.z, polarTarget.y - 90, 360 * Time.deltaTime)); - eye_ball.localRotation = Quaternion.RotateTowards(eye_ball.localRotation, Quaternion.Euler(polarTarget.x + 90, 0, 0), - 360 * Time.deltaTime); - } - - break; - case State.SLEEPING: - if (!part.FindModelAnimators("Sleeping")[0].isPlaying) - { - AdvanceAnimationTo(part.FindModelAnimators("Sleeping")[0], "Sleeping", 1, 100); - - state = State.OFF; - } - - break; - } - } - - private Vector2 CartesianToPolar(Vector3 vector) - { - Vector2 polar; - polar.y = Mathf.Atan2(vector.x, vector.z); - float xzLen = new Vector2(vector.x, vector.z).magnitude; - polar.x = Mathf.Atan2(-vector.y, xzLen); - polar *= Mathf.Rad2Deg; - return polar; - } - } -} diff --git a/Parts/MechJeb2_Pod/model.mu b/Parts/MechJeb2_Pod/model.mu deleted file mode 100644 index 0b183c8c8..000000000 Binary files a/Parts/MechJeb2_Pod/model.mu and /dev/null differ diff --git a/Parts/MechJeb2_Pod/model000.dds b/Parts/MechJeb2_Pod/model000.dds deleted file mode 100644 index 1e472d368..000000000 Binary files a/Parts/MechJeb2_Pod/model000.dds and /dev/null differ diff --git a/Parts/MechJeb2_Pod/model001.dds b/Parts/MechJeb2_Pod/model001.dds deleted file mode 100644 index 44a64c24f..000000000 Binary files a/Parts/MechJeb2_Pod/model001.dds and /dev/null differ diff --git a/Parts/MechJeb2_Pod/model002.dds b/Parts/MechJeb2_Pod/model002.dds deleted file mode 100644 index b9eb25e01..000000000 Binary files a/Parts/MechJeb2_Pod/model002.dds and /dev/null differ diff --git a/Parts/MechJeb2_Pod/part.cfg b/Parts/MechJeb2_Pod/part.cfg deleted file mode 100644 index e43001ce0..000000000 --- a/Parts/MechJeb2_Pod/part.cfg +++ /dev/null @@ -1,250 +0,0 @@ -RESOURCE_DEFINITION -{ - name = MJPropellant - displayName = #MechJeb_RESOURCE_MJPropellant - density = 0.004 - flowMode = NO_FLOW - transfer = NONE -} - -PART { - // --- general parameters --- - name = mumech_MJ2_Pod - module = Part - author = r4m0n/The_Duck (code) || CardBoardBoxProcessor (model) - - // --- asset parameters --- - mesh = model.mu - - // --- node definitions --- - // definition format is Position X, Position Y, Position Z, Up X, Up Y, Up Z - node_stack_bottom = 0.0, -0.6010774, 0.0, 0.0, -1.0, 0.0, 1 - - fx_exhaustFlame_white_tiny = 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, running - - // --- Sound FX definition --- - sound_vent_medium = engage - sound_rocket_mini = running - sound_vent_soft = disengage - - // --- editor parameters --- - TechRequired = automation - entryCost = 250000 - cost = 35000 - category = none - subcategory = 0 - title = #MechJeb_MechanicalJeb2_Title // #MechJeb_MechanicalJeb_Title = Mechanical Jeb - Pod version 2.0 - manufacturer = #MechJeb_AnatidRobotics_Multiversal // #MechJeb_AnatidRobotics_Multiversal = Anatid Robotics / Multiversal Mechatronics - description = #MechJeb_MechanicalJeb2_Description // #MechJeb_MechanicalJeb2_Description = After many years spent on research, our scientists still couldn't explain why Jebediah Kerman was such a good pilot, so we decided to make a mechanical copy of his brain to help pilot our ships. This is an unmanned pod version of MechJeb, designed to save the life of the brave Kerbals who volunteer to test new crafts. - - // attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision - attachRules = 1,0,1,1,1 - - // --- standard part parameters --- - mass = 2 - dragModelType = default - maximum_drag = 0.2 - minimum_drag = 0.1 - angularDrag = 2 - crashTolerance = 10 - maxTemp = 3400 - - vesselType = Probe - stagingIcon = COMMAND_POD - bulkheadProfiles = size0 - - // --- internal setup --- - CrewCapacity = 0 - - tags = cmg command control fly gyro moment react stab steer torque autopilot rcs sas - - MODULE - { - name = ModuleCommand - minimumCrew = 0 - - RESOURCE - { - name = ElectricCharge - rate = 0.005 - } - } - - MODULE - { - name = ModuleReactionWheel - - PitchTorque = 6 - YawTorque = 6 - RollTorque = 6 - - RESOURCE - { - name = ElectricCharge - rate = 0.15 - } - } - - MODULE - { - name = ModuleSAS - } - - MODULE - { - name = MechJebCore - MechJebLocalSettings { - MechJebModuleCustomWindowEditor { unlockTechs = flightControl } - MechJebModuleSmartASS { unlockTechs = flightControl } - MechJebModuleManeuverPlanner { unlockTechs = advFlightControl } - MechJebModuleNodeEditor { unlockTechs = advFlightControl } - MechJebModuleTranslatron { unlockTechs = advFlightControl } - MechJebModuleWarpHelper { unlockTechs = advFlightControl } - MechJebModuleAttitudeAdjustment { unlockTechs = advFlightControl } - MechJebModuleThrustWindow { unlockTechs = advFlightControl } - MechJebModuleRCSBalancerWindow { unlockTechs = advFlightControl } - MechJebModuleRoverWindow { unlockTechs = fieldScience } - MechJebModuleAscentGuidance { unlockTechs = unmannedTech } - MechJebModuleLandingGuidance { unlockTechs = unmannedTech } - MechJebModuleSpaceplaneGuidance { unlockTechs = unmannedTech } - MechJebModuleDockingGuidance { unlockTechs = advUnmanned } - MechJebModuleRendezvousAutopilotWindow { unlockTechs = advUnmanned } - MechJebModuleRendezvousGuidance { unlockTechs = advUnmanned } - } - } - - MODULE - { - name = MechJebPod - } - - RESOURCE - { - name = ElectricCharge - amount = 10 - maxAmount = 10 - } - - MODULE - { - name = ModuleGenerator - isAlwaysActive = true - OUTPUT_RESOURCE - { - name = ElectricCharge - rate = 0.25 - } - } - - MODULE - { - name = ModuleRCS - thrusterTransformName = RCSthruster - thrusterPower = 4 - resourceName = MJPropellant - fxOffset = 0, 0, 0 - atmosphereCurve - { - key = 0 260 - key = 1 100 - } - } - - RESOURCE - { - name = MJPropellant - amount = 1000 - maxAmount = 1000 - } - - MODULE - { - name = ModuleEngines - thrustVectorTransformName = engine - exhaustDamage = False - ignitionThreshold = 0.1 - minThrust = 0 - maxThrust = 100 - heatProduction = 300 - fxOffset = 0, 0, 7 - PROPELLANT - { - name = MJPropellant - ratio = 1 - DrawGauge = True - } - atmosphereCurve - { - key = 0 260 - key = 1 100 - } - } - - MODULE - { - name = ModuleGimbal - gimbalTransformName = engine - gimbalRange = 1 - useGimbalResponseSpeed = true - GimbalResponseSpeed = 0.1 - } - - MODULE - { - name = ModuleJettison - jettisonName = adapter - bottomNodeName = bottom - isFairing = True - jettisonedObjectMass = 0.1 - jettisonForce = 5 - jettisonDirection = 0 0 1 - } - - //MODULE - //{ - // name = ModuleLandingLeg - // animationName = Legs_Extend - // wheelColliderName = wheel1 - // suspensionTransformName = Leg001 - // suspensionUpperLimit = 14.3 - // impactTolerance = 300 - // suspensionSpring = 10 - // suspensionDamper = 1 - //} - // - //MODULE - //{ - // name = ModuleLandingLeg - // animationName = Legs_Extend - // wheelColliderName = wheel2 - // suspensionTransformName = Leg002 - // suspensionUpperLimit = 14.3 - // impactTolerance = 300 - // suspensionSpring = 10 - // suspensionDamper = 1 - //} - // - //MODULE - //{ - // name = ModuleLandingLeg - // animationName = Legs_Extend - // wheelColliderName = wheel3 - // suspensionTransformName = Leg003 - // suspensionUpperLimit = 14.3 - // impactTolerance = 300 - // suspensionSpring = 10 - // suspensionDamper = 1 - //} - // - //MODULE - //{ - // name = ModuleLandingLeg - // animationName = Legs_Extend - // wheelColliderName = wheel4 - // suspensionTransformName = Leg004 - // suspensionUpperLimit = 14.3 - // impactTolerance = 300 - // suspensionSpring = 10 - // suspensionDamper = 1 - //} -}