Beispiel #1
0
        void OnVesselWasModified(Vessel vesselModified)
        {
            if (vesselModified != this.vessel)
            {
                return;
            }

            if (linked)
            {
                if (linkedStrutModule.vessel != this.vessel)
                {
                    if (allowDock)
                    {
                        KAS_Shared.DebugWarning("OnVesselWasModified(strut) Source and target vessel are different, docking strut... (allowDock = true)");
                        KASModuleStrut tmpLinkedStrutMod = linkedStrutModule;
                        Unlink();
                        LinkTo(tmpLinkedStrutMod, false);
                    }
                    else
                    {
                        KAS_Shared.DebugWarning("OnVesselWasModified(strut) Source and target vessel are different, unlinking strut... (allowDock = false)");
                        Unlink();
                        fxSndBroke.audio.Play();
                    }
                }
            }
        }
Beispiel #2
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            // Do not load ScienceData nodes for this module's host part (a KAS container) as they were only stored in case the vessel was
            // recovered. The original parts still contain the science data. (See OnSave.)

            if (node.HasNode("CONTENT") || node.HasNode("CONTENT_PART"))
            {
                contents.Clear();
            }

            foreach (ConfigNode cn in node.nodes)
            {
                if (cn.name != "CONTENT" && cn.name != "CONTENT_PART")
                {
                    continue;
                }

                string      AvPartName = cn.GetValue("name") ?? "null";
                PartContent item       = PartContent.Get(contents, AvPartName);

                if (item != null)
                {
                    item.Load(cn);
                }
                else
                {
                    KAS_Shared.DebugError("Load(Container) - Cannot retrieve " + AvPartName + " from PartLoader !");
                }
            }
        }
Beispiel #3
0
 public void RefreshCtrlState()
 {
     KAS_Shared.DebugLog("RefreshCtrlState(Rotor)");
     if (controlActivated)
     {
         if (controlInverted)
         {
             controlField = "Enabled(Inverted)";
         }
         else
         {
             controlField = "Enabled";
         }
     }
     else
     {
         if (controlInverted)
         {
             controlField = "Disabled(Inverted)";
         }
         else
         {
             controlField = "Disabled";
         }
     }
 }
Beispiel #4
0
 public override void OnJointBreakFixed()
 {
     KAS_Shared.DebugWarning("OnJointBreak(Strut) A joint broken on " + part.partInfo.title
                             + " !, force: " + breakForce);
     Unlink();
     fxSndBroke.audio.Play();
 }
Beispiel #5
0
 private void StopPump()
 {
     UnlinkPump();
     pumpFuel = false;
     Events["ContextMenuTogglePump"].guiName = "Pump Here";
     KAS_Shared.InvalidateContextMenu(this.part);
 }
Beispiel #6
0
        private void StoreGrabbedPart()
        {
            KASModuleGrab moduleGrab = KAS_Shared.GetGrabbedPartModule(FlightGlobals.ActiveVessel);

            if (!moduleGrab)
            {
                fxSndBipWrong.audio.Play();
                ScreenMessages.PostScreenMessage("You didn't grab anything to store !", 5, ScreenMessageStyle.UPPER_CENTER);
                return;
            }
            if (!moduleGrab.storable)
            {
                fxSndBipWrong.audio.Play();
                ScreenMessages.PostScreenMessage("This part cannot be stored !", 5, ScreenMessageStyle.UPPER_CENTER);
                return;
            }
            if (MaxSizeReached(moduleGrab.part.partInfo, 1))
            {
                fxSndBipWrong.audio.Play();
                ScreenMessages.PostScreenMessage("Max size of the container reached !", 5, ScreenMessageStyle.UPPER_CENTER);
                return;
            }
            Add(moduleGrab.part.partInfo, 1);
            moduleGrab.Drop();
            moduleGrab.part.Die();
            fxSndStore.audio.Play();
        }
