Example #1
0
    public override void OnSave(ConfigNode node)
    {
        base.OnSave(node);

        Save(node.AddNode("ATTACHED_PART_INFOS"), attachedPartInfos);

        if (debug)
        {
            printf("Save: %s", node);
        }

        // Save original positions when saving the ship.
        // Don't do it at the save occuring at initial scene start.
        if (flightState == State.STARTED)
        {
            //SetOriginalPositions();
            AnimatedAttachmentUpdater.UpdateOriginalPositions();
        }
    }
Example #2
0
    void FixedUpdate()
    {
        bool isMoving = AnyAnimationMoving();

        if (isMoving == wasMoving)
        {
            return;
        }
        wasMoving = isMoving;

        printf(isMoving ? "Started moving" : "Stopped moving");

        List <Part> parts = AnimatedAttachmentUpdater.GetParts();

        if (isMoving)
        {
            partInfos = new PartInfo[parts.Count];

            // If any part is moving, we need to de-strut any wheels
            foreach (Part part in parts)
            {
                // Ignore parts that don't have struting
                if (part.autoStrutMode == Part.AutoStrutMode.Off)
                {
                    continue;
                }

                // Create a record to keep track of the part and the current mode
                PartInfo partInfo = new PartInfo();
                partInfos[parts.IndexOf(part)] = partInfo;

                partInfo.part          = part;
                partInfo.autoStrutMode = part.autoStrutMode;

                printf("Changing auto strut of %s from %s to %s",
                       part.name,
                       part.autoStrutMode,
                       Part.AutoStrutMode.Off);

                // Remove the struting
                part.autoStrutMode = Part.AutoStrutMode.Off;
                part.ReleaseAutoStruts();
            }
        }
        else
        {
            // Go through our list of de-strutted parts and put their original strutting back again
            foreach (PartInfo partInfo in partInfos)
            {
                if (partInfo == null)
                {
                    continue;
                }

                printf("Changing auto strut of %s from %s to %s",
                       partInfo.part.name,
                       partInfo.part.autoStrutMode,
                       partInfo.autoStrutMode);

                // Bring struty back
                partInfo.part.autoStrutMode = partInfo.autoStrutMode;
            }
        }
    }