Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
 private void LoadShaders()
 {
     foreach (var shaderFilename in Shaders)
     {
         try
         {
             var mat = new Material(KRSUtils.GetResourceString(shaderFilename));
             Materials[mat.shader.name] = mat;
         }
         catch
         {
             MonoBehaviour.print("[ERROR] " + this.GetType().Name + " : Failed to load " + shaderFilename);
         }
     }
 }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private Func <Part, bool> CanApplyIfType(string typeName)
        {
            var type = KRSUtils.FindType(typeName);

            return((p) => type.IsInstanceOfType(p));
        }