Beispiel #7
0
 /// <summary>Starts physics handling on the object.</summary>
 /// <remarks>The object is expected to not have rigidbody. The one will be added with the proper
 /// mass and velocity settings. Parent transform of the physics object will be set top
 /// <c>null</c>, and it will become an idependent object.</remarks>
 /// <param name="physicObj">Game object to attach physics to. In normal case it's never a part's
 /// gameobject.</param>
 /// <param name="mass">Mass of the rigidbody.</param>
 /// <param name="delayPhysics">If default or <c>false</c> then new object gets parent's velocity
 /// immediately. Otherwise, the rigidbody is created as kinematic and velocity is sync'ed in the
 /// next <c>FixedUpdate()</c> call.</param>
 public void StartPhysics(GameObject physicObj, float mass, bool delayPhysics = false)
 {
     KAS_Shared.DebugLog("StartPhysics(PhysicChild)");
     if (this.physicObj == null)
     {
         this.physicObj         = physicObj;
         physicObjRb            = physicObj.AddComponent <Rigidbody>();
         physicObjRb.mass       = mass;
         physicObjRb.useGravity = false;
         if (delayPhysics)
         {
             physicObjRb.isKinematic = true;
             StartCoroutine(WaitAndPromoteToPhysic());
         }
         else
         {
             physicObjRb.velocity        = part.Rigidbody.velocity;
             physicObjRb.angularVelocity = part.Rigidbody.angularVelocity;
             physicObj.transform.parent  = null;
         }
     }
     else
     {
         KAS_Shared.DebugWarning("StartPhysics(PhysicChild) Physic already started! Ignore.");
     }
 }
Beispiel #8
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (node.HasNode("CONTENT") || node.HasNode("CONTENT_PART"))
            {
                contents.Clear();
            }

            foreach (ConfigNode cn in node.nodes)
            {
                if (cn.name != "CONTENT" && cn.name != "CONTENT_PART")
                {
                    continue;
                }

                string      AvPartName = cn.GetValue("name") ?? "null";
                PartContent item       = PartContent.Get(contents, AvPartName);

                if (item != null)
                {
                    item.Load(cn);
                }
                else
                {
                    KAS_Shared.DebugError("Load(Container) - Cannot retrieve " + AvPartName + " from PartLoader !");
                }
            }
        }
Beispiel #9
0
 public void OnPartUnpack()
 {
     if (grabbed)
     {
         if (!evaHolderPart)
         {
             if (evaHolderVesselName != null && evaHolderVesselName != "")
             {
                 Vessel vess = KAS_Shared.GetVesselByName(evaHolderVesselName);
                 if (vess)
                 {
                     KAS_Shared.DebugLog("OnPartUnpack(EvaGrab) - Re-set grab after load on : " + evaHolderVesselName);
                     Grab(vess);
                 }
                 else
                 {
                     evaHolderVesselName = null;
                     evaHolderPart       = null;
                     grabbed             = false;
                 }
             }
         }
         else
         {
             if (!physicJoint)
             {
                 this.part.rigidbody.isKinematic = true;
             }
         }
     }
 }
Beispiel #10
0
        public void AttachStatic(float breakForce = 10)
        {
            KAS_Shared.DebugLog("JointToStatic(Base) Create kinematic rigidbody");
            if (StaticAttach.connectedGameObject)
            {
                Destroy(StaticAttach.connectedGameObject);
            }
            GameObject obj = new GameObject("KASBody");

            obj.AddComponent <Rigidbody>();
            obj.rigidbody.isKinematic        = true;
            obj.transform.position           = this.part.transform.position;
            obj.transform.rotation           = this.part.transform.rotation;
            StaticAttach.connectedGameObject = obj;

            KAS_Shared.DebugLog("JointToStatic(Base) Create fixed joint on the kinematic rigidbody");
            if (StaticAttach.fixedJoint)
            {
                Destroy(StaticAttach.fixedJoint);
            }
            FixedJoint CurJoint = this.part.gameObject.AddComponent <FixedJoint>();

            CurJoint.breakForce     = breakForce;
            CurJoint.breakTorque    = breakForce;
            CurJoint.connectedBody  = obj.rigidbody;
            StaticAttach.fixedJoint = CurJoint;
            attachMode.StaticJoint  = true;
        }
Beispiel #11
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state != StartState.None)
            {
                if (allowRelease)
                {
                    Actions["ActionGroupRelease"].active            = true;
                    Events["ContextMenuRelease"].guiActive          = true;
                    Events["ContextMenuRelease"].guiActiveUnfocused = true;
                }
                else
                {
                    Actions["ActionGroupRelease"].active            = false;
                    Events["ContextMenuRelease"].guiActive          = false;
                    Events["ContextMenuRelease"].guiActiveUnfocused = false;
                }
            }

            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }
            KAS_Shared.createFXSound(this.part, fxSndStore, sndStorePath, false);
            LoadBays();
        }
