Example #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;

                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);
                    }
                }
            }

            if (vehicleComp.ShowsStorage())
            {
                if (storage.Any())
                {
                    Vector3 mountThingLoc = drawLoc;
                    if (Rotation.AsInt % 2 == 1)
                    {
                        mountThingLoc.y  = Altitudes.AltitudeFor(AltitudeLayer.LayingPawn); // horizontal
                        mountThingLoc.z += 0.1f;
                    }
                    else
                    {
                        mountThingLoc.y = Altitudes.AltitudeFor(AltitudeLayer.Pawn) + 0.07f; // vertical
                    }
                    Vector3 mountThingOffset = (-0.3f * def.interactionCellOffset.ToVector3()).RotatedBy(Rotation.AsAngle);

                    foreach (Thing mountThing in storage)
                    {
                        mountThing.Rotation = Rotation;
                        mountThing.DrawAt(mountThingLoc + mountThingOffset);

                        //Pawn p = (Pawn)mountThing;
                        //p.ExposeData();
                        //p.Rotation = Rotation;
                        //p.DrawAt(mountThingLoc + mountThingOffset);
                        //p.DrawGUIOverlay();
                    }
                }
            }


            base.DrawAt(bodyLoc);

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