public override void Regenerate()
        {
            float       y           = Altitudes.AltitudeFor(AltitudeLayer.Zone);
            ZoneManager zoneManager = base.Map.zoneManager;
            CellRect    cellRect    = new CellRect(base.section.botLeft.x, base.section.botLeft.z, 17, 17);

            cellRect.ClipInsideMap(base.Map);
            base.ClearSubMeshes(MeshParts.All);
            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    Zone zone = zoneManager.ZoneAt(new IntVec3(i, 0, j));
                    if (zone != null && !zone.hidden)
                    {
                        LayerSubMesh subMesh = base.GetSubMesh(zone.Material);
                        int          count   = subMesh.verts.Count;
                        subMesh.verts.Add(new Vector3((float)i, y, (float)j));
                        subMesh.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                        subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                        subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                        subMesh.tris.Add(count);
                        subMesh.tris.Add(count + 1);
                        subMesh.tris.Add(count + 2);
                        subMesh.tris.Add(count);
                        subMesh.tris.Add(count + 2);
                        subMesh.tris.Add(count + 3);
                    }
                }
            }
            base.FinalizeMesh(MeshParts.Verts | MeshParts.Tris);
        }
예제 #2
0
        public static void MakeBaseGeometry(Section section, LayerSubMesh sm, AltitudeLayer altitudeLayer)
        {
            sm.Clear(MeshParts.Verts | MeshParts.Tris);
            CellRect cellRect = new CellRect(section.botLeft.x, section.botLeft.z, 17, 17);

            cellRect.ClipInsideMap(section.map);
            float y = Altitudes.AltitudeFor(altitudeLayer);

            sm.verts.Capacity = cellRect.Area * 9;
            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    sm.verts.Add(new Vector3((float)i, y, (float)j));
                    sm.verts.Add(new Vector3((float)i, y, (float)((float)j + 0.5)));
                    sm.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)((float)i + 0.5), y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)((float)j + 0.5)));
                    sm.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                    sm.verts.Add(new Vector3((float)((float)i + 0.5), y, (float)j));
                    sm.verts.Add(new Vector3((float)((float)i + 0.5), y, (float)((float)j + 0.5)));
                }
            }
            int num = cellRect.Area * 8 * 3;

            sm.tris.Capacity = num;
            int num2 = 0;

            while (sm.tris.Count < num)
            {
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 2);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 4);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 6);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 1);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 3);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 8);
                sm.tris.Add(num2 + 5);
                sm.tris.Add(num2 + 7);
                sm.tris.Add(num2 + 8);
                num2 += 9;
            }
            sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris);
        }
예제 #3
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.spawnTick     = Find.TickManager.TicksGame;
     this.spawnRealTime = Time.realtimeSinceStartup;
     RealTime.moteList.MoteSpawned(this);
     base.Map.moteCounter.Notify_MoteSpawned();
     this.exactPosition.y = Altitudes.AltitudeFor(base.def.altitudeLayer);
 }
예제 #4
0
 public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
 {
     if (this.shadowMesh != null && thingDef != null && this.shadowInfo != null && (Find.VisibleMap == null || !loc.ToIntVec3().InBounds(Find.VisibleMap) || !Find.VisibleMap.roofGrid.Roofed(loc.ToIntVec3())) && DebugViewSettings.drawShadows)
     {
         Vector3 position = loc + this.shadowInfo.offset;
         position.y = Altitudes.AltitudeFor(AltitudeLayer.Shadows);
         Graphics.DrawMesh(this.shadowMesh, position, rot.AsQuat, MatBases.SunShadowFade, 0);
     }
 }
예제 #5
0
 public static void RenderSpot(Vector3 loc, Material mat, float scale = 0.15f)
 {
     CellRenderer.InitFrame();
     if (CellRenderer.viewRect.Contains(loc.ToIntVec3()))
     {
         loc.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
         Vector3   s      = new Vector3(scale, 1f, scale);
         Matrix4x4 matrix = default(Matrix4x4);
         matrix.SetTRS(loc, Quaternion.identity, s);
         Graphics.DrawMesh(MeshPool.circle, matrix, mat, 0);
     }
 }