Beispiel #12
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("FIXEDATTACH"))
     {
         ConfigNode FxNode = node.GetNode("FIXEDATTACH");
         KAS_Shared.DebugLog("OnLoad(Core) Loading fixed joint info from save...");
         FixedAttach.savedPartID     = FxNode.GetValue("connectedPartID").ToString();
         FixedAttach.savedVesselID   = FxNode.GetValue("connectedVesselID").ToString();
         FixedAttach.savedBreakForce = float.Parse(FxNode.GetValue("breakForce"));
         attachMode.FixedJoint       = true;
     }
     if (node.HasNode("DOCKEDVESSEL") && node.HasValue("dockedPartID"))
     {
         KAS_Shared.DebugLog("OnLoad(Core) Loading docked info from save...");
         this.vesselInfo = new DockedVesselInfo();
         this.vesselInfo.Load(node.GetNode("DOCKEDVESSEL"));
         dockedPartID      = node.GetValue("dockedPartID").ToString();
         attachMode.Docked = true;
     }
     if (node.HasValue("StaticJoint"))
     {
         attachMode.StaticJoint = true;
     }
 }
Beispiel #13
0
        public void AttachFixed(Part srcPart, Part tgtPart, float breakForce)
        {
            attachMode.FixedJoint = true;
            FixedAttach.srcPart   = srcPart;
            FixedAttach.tgtPart   = tgtPart;

            if (!srcPart.packed && !tgtPart.packed)
            {
                KAS_Shared.DebugLog("AttachFixed(Core) Create fixed joint on " + srcPart.partInfo.title
                                    + " with " + tgtPart.partInfo.title);
                if (FixedAttach.fixedJoint)
                {
                    Destroy(FixedAttach.fixedJoint);
                }
                FixedAttach.fixedJoint = srcPart.gameObject.AddComponent <FixedJoint>();
                FixedAttach.fixedJoint.connectedBody = tgtPart.rb;
                FixedAttach.fixedJoint.breakForce    = breakForce;
                FixedAttach.fixedJoint.breakTorque   = breakForce;
            }
            else
            {
                SetCreateJointOnUnpack(true);
                KAS_Shared.DebugWarning("AttachFixed(Core) Cannot create fixed joint as part(s) is packed,"
                                        + " delaying to unpack...");
            }
        }
Beispiel #14
0
            public void Load(ConfigNode node)
            {
                if (node.name == "CONTENT" && node.HasValue("qty"))
                {
                    pristine_count += int.Parse(node.GetValue("qty"));
                }
                else if (node.name == "CONTENT_PART" && node.HasValue("kas_total_mass"))
                {
                    ConfigNode nodeD = new ConfigNode();
                    node.CopyTo(nodeD);

                    // Backward compatibility: compute the cost and save it
                    if (!nodeD.HasValue("kas_total_cost"))
                    {
                        var snapshot = KAS_Shared.LoadProtoPartSnapshot(nodeD);

                        float dry_cost, fuel_cost;
                        float total_cost = ShipConstruction.GetPartCosts(snapshot, part, out dry_cost, out fuel_cost);
                        nodeD.AddValue("kas_total_cost", total_cost);
                    }

                    instance_mass += float.Parse(nodeD.GetValue("kas_total_mass"));
                    instance_cost += float.Parse(nodeD.GetValue("kas_total_cost"));
                    instances.Add(nodeD);
                }
            }
Beispiel #15
0
 private void UpdateTelescopicArmControl()
 {
     //extend key pressed
     if (telescopicExtendKey != "")
     {
         if (Input.GetKeyDown(telescopicExtendKey.ToLower()))
         {
             KAS_Shared.SendMsgToTelescopicArm("EventTelescopicExtend", true, vess: FlightGlobals.ActiveVessel);
         }
         if (Input.GetKeyUp(telescopicExtendKey.ToLower()))
         {
             KAS_Shared.SendMsgToTelescopicArm("EventTelescopicExtend", false, vess: FlightGlobals.ActiveVessel);
         }
     }
     //retract key pressed
     if (telescopicRetractKey != "")
     {
         if (Input.GetKeyDown(telescopicRetractKey.ToLower()))
         {
             KAS_Shared.SendMsgToTelescopicArm("EventTelescopicRetract", true, vess: FlightGlobals.ActiveVessel);
         }
         if (Input.GetKeyUp(telescopicRetractKey.ToLower()))
         {
             KAS_Shared.SendMsgToTelescopicArm("EventTelescopicRetract", false, vess: FlightGlobals.ActiveVessel);
         }
     }
 }
