Ejemplo n.º 1
0
        public override void DrawAt(Vector3 drawLoc)
        {
            if (!Spawned)
            {
                base.DrawAt(drawLoc);
                return;
            }

            wheelLoc = drawLoc;
            bodyLoc  = drawLoc;
            //Vertical
            if (Rotation.AsInt % 2 == 0)
            {
                wheelLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Item) + 0.02f;
            }

            //horizontal
            if (axlesComp.HasAxles() && Rotation.AsInt % 2 == 1)
            {
                wheelLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.04f;
                bodyLoc.y  = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.03f;

                Vector2    drawSize = def.graphic.drawSize;
                int        num      = Rotation == Rot4.West ? -1 : 1;
                Vector3    vector3  = new Vector3(1f * drawSize.x, 1f, 1f * drawSize.y);
                Quaternion asQuat   = Rotation.AsQuat;
                float      x        = 1f * Mathf.Sin(num * (wheelRotation * 0.05f) % (2 * Mathf.PI));
                float      z        = 1f * Mathf.Cos(num * (wheelRotation * 0.05f) % (2 * Mathf.PI));

                asQuat.SetLookRotation(new Vector3(x, 0f, z), Vector3.up);

                wheel_shake = (float)((Math.Sin(tick_time) + Math.Abs(Math.Sin(tick_time))) / 40.0);

                wheelLoc.z = wheelLoc.z + wheel_shake;

                Vector3 mountThingLoc = drawLoc;
                mountThingLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.06f;
                Vector3 mountThingOffset = new Vector3(0, 0, 1).RotatedBy(Rotation.AsAngle);

                List <Vector3> list;
                if (axlesComp.GetAxleLocations(drawSize, num, out list))
                {
                    foreach (Vector3 current in list)
                    {
                        Matrix4x4 matrix = default(Matrix4x4);
                        matrix.SetTRS(wheelLoc + current, asQuat, vector3);
                        Graphics.DrawMesh(MeshPool.plane10, matrix, graphic_Wheel_Single.MatAt(Rotation), 0);
                    }
                }
            }
            base.DrawAt(bodyLoc);

            if (vehicleComp.compProps.specialShadowData != null)
            {
                if (shadowGraphic == null)
                {
                    shadowGraphic = new Graphic_Shadow(vehicleComp.compProps.specialShadowData);
                }
                shadowGraphic.Draw(drawLoc, Rot4.North, this);
            }
        }