예제 #6
0
        public void DebugDraw()
        {
            float   y       = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
            Vector3 vector  = new Vector3((float)this.minX, y, (float)this.minZ);
            Vector3 vector2 = new Vector3((float)this.minX, y, (float)(this.maxZ + 1));
            Vector3 vector3 = new Vector3((float)(this.maxX + 1), y, (float)(this.maxZ + 1));
            Vector3 vector4 = new Vector3((float)(this.maxX + 1), y, (float)this.minZ);

            GenDraw.DrawLineBetween(vector, vector2);
            GenDraw.DrawLineBetween(vector2, vector3);
            GenDraw.DrawLineBetween(vector3, vector4);
            GenDraw.DrawLineBetween(vector4, vector);
        }
예제 #7
0
        private void MakeBaseGeometry(LayerSubMesh sm)
        {
            this.glowGrid = base.Map.glowGrid.glowGrid;
            this.sectRect = new CellRect(base.section.botLeft.x, base.section.botLeft.z, 17, 17);
            this.sectRect.ClipInsideMap(base.Map);
            int   capacity = (this.sectRect.Width + 1) * (this.sectRect.Height + 1) + this.sectRect.Area;
            float y        = Altitudes.AltitudeFor(AltitudeLayer.LightingOverlay);

            sm.verts.Capacity = capacity;
            for (int i = this.sectRect.minZ; i <= this.sectRect.maxZ + 1; i++)
            {
                for (int j = this.sectRect.minX; j <= this.sectRect.maxX + 1; j++)
                {
                    sm.verts.Add(new Vector3((float)j, y, (float)i));
                }
            }
            this.firstCenterInd = sm.verts.Count;
            for (int k = this.sectRect.minZ; k <= this.sectRect.maxZ; k++)
            {
                for (int l = this.sectRect.minX; l <= this.sectRect.maxX; l++)
                {
                    sm.verts.Add(new Vector3((float)((float)l + 0.5), y, (float)((float)k + 0.5)));
                }
            }
            sm.tris.Capacity = this.sectRect.Area * 4 * 3;
            for (int m = this.sectRect.minZ; m <= this.sectRect.maxZ; m++)
            {
                for (int n = this.sectRect.minX; n <= this.sectRect.maxX; n++)
                {
                    int item  = default(int);
                    int item2 = default(int);
                    int item3 = default(int);
                    int item4 = default(int);
                    int item5 = default(int);
                    this.CalculateVertexIndices(n, m, out item, out item2, out item3, out item4, out item5);
                    sm.tris.Add(item);
                    sm.tris.Add(item5);
                    sm.tris.Add(item4);
                    sm.tris.Add(item);
                    sm.tris.Add(item2);
                    sm.tris.Add(item5);
                    sm.tris.Add(item2);
                    sm.tris.Add(item3);
                    sm.tris.Add(item5);
                    sm.tris.Add(item3);
                    sm.tris.Add(item4);
                    sm.tris.Add(item5);
                }
            }
            sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris);
        }
예제 #8
0
        private static void DrawMapEdgeLines(int edgeDist)
        {
            float   y       = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
            IntVec3 size    = Find.VisibleMap.Size;
            Vector3 vector  = new Vector3((float)edgeDist, y, (float)edgeDist);
            Vector3 vector2 = new Vector3((float)edgeDist, y, (float)(size.z - edgeDist));
            Vector3 vector3 = new Vector3((float)(size.x - edgeDist), y, (float)(size.z - edgeDist));
            Vector3 vector4 = new Vector3((float)(size.x - edgeDist), y, (float)edgeDist);

            GenDraw.DrawLineBetween(vector, vector2, GenDraw.LineMatMetaOverlay);
            GenDraw.DrawLineBetween(vector2, vector3, GenDraw.LineMatMetaOverlay);
            GenDraw.DrawLineBetween(vector3, vector4, GenDraw.LineMatMetaOverlay);
            GenDraw.DrawLineBetween(vector4, vector, GenDraw.LineMatMetaOverlay);
        }