Beispiel #16
0
        private IEnumerator WaitAndSendMsg(Part partToAttach, Vector3 position, Quaternion rotation, Part toPart = null)
        {
            while (!partToAttach.rigidbody)
            {
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Waiting rigidbody to initialize...");
                yield return(new WaitForFixedUpdate());
            }
            if (toPart)
            {
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Rigidbody initialized, setting velocity...");
                partToAttach.rigidbody.velocity        = toPart.rigidbody.velocity;
                partToAttach.rigidbody.angularVelocity = toPart.rigidbody.angularVelocity;
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Waiting velocity to apply by waiting 0.1 seconds...");
                yield return(new WaitForSeconds(0.1f));

                partToAttach.transform.position = position;
                partToAttach.transform.rotation = rotation;
                partToAttach.SendMessage("OnAttachPart", toPart, SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                partToAttach.transform.position = position;
                partToAttach.transform.rotation = rotation;
                partToAttach.SendMessage("OnAttachStatic", SendMessageOptions.DontRequireReceiver);
            }
        }
Beispiel #17
0
        public static Part GetPartByID(string vesselID, string partID)
        {
            Vessel searchVessel = FlightGlobals.Vessels.Find(ves => ves.id.ToString() == vesselID);

            if (searchVessel)
            {
                if (!searchVessel.loaded)
                {
                    KAS_Shared.DebugWarning("GetPartByID - Searched vessel are not loaded, loading it...");
                    searchVessel.Load();
                }
                Part searchedPart = searchVessel.Parts.Find(p => p.flightID.ToString() == partID);
                if (searchedPart)
                {
                    return(searchedPart);
                }
                else
                {
                    KAS_Shared.DebugError("GetPartByID - Searched part not found !");
                }
            }
            else
            {
                KAS_Shared.DebugError("GetPartByID - Searched vessel not found !");
            }
            return(null);
        }
Beispiel #18
0
 protected override void OnJointBreak(float breakForce)
 {
     base.OnJointBreak(breakForce);
     KAS_Shared.DebugWarning("A joint broken on " + part.partInfo.title + " !, force: " + breakForce);
     KAS_Shared.DebugWarning("Disable magnet...");
     MagnetActive = false;
 }
Beispiel #19
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (node.HasNode("CONTENT"))
            {
                contents.Clear();
            }

            foreach (ConfigNode cn in node.GetNodes("CONTENT"))
            {
                if (cn.HasValue("name") && cn.HasValue("qty"))
                {
                    string        AvPartName = cn.GetValue("name").ToString();
                    AvailablePart avPart     = null;
                    avPart = PartLoader.getPartInfoByName(AvPartName);
                    int qty = int.Parse(cn.GetValue("qty"));
                    if (avPart != null)
                    {
                        contents.Add(avPart, qty);
                    }
                    else
                    {
                        KAS_Shared.DebugError("Load(Container) - Cannot retrieve " + AvPartName + " from PartLoader !");
                    }
                }
            }
        }
Beispiel #20
0
 public static bool createFXSound(Part part, FXGroup group, string sndPath, bool loop,
                                  float maxDistance = 30f)
 {
     group.audio              = part.gameObject.AddComponent <AudioSource>();
     group.audio.volume       = GameSettings.SHIP_VOLUME;
     group.audio.rolloffMode  = AudioRolloffMode.Linear;
     group.audio.dopplerLevel = 0f;
     group.audio.spatialBlend = 1f;
     group.audio.maxDistance  = maxDistance;
     group.audio.loop         = loop;
     group.audio.playOnAwake  = false;
     if (GameDatabase.Instance.ExistsAudioClip(sndPath))
     {
         group.audio.clip = GameDatabase.Instance.GetAudioClip(sndPath);
         return(true);
     }
     else
     {
         KAS_Shared.DebugError("Sound not found in the game database !");
         ScreenMessages.PostScreenMessage(
             string.Format("Sound file : {0} as not been found, please check your KAS installation !",
                           sndPath),
             10, ScreenMessageStyle.UPPER_CENTER);
         return(false);
     }
 }
