Esempio n. 1
0
        public override void OnStart(PartModule.StartState state)
        {
            print(new StackTrace(true).GetFrame(0).GetFileLineNumber());
            this.part.force_activate();
            this.angleStart = this.angle;
            InitializeStatic(this.angle);
            if (this.part.parent)
            {
                this.parentAxis = this.part.parent.transform.InverseTransformDirection(this.transform.TransformDirection(this.axis));
                this.parentDir  = this.part.parent.transform.InverseTransformDirection(this.transform.TransformDirection(KRSUtils.VectorSwap(this.axis)));
            }

            if (this.isFixed)
            {
                SetTargetAngle(this.angle);
            }
        }
Esempio n. 2
0
        private void CalcAngle()
        {
            /// Calculate angle base upon the difference of the previous parentDir and current.
            /// parentDir is the direction of a vector perpendicular to the axis relative to the parent of this part
            var vdir  = this.part.parent.transform.InverseTransformDirection(this.transform.TransformDirection(KRSUtils.VectorSwap(this.axis)));
            var delta = -KRSUtils.VectorSignedAngle(vdir, parentDir, parentAxis);

            this.angle = KRSUtils.Wrap(this.angleStart + delta, -180f, 179.999f);
        }