예제 #9
0
        protected override Vector3 NextExactPosition(float deltaTime)
        {
            Vector3 vector = base.NextExactPosition(deltaTime);

            if (this.link1.Linked)
            {
                if (!this.link1.Target.ThingDestroyed)
                {
                    this.link1.UpdateDrawPos();
                }
                Vector3 b = this.link1.LastDrawPos - this.attacheeLastPosition;
                vector  += b;
                vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
                this.attacheeLastPosition = this.link1.LastDrawPos;
            }
            return(vector);
        }
예제 #10
0
 public void DrawOverlay(Map map)
 {
     if (this.worldOverlayMat != null)
     {
         Vector3 position = map.Center.ToVector3ShiftedWithAltitude(AltitudeLayer.Weather);
         Graphics.DrawMesh(MeshPool.wholeMapPlane, position, Quaternion.identity, this.worldOverlayMat, 0);
     }
     if (this.screenOverlayMat != null)
     {
         float   num       = Find.Camera.orthographicSize * 2f;
         Vector3 s         = new Vector3(num * Find.Camera.aspect, 1f, num);
         Vector3 position2 = Find.Camera.transform.position;
         position2.y = Altitudes.AltitudeFor(AltitudeLayer.Weather) + 0.046875f;
         Matrix4x4 matrix = default(Matrix4x4);
         matrix.SetTRS(position2, Quaternion.identity, s);
         Graphics.DrawMesh(MeshPool.plane10, matrix, this.screenOverlayMat, 0);
     }
 }
예제 #11
0
        public static void DrawGhostThing(IntVec3 center, Rot4 rot, ThingDef thingDef, Graphic baseGraphic, Color ghostCol, AltitudeLayer drawAltitude)
        {
            if (baseGraphic == null)
            {
                baseGraphic = thingDef.graphic;
            }
            Graphic graphic = GhostDrawer.GhostGraphicFor(baseGraphic, thingDef, ghostCol);
            Vector3 loc     = Gen.TrueCenter(center, rot, thingDef.Size, Altitudes.AltitudeFor(drawAltitude));

            graphic.DrawFromDef(loc, rot, thingDef, 0f);
            if (thingDef.PlaceWorkers != null)
            {
                for (int i = 0; i < thingDef.PlaceWorkers.Count; i++)
                {
                    thingDef.PlaceWorkers[i].DrawGhost(thingDef, center, rot);
                }
            }
        }
예제 #12
0
        public static void DrawArrowPointingAt(Vector3 mapTarget, bool offscreenOnly = false)
        {
            Vector3 vector = UI.UIToMapPosition((float)(UI.screenWidth / 2), (float)(UI.screenHeight / 2));

            if ((vector - mapTarget).MagnitudeHorizontalSquared() < 81f)
            {
                if (!offscreenOnly)
                {
                    Vector3 position = mapTarget;
                    position.y  = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
                    position.z -= 1.5f;
                    Graphics.DrawMesh(MeshPool.plane20, position, Quaternion.identity, GenDraw.ArrowMatWhite, 0);
                }
            }
            else
            {
                Vector3 vector2   = (mapTarget - vector).normalized * 7f;
                Vector3 position2 = vector + vector2;
                position2.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
                Quaternion rotation = Quaternion.LookRotation(vector2);
                Graphics.DrawMesh(MeshPool.plane20, position2, rotation, GenDraw.ArrowMatWhite, 0);
            }
        }