Beispiel #21
0
        void OnVesselWasModified(Vessel vesselModified)
        {
            if (vesselModified != this.vessel)
            {
                return;
            }

            if (linked)
            {
                if (linkedStrutModule.vessel != this.vessel)
                {
                    if (allowDock)
                    {
                        KAS_Shared.DebugWarning("OnVesselWasModified(strut) Source and target vessel are"
                                                + " different, postponing docking strut... (allowDock = true)");
                        // This callback is invoked while the vessel is being
                        // modified, so any further changes must be postponed.
                        StartCoroutine(WaitAndRedock());
                    }
                    else
                    {
                        KAS_Shared.DebugWarning("OnVesselWasModified(strut) Source and target vessel are"
                                                + " different, unlinking strut... (allowDock = false)");
                        Unlink();
                        fxSndBroke.audio.Play();
                    }
                }
                else if (pumpTo && (!pumpFrom || pumpFrom.State == PartStates.DEAD ||
                                    pumpTo.vessel != pumpFrom.vessel))
                {
                    StopPump();
                }
            }
        }
Beispiel #22
0
        public static void AddNodeTransform(Part p, AttachNode attachNode)
        {
            Quaternion rotation = Quaternion.LookRotation(attachNode.orientation, Vector3.up);

            if (attachNode.nodeType == AttachNode.NodeType.Surface)
            {
                rotation = Quaternion.Inverse(rotation);
            }

            if (attachNode.nodeTransform == null)
            {
                Transform nodeTransform = new GameObject("KASNodeTransf").transform;
                nodeTransform.parent        = p.transform;
                nodeTransform.localPosition = attachNode.position;
                nodeTransform.localRotation = rotation;
                attachNode.nodeTransform    = nodeTransform;
            }
            else
            {
                attachNode.nodeTransform.localPosition = attachNode.position;
                attachNode.nodeTransform.localRotation = rotation;
                KAS_Shared.DebugLog("AddTransformToAttachNode - Node : " + attachNode.id
                                    + " already have a nodeTransform, only update");
            }
        }
Beispiel #23
0
        private void StartPump(bool from_ui)
        {
            StopPump();

            if (!linkedStrutModule || linkedStrutModule.part.vessel != part.vessel)
            {
                if (from_ui)
                {
                    ScreenMessages.PostScreenMessage("Can't pump when not connected to the same vessel!",
                                                     3, ScreenMessageStyle.UPPER_CENTER);
                }
                return;
            }

            Part target = part.srfAttachNode.attachedPart;
            Part source = linkedStrutModule.part.srfAttachNode.attachedPart;

            if (!target || !source)
            {
                if (from_ui)
                {
                    ScreenMessages.PostScreenMessage("Can't pump when an end is dangling!",
                                                     3, ScreenMessageStyle.UPPER_CENTER);
                }
                return;
            }

            pumpTo   = target;
            pumpFrom = source;
            pumpTo.fuelLookupTargets.Add(pumpFrom);
            pumpFuel = true;
            Events["ContextMenuTogglePump"].guiName = "Stop Pumping";
            KAS_Shared.InvalidateContextMenu(this.part);
        }
Beispiel #24
0
        public void Update()
        {
            EditorLogic editor = EditorLogic.fetch;

            if (editor == null)
            {
                return;
            }
            if (editor.editorScreen != EditorLogic.EditorScreen.Parts)
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                Part p = KAS_Shared.GetPartUnderCursor();
                if (p)
                {
                    KASModuleContainer containerModule = p.GetComponent <KASModuleContainer>();
                    if (containerModule)
                    {
                        containerModule.EditContents();
                    }
                }
            }
        }
Beispiel #25
0
 private void Unlink()
 {
     // Unload tube renderer
     if (linkedStrutModule)
     {
         linkedStrutModule.UnlinkPump();
         linkedStrutModule.strutRenderer.UnLoad();
         linkedStrutModule.linked = false;
         linkedStrutModule.Events["ContextMenuUnlink"].guiActiveUnfocused = false;
         linkedStrutModule.Events["ContextMenuLink"].guiActiveUnfocused   = true;
         linkedStrutModule.Events["ContextMenuTogglePump"].active         = false;
         KAS_Shared.InvalidateContextMenu(linkedStrutModule.part);
     }
     this.UnlinkPump();
     this.strutRenderer.UnLoad();
     this.linked      = false;
     tgtStrutPartID   = null;
     tgtStrutVesselID = null;
     this.Events["ContextMenuUnlink"].guiActiveUnfocused = false;
     this.Events["ContextMenuLink"].guiActiveUnfocused   = true;
     this.Events["ContextMenuTogglePump"].active         = false;
     KAS_Shared.InvalidateContextMenu(this.part);
     // Detach parts
     if (linkedStrutModule)
     {
         linkedStrutModule.Detach();
     }
     this.Detach();
     // Clean references
     if (linkedStrutModule)
     {
         linkedStrutModule.linkedStrutModule = null;
     }
     this.linkedStrutModule = null;
 }
