Esempio n. 1
0
        public void DrawWorkerAnimated(Vector3 loc, Rot4 rot, int index, float extraRotation, bool rotatePoints = false)
        {
            Mesh       mesh       = MeshAt(rot);
            Vector3    newLoc     = loc;
            Quaternion quaternion = QuatFromRot(rot);

            if (extraRotation != 0f)
            {
                quaternion *= Quaternion.Euler(Vector3.up * extraRotation);
            }
            Vector3 offset = DrawOffset(rot);

            if (rotatePoints && extraRotation != 0)
            {
                offset = Ext_Math.RotatePoint(offset, Vector3.zero, extraRotation);
            }
            newLoc += offset;

            Material mat = SubGraphicForIndex(index).MatSingle;

            DrawMeshInt(mesh, newLoc, quaternion, mat);
            if (ShadowGraphic != null)
            {
                ShadowGraphic.DrawWorker(newLoc, rot, null, null, extraRotation);
            }
        }
        public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
        {
            if (baseData == null)
            {
                base.DrawWorker(loc, rot, thingDef, thing, extraRotation);
                return;
            }

            var useFrontBase = !thing.Rotation.IsHorizontal;
            var baseOffset   = new Vector3(baseData.baseOffset.x, 0, baseData.baseOffset.y - (thing.RotatedSize.z - 1) / 2f);
            var baseMat      = useFrontBase ? baseMatFront : baseMatSide;
            var baseMesh     = MeshPool.GridPlane(new Vector2(thing.RotatedSize.x, 1));

            Graphics.DrawMesh(baseMesh, loc + baseOffset, Quaternion.identity, baseMat, 0);

            var mesh     = MeshAt(rot);
            var rotation = QuatFromRot(rot);
            var material = MatAt(rot, thing);

            Graphics.DrawMesh(mesh, loc, rotation, material, 0);
            if (ShadowGraphic != null)
            {
                ShadowGraphic.DrawWorker(loc, rot, thingDef, thing, extraRotation);
            }
        }
Esempio n. 3
0
        public virtual void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
        {
            Mesh       mesh = MeshAt(rot);
            Quaternion quat = QuatFromRot(rot);

            if (extraRotation != 0f)
            {
                quat *= Quaternion.Euler(Vector3.up * extraRotation);
            }
            loc += DrawOffset(rot);
            Material mat = MatAt(rot, thing);

            DrawMeshInt(mesh, loc, quat, mat);
            if (ShadowGraphic != null)
            {
                ShadowGraphic.DrawWorker(loc, rot, thingDef, thing, extraRotation);
            }
        }
        public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
        {
            var      blob            = (Building_FoamBlob)thing;
            var      scaleMultiplier = blob.spriteScaleMultiplier;
            var      meshScale       = new Vector2(drawSize.x * scaleMultiplier.x, drawSize.y * scaleMultiplier.y);
            Material material        = thing.Graphic.MatAt(thing.Rotation, thing);

            Matrix4x4 matrix = default(Matrix4x4);

            var drawPos        = thing.DrawPos;
            var customAltitude = Altitudes.AltitudeFor(thing.def.altitudeLayer) + Altitudes.AltInc * (thing.Map.Size.z - thing.Position.z);

            matrix.SetTRS(new Vector3(drawPos.x, customAltitude, drawPos.z), rot.AsQuat, new Vector3(meshScale.x, 0, meshScale.y));
            Graphics.DrawMesh(MeshPool.plane10, matrix, material, 0);

            if (ShadowGraphic != null)
            {
                ShadowGraphic.DrawWorker(thing.Position.ToVector3(), thing.Rotation, thing.def, thing, extraRotation);
            }
        }