예제 #13
0
        public override void Regenerate()
        {
            if (!MatBases.SunShadow.shader.isSupported)
            {
                return;
            }
            SectionLayer_SunShadows.edificeGrid = base.Map.edificeGrid.InnerArray;
            float    y        = Altitudes.AltitudeFor(AltitudeLayer.Shadows);
            CellRect cellRect = new CellRect(this.section.botLeft.x, this.section.botLeft.z, 17, 17);

            cellRect.ClipInsideMap(base.Map);
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.SunShadow);

            subMesh.Clear(MeshParts.All);
            subMesh.verts.Capacity  = cellRect.Area * 2;
            subMesh.tris.Capacity   = cellRect.Area * 4;
            subMesh.colors.Capacity = cellRect.Area * 2;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    Thing thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i, j)];
                    if (thing != null && thing.def.staticSunShadowHeight > 0f)
                    {
                        float   staticSunShadowHeight = thing.def.staticSunShadowHeight;
                        Color32 item  = new Color32(0, 0, 0, (byte)(255f * staticSunShadowHeight));
                        int     count = subMesh.verts.Count;
                        subMesh.verts.Add(new Vector3((float)i, y, (float)j));
                        subMesh.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                        subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                        subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                        subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor);
                        subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor);
                        subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor);
                        subMesh.colors.Add(SectionLayer_SunShadows.LowVertexColor);
                        int count2 = subMesh.verts.Count;
                        subMesh.tris.Add(count2 - 4);
                        subMesh.tris.Add(count2 - 3);
                        subMesh.tris.Add(count2 - 2);
                        subMesh.tris.Add(count2 - 4);
                        subMesh.tris.Add(count2 - 2);
                        subMesh.tris.Add(count2 - 1);
                        if (i > 0)
                        {
                            thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i - 1, j)];
                            if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight)
                            {
                                int count3 = subMesh.verts.Count;
                                subMesh.verts.Add(new Vector3((float)i, y, (float)j));
                                subMesh.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                                subMesh.colors.Add(item);
                                subMesh.colors.Add(item);
                                subMesh.tris.Add(count + 1);
                                subMesh.tris.Add(count);
                                subMesh.tris.Add(count3);
                                subMesh.tris.Add(count3);
                                subMesh.tris.Add(count3 + 1);
                                subMesh.tris.Add(count + 1);
                            }
                        }
                        if (i < base.Map.Size.x - 1)
                        {
                            thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i + 1, j)];
                            if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight)
                            {
                                int count4 = subMesh.verts.Count;
                                subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                                subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                                subMesh.colors.Add(item);
                                subMesh.colors.Add(item);
                                subMesh.tris.Add(count + 2);
                                subMesh.tris.Add(count4);
                                subMesh.tris.Add(count4 + 1);
                                subMesh.tris.Add(count4 + 1);
                                subMesh.tris.Add(count + 3);
                                subMesh.tris.Add(count + 2);
                            }
                        }
                        if (j > 0)
                        {
                            thing = SectionLayer_SunShadows.edificeGrid[cellIndices.CellToIndex(i, j - 1)];
                            if (thing == null || thing.def.staticSunShadowHeight < staticSunShadowHeight)
                            {
                                int count5 = subMesh.verts.Count;
                                subMesh.verts.Add(new Vector3((float)i, y, (float)j));
                                subMesh.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                                subMesh.colors.Add(item);
                                subMesh.colors.Add(item);
                                subMesh.tris.Add(count);
                                subMesh.tris.Add(count + 3);
                                subMesh.tris.Add(count5);
                                subMesh.tris.Add(count + 3);
                                subMesh.tris.Add(count5 + 1);
                                subMesh.tris.Add(count5);
                            }
                        }
                    }
                }
            }
            if (subMesh.verts.Count > 0)
            {
                subMesh.FinalizeMesh(MeshParts.Verts | MeshParts.Tris | MeshParts.Colors);
                float   num  = Mathf.Max(15f, 15f);
                Vector3 size = subMesh.mesh.bounds.size;
                size.x += 2f * num + 2f;
                size.z += 2f * num + 2f;
                subMesh.mesh.bounds = new Bounds(subMesh.mesh.bounds.center, size);
            }
        }
예제 #14
0
 public override void Draw()
 {
     this.exactPosition.y = Altitudes.AltitudeFor(base.def.altitudeLayer);
     base.Draw();
 }