Beispiel #26
0
 private void UpdateAttachControl()
 {
     if (KASAddonPointer.isRunning)
     {
         if (
             Input.GetKeyDown(KeyCode.Escape) ||
             Input.GetKeyDown(KeyCode.Space) ||
             Input.GetKeyDown(KeyCode.Mouse1) ||
             Input.GetKeyDown(KeyCode.Mouse2) ||
             Input.GetKeyDown(KeyCode.Return) ||
             Input.GetKeyDown(attachKey.ToLower())
             )
         {
             KAS_Shared.DebugLog("Cancel key pressed, stop eva attach mode");
             KASAddonPointer.StopPointer();
         }
     }
     else if (Input.GetKeyDown(attachKey.ToLower()))
     {
         KASModuleGrab grabbedModule = KAS_Shared.GetGrabbedPartModule(FlightGlobals.ActiveVessel);
         if (grabbedModule)
         {
             if (grabbedModule.attachOnPart || grabbedModule.attachOnEva || grabbedModule.attachOnStatic)
             {
                 KASAddonPointer.StartPointer(grabbedModule.part, KASAddonPointer.PointerMode.MoveAndAttach, grabbedModule.attachOnPart, grabbedModule.attachOnEva, grabbedModule.attachOnStatic, grabbedModule.attachMaxDist, grabbedModule.part.transform, grabbedModule.attachSendMsgOnly);
             }
         }
     }
 }
Beispiel #27
0
        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;
        }
Beispiel #28
0
 private void UpdateRotorControl()
 {
     //negative key pressed
     if (rotorNegativeKey != "")
     {
         if (Input.GetKeyDown(rotorNegativeKey.ToLower()))
         {
             KAS_Shared.SendMsgToRotor("EventRotorNegative", true, vess: FlightGlobals.ActiveVessel);
         }
         if (Input.GetKeyUp(rotorNegativeKey.ToLower()))
         {
             KAS_Shared.SendMsgToRotor("EventRotorNegative", false, vess: FlightGlobals.ActiveVessel);
         }
     }
     //positive key pressed
     if (rotorPositiveKey != "")
     {
         if (Input.GetKeyDown(rotorPositiveKey.ToLower()))
         {
             KAS_Shared.SendMsgToRotor("EventRotorPositive", true, vess: FlightGlobals.ActiveVessel);
         }
         if (Input.GetKeyUp(rotorPositiveKey.ToLower()))
         {
             KAS_Shared.SendMsgToRotor("EventRotorPositive", false, vess: FlightGlobals.ActiveVessel);
         }
     }
 }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor || state == StartState.None)
            {
                return;
            }

            Events["ContextMenuRetract"].guiName = "Retract (" + KASAddonControlKey.telescopicRetractKey + ")";
            Events["ContextMenuExtend"].guiName  = "Extend (" + KASAddonControlKey.telescopicExtendKey + ")";

            KAS_Shared.createFXSound(this.part, fxSndMotorStart, motorStartSndPath, false);
            KAS_Shared.createFXSound(this.part, fxSndMotor, motorSndPath, true);
            KAS_Shared.createFXSound(this.part, fxSndMotorStop, motorStopSndPath, false);
            KAS_Shared.createFXSound(this.part, fxSndSection, sectionSndPath, false);

            LoadSections();

            if (savedSectionsLocalPos.Count > 0)
            {
                KAS_Shared.DebugLog("OnStart(TelescopicArm) - Re-set section position from save");
                foreach (KeyValuePair <int, SectionInfo> section in sections)
                {
                    KAS_Shared.DebugLog("OnStart(TelescopicArm) - Move section " + section.Key + " to local position : " + section.Value.savedLocalPos);
                    section.Value.transform.position = this.part.transform.TransformPoint(section.Value.savedLocalPos);
                }
            }
        }
Beispiel #30
0
 protected override void OnJointBreak(float breakForce)
 {
     KAS_Shared.DebugWarning("OnJointBreak(Strut) A joint broken on " + part.partInfo.title + " !, force: " + breakForce);
     Unlink();
     fxSndBroke.audio.Play();
     base.OnJointBreak(breakForce);
 }