예제 #15
0
        public override void Regenerate()
        {
            Building[] innerArray = base.Map.edificeGrid.InnerArray;
            float      y          = Altitudes.AltitudeFor(AltitudeLayer.Shadows);
            CellRect   cellRect   = new CellRect(base.section.botLeft.x, base.section.botLeft.z, 17, 17);

            cellRect.ClipInsideMap(base.Map);
            LayerSubMesh sm = base.GetSubMesh(MatBases.EdgeShadow);

            sm.Clear(MeshParts.All);
            sm.verts.Capacity  = cellRect.Area * 4;
            sm.colors.Capacity = cellRect.Area * 4;
            sm.tris.Capacity   = cellRect.Area * 8;
            bool[]      array       = new bool[4];
            bool[]      array2      = new bool[4];
            bool[]      array3      = new bool[4];
            float       num         = 0f;
            float       num2        = 0f;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minX; i <= cellRect.maxX; i++)
            {
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    Thing thing = innerArray[cellIndices.CellToIndex(i, j)];
                    if (thing != null && thing.def.castEdgeShadows)
                    {
                        sm.verts.Add(new Vector3((float)i, y, (float)j));
                        sm.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                        sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                        sm.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                        sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                        sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                        sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                        sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                        int count = sm.verts.Count;
                        sm.tris.Add(count - 4);
                        sm.tris.Add(count - 3);
                        sm.tris.Add(count - 2);
                        sm.tris.Add(count - 4);
                        sm.tris.Add(count - 2);
                        sm.tris.Add(count - 1);
                    }
                    else
                    {
                        array[0]  = false;
                        array[1]  = false;
                        array[2]  = false;
                        array[3]  = false;
                        array2[0] = false;
                        array2[1] = false;
                        array2[2] = false;
                        array2[3] = false;
                        array3[0] = false;
                        array3[1] = false;
                        array3[2] = false;
                        array3[3] = false;
                        IntVec3   a = new IntVec3(i, 0, j);
                        IntVec3[] cardinalDirectionsAround = GenAdj.CardinalDirectionsAround;
                        for (int k = 0; k < 4; k++)
                        {
                            IntVec3 c = a + cardinalDirectionsAround[k];
                            if (c.InBounds(base.Map))
                            {
                                thing = innerArray[cellIndices.CellToIndex(c)];
                                if (thing != null && thing.def.castEdgeShadows)
                                {
                                    array2[k]          = true;
                                    array[(k + 3) % 4] = true;
                                    array[k]           = true;
                                }
                            }
                        }
                        IntVec3[] diagonalDirectionsAround = GenAdj.DiagonalDirectionsAround;
                        for (int l = 0; l < 4; l++)
                        {
                            if (!array[l])
                            {
                                IntVec3 c = a + diagonalDirectionsAround[l];
                                if (c.InBounds(base.Map))
                                {
                                    thing = innerArray[cellIndices.CellToIndex(c)];
                                    if (thing != null && thing.def.castEdgeShadows)
                                    {
                                        array[l]  = true;
                                        array3[l] = true;
                                    }
                                }
                            }
                        }
                        Action <int> action = delegate(int idx)
                        {
                            sm.tris.Add(sm.verts.Count - 2);
                            sm.tris.Add(idx);
                            sm.tris.Add(sm.verts.Count - 1);
                            sm.tris.Add(sm.verts.Count - 1);
                            sm.tris.Add(idx);
                            sm.tris.Add(idx + 1);
                        };
                        Action action2 = delegate
                        {
                            sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                            sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                            sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                            sm.tris.Add(sm.verts.Count - 3);
                            sm.tris.Add(sm.verts.Count - 2);
                            sm.tris.Add(sm.verts.Count - 1);
                        };
                        int count2 = sm.verts.Count;
                        if (array[0])
                        {
                            if (array2[0] || array2[1])
                            {
                                num = (num2 = 0f);
                                if (array2[0])
                                {
                                    num2 = 0.45f;
                                }
                                if (array2[1])
                                {
                                    num = 0.45f;
                                }
                                sm.verts.Add(new Vector3((float)i, y, (float)j));
                                sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                                sm.verts.Add(new Vector3((float)i + num, y, (float)j + num2));
                                sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                                if (array[1] && !array3[1])
                                {
                                    action(sm.verts.Count);
                                }
                            }
                            else
                            {
                                sm.verts.Add(new Vector3((float)i, y, (float)j));
                                sm.verts.Add(new Vector3((float)i, y, (float)((float)j + 0.44999998807907104)));
                                sm.verts.Add(new Vector3((float)((float)i + 0.44999998807907104), y, (float)j));
                                action2();
                            }
                        }
                        if (array[1])
                        {
                            if (array2[1] || array2[2])
                            {
                                num = (num2 = 0f);
                                if (array2[1])
                                {
                                    num = 0.45f;
                                }
                                if (array2[2])
                                {
                                    num2 = -0.45f;
                                }
                                sm.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                                sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                                sm.verts.Add(new Vector3((float)i + num, y, (float)(j + 1) + num2));
                                sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                                if (array[2] && !array3[2])
                                {
                                    action(sm.verts.Count);
                                }
                            }
                            else
                            {
                                sm.verts.Add(new Vector3((float)i, y, (float)(j + 1)));
                                sm.verts.Add(new Vector3((float)((float)i + 0.44999998807907104), y, (float)(j + 1)));
                                sm.verts.Add(new Vector3((float)i, y, (float)((float)(j + 1) - 0.44999998807907104)));
                                action2();
                            }
                        }
                        if (array[2])
                        {
                            if (array2[2] || array2[3])
                            {
                                num = (num2 = 0f);
                                if (array2[2])
                                {
                                    num2 = -0.45f;
                                }
                                if (array2[3])
                                {
                                    num = -0.45f;
                                }
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                                sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                                sm.verts.Add(new Vector3((float)(i + 1) + num, y, (float)(j + 1) + num2));
                                sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                                if (array[3] && !array3[3])
                                {
                                    action(sm.verts.Count);
                                }
                            }
                            else
                            {
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)(j + 1)));
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)((float)(j + 1) - 0.44999998807907104)));
                                sm.verts.Add(new Vector3((float)((float)(i + 1) - 0.44999998807907104), y, (float)(j + 1)));
                                action2();
                            }
                        }
                        if (array[3])
                        {
                            if (array2[3] || array2[0])
                            {
                                num = (num2 = 0f);
                                if (array2[3])
                                {
                                    num = -0.45f;
                                }
                                if (array2[0])
                                {
                                    num2 = 0.45f;
                                }
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                                sm.colors.Add(SectionLayer_EdgeShadows.Shadowed);
                                sm.verts.Add(new Vector3((float)(i + 1) + num, y, (float)j + num2));
                                sm.colors.Add(SectionLayer_EdgeShadows.Lit);
                                if (array[0] && !array3[0])
                                {
                                    action(count2);
                                }
                            }
                            else
                            {
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)j));
                                sm.verts.Add(new Vector3((float)((float)(i + 1) - 0.44999998807907104), y, (float)j));
                                sm.verts.Add(new Vector3((float)(i + 1), y, (float)((float)j + 0.44999998807907104)));
                                action2();
                            }
                        }
                    }
                }
            }
            if (sm.verts.Count > 0)
            {
                sm.FinalizeMesh(MeshParts.Verts | MeshParts.Tris | MeshParts.Colors);
            }
        }
예제 #16
0
 public void RenderPawnAt(Vector3 drawLoc, RotDrawMode bodyDrawType, bool headStump)
 {
     if (!this.graphics.AllResolved)
     {
         this.graphics.ResolveAllGraphics();
     }
     if (this.pawn.GetPosture() == PawnPosture.Standing)
     {
         this.RenderPawnInternal(drawLoc, Quaternion.identity, true, bodyDrawType, headStump);
         if (this.pawn.carryTracker != null)
         {
             Thing carriedThing = this.pawn.carryTracker.CarriedThing;
             if (carriedThing != null)
             {
                 Vector3 vector = drawLoc;
                 bool    flag   = false;
                 bool    flip   = false;
                 if (this.pawn.CurJob == null || !this.pawn.jobs.curDriver.ModifyCarriedThingDrawPos(ref vector, ref flag, ref flip))
                 {
                     if (carriedThing is Pawn || carriedThing is Corpse)
                     {
                         vector += new Vector3(0.44f, 0f, 0f);
                     }
                     else
                     {
                         vector += new Vector3(0.18f, 0f, 0.05f);
                     }
                 }
                 if (flag)
                 {
                     vector.y -= 0.0390625f;
                 }
                 else
                 {
                     vector.y += 0.0390625f;
                 }
                 carriedThing.DrawAt(vector, flip);
             }
         }
         if (this.pawn.def.race.specialShadowData != null)
         {
             if (this.shadowGraphic == null)
             {
                 this.shadowGraphic = new Graphic_Shadow(this.pawn.def.race.specialShadowData);
             }
             this.shadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f);
         }
         if (this.graphics.nakedGraphic != null && this.graphics.nakedGraphic.ShadowGraphic != null)
         {
             this.graphics.nakedGraphic.ShadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f);
         }
     }
     else
     {
         Rot4         rot          = this.LayingFacing();
         Building_Bed building_Bed = this.pawn.CurrentBed();
         bool         renderBody;
         Quaternion   quat;
         Vector3      rootLoc;
         if (building_Bed != null && this.pawn.RaceProps.Humanlike)
         {
             renderBody = building_Bed.def.building.bed_showSleeperBody;
             Rot4 rotation = building_Bed.Rotation;
             rotation.AsInt += 2;
             quat            = rotation.AsQuat;
             AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 15);
             Vector3       vector2  = this.pawn.Position.ToVector3ShiftedWithAltitude(altLayer);
             Vector3       vector3  = vector2;
             vector3.y += 0.02734375f;
             float   d = -this.BaseHeadOffsetAt(Rot4.South).z;
             Vector3 a = rotation.FacingCell.ToVector3();
             rootLoc    = vector2 + a * d;
             rootLoc.y += 0.0078125f;
         }
         else
         {
             renderBody = true;
             rootLoc    = drawLoc;
             if (!this.pawn.Dead && this.pawn.CarriedBy == null)
             {
                 rootLoc.y = Altitudes.AltitudeFor(AltitudeLayer.LayingPawn) + 0.0078125f;
             }
             if (this.pawn.Downed || this.pawn.Dead)
             {
                 quat = Quaternion.AngleAxis(this.wiggler.downedAngle, Vector3.up);
             }
             else if (this.pawn.RaceProps.Humanlike)
             {
                 quat = rot.AsQuat;
             }
             else
             {
                 Rot4 rot2 = Rot4.West;
                 int  num  = this.pawn.thingIDNumber % 2;
                 if (num != 0)
                 {
                     if (num == 1)
                     {
                         rot2 = Rot4.East;
                     }
                 }
                 else
                 {
                     rot2 = Rot4.West;
                 }
                 quat = rot2.AsQuat;
             }
         }
         this.RenderPawnInternal(rootLoc, quat, renderBody, rot, rot, bodyDrawType, false, headStump);
     }
     if (this.pawn.Spawned && !this.pawn.Dead)
     {
         this.pawn.stances.StanceTrackerDraw();
         this.pawn.pather.PatherDraw();
     }
     this.DrawDebug();
 }
        public void RegenerateMesh()
        {
            for (int i = 0; i < this.meshes.Count; i++)
            {
                this.meshes[i].Clear();
            }
            int num  = 0;
            int num2 = 0;

            if (this.meshes.Count < num + 1)
            {
                Mesh mesh = new Mesh();
                mesh.name = "CellBoolDrawer";
                this.meshes.Add(mesh);
            }
            Mesh     mesh2    = this.meshes[num];
            CellRect cellRect = new CellRect(0, 0, this.mapSizeX, this.mapSizeZ);
            float    y        = Altitudes.AltitudeFor(AltitudeLayer.MapDataOverlay);
            bool     careAboutVertexColors = false;

            for (int j = cellRect.minX; j <= cellRect.maxX; j++)
            {
                for (int k = cellRect.minZ; k <= cellRect.maxZ; k++)
                {
                    int index = CellIndicesUtility.CellToIndex(j, k, this.mapSizeX);
                    if (this.giver.GetCellBool(index))
                    {
                        CellBoolDrawer.verts.Add(new Vector3((float)j, y, (float)k));
                        CellBoolDrawer.verts.Add(new Vector3((float)j, y, (float)(k + 1)));
                        CellBoolDrawer.verts.Add(new Vector3((float)(j + 1), y, (float)(k + 1)));
                        CellBoolDrawer.verts.Add(new Vector3((float)(j + 1), y, (float)k));
                        Color cellExtraColor = this.giver.GetCellExtraColor(index);
                        CellBoolDrawer.colors.Add(cellExtraColor);
                        CellBoolDrawer.colors.Add(cellExtraColor);
                        CellBoolDrawer.colors.Add(cellExtraColor);
                        CellBoolDrawer.colors.Add(cellExtraColor);
                        if (cellExtraColor != Color.white)
                        {
                            careAboutVertexColors = true;
                        }
                        int count = CellBoolDrawer.verts.Count;
                        CellBoolDrawer.tris.Add(count - 4);
                        CellBoolDrawer.tris.Add(count - 3);
                        CellBoolDrawer.tris.Add(count - 2);
                        CellBoolDrawer.tris.Add(count - 4);
                        CellBoolDrawer.tris.Add(count - 2);
                        CellBoolDrawer.tris.Add(count - 1);
                        num2++;
                        if (num2 >= 16383)
                        {
                            this.FinalizeWorkingDataIntoMesh(mesh2);
                            num++;
                            if (this.meshes.Count < num + 1)
                            {
                                Mesh mesh3 = new Mesh();
                                mesh3.name = "CellBoolDrawer";
                                this.meshes.Add(mesh3);
                            }
                            mesh2 = this.meshes[num];
                            num2  = 0;
                        }
                    }
                }
            }
            this.FinalizeWorkingDataIntoMesh(mesh2);
            this.CreateMaterialIfNeeded(careAboutVertexColors);
            this.dirty = false;
        }
예제 #18
0
 public Vector3 ToVector3ShiftedWithAltitude(AltitudeLayer AltLayer)
 {
     return(this.ToVector3ShiftedWithAltitude(Altitudes.AltitudeFor(AltLayer)));
 }
예제 #19
0
        public override void Regenerate()
        {
            if (MatBases.SunShadow.shader.isSupported)
            {
                LayerSubMesh subMesh = base.GetSubMesh(MatBases.IndoorMask);
                subMesh.Clear(MeshParts.All);
                Building[] innerArray = base.Map.edificeGrid.InnerArray;
                CellRect   cellRect   = new CellRect(base.section.botLeft.x, base.section.botLeft.z, 17, 17);
                cellRect.ClipInsideMap(base.Map);
                subMesh.verts.Capacity = cellRect.Area * 2;
                subMesh.tris.Capacity  = cellRect.Area * 4;
                float       y           = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
                CellIndices cellIndices = base.Map.cellIndices;
                for (int i = cellRect.minX; i <= cellRect.maxX; i++)
                {
                    for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                    {
                        IntVec3 intVec = new IntVec3(i, 0, j);
                        if (!this.HideRainPrimary(intVec))
                        {
                            bool flag  = intVec.Roofed(base.Map);
                            bool flag2 = false;
                            if (flag)
                            {
                                for (int k = 0; k < 8; k++)
                                {
                                    IntVec3 c = intVec + GenAdj.AdjacentCells[k];
                                    if (c.InBounds(base.Map) && this.HideRainPrimary(c))
                                    {
                                        flag2 = true;
                                        break;
                                    }
                                }
                            }
                            if (flag && flag2)
                            {
                                goto IL_016e;
                            }
                            continue;
                        }
                        goto IL_016e;
IL_016e:
                        Thing thing = innerArray[cellIndices.CellToIndex(i, j)];
                        float num = (float)((thing == null || (thing.def.passability != Traversability.Impassable && !thing.def.IsDoor)) ? 0.15999999642372131 : 0.0);
                        subMesh.verts.Add(new Vector3((float)i - num, y, (float)j - num));
                        subMesh.verts.Add(new Vector3((float)i - num, y, (float)(j + 1) + num));
                        subMesh.verts.Add(new Vector3((float)(i + 1) + num, y, (float)(j + 1) + num));
                        subMesh.verts.Add(new Vector3((float)(i + 1) + num, y, (float)j - num));
                        int count = subMesh.verts.Count;
                        subMesh.tris.Add(count - 4);
                        subMesh.tris.Add(count - 3);
                        subMesh.tris.Add(count - 2);
                        subMesh.tris.Add(count - 4);
                        subMesh.tris.Add(count - 2);
                        subMesh.tris.Add(count - 1);
                    }
                }
                if (subMesh.verts.Count > 0)
                {
                    subMesh.FinalizeMesh(MeshParts.Verts | MeshParts.Tris);
                }
            }
        }