Schematics should work on Mac now
This commit is contained in:
1 parent
a545f0ec11
commit
eb63d58101
9 files changed
+21
-11
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
using CalamityMod.Schematics.AutoGeneratedContent;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,13 +7,24 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader.IO;
|
||||
|
||||
using SystemDrawing = System.Drawing;
|
||||
|
||||
namespace CalamityMod.Schematics
|
||||
{
|
||||
[Serializable]
|
||||
public struct SerializableColor
|
||||
{
|
||||
internal byte Red;
|
||||
internal byte Green;
|
||||
internal byte Blue;
|
||||
internal byte Alpha;
|
||||
public SerializableColor(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
Red = r;
|
||||
Green = g;
|
||||
Blue = b;
|
||||
Alpha = a;
|
||||
}
|
||||
}
|
||||
public static class SchematicLoader
|
||||
{
|
||||
#region Fields
|
||||
@@ -73,16 +83,16 @@ namespace CalamityMod.Schematics
|
||||
|
||||
Stream schematicStream = CalamityMod.Instance.GetFileStream(schematicPath + ".sch", true);
|
||||
|
||||
var systemImage = (SystemDrawing.Bitmap)new BinaryFormatter().Deserialize(schematicStream);
|
||||
var systemImage = (SerializableColor[,])new BinaryFormatter().Deserialize(schematicStream);
|
||||
|
||||
ColorTileCombination[,] schematic = new ColorTileCombination[systemImage.Width, systemImage.Height];
|
||||
ColorTileCombination[,] schematic = new ColorTileCombination[systemImage.GetLength(0), systemImage.GetLength(1)];
|
||||
|
||||
for (int x = 0; x < systemImage.Width; x++)
|
||||
for (int x = 0; x < systemImage.GetLength(0); x++)
|
||||
{
|
||||
for (int y = 0; y < systemImage.Height; y++)
|
||||
for (int y = 0; y < systemImage.GetLength(1); y++)
|
||||
{
|
||||
var systemColor = systemImage.GetPixel(x, y);
|
||||
Color xnaColor = new Color(systemColor.R, systemColor.G, systemColor.B, systemColor.A);
|
||||
var systemColor = systemImage[x, y];
|
||||
Color xnaColor = new Color(systemColor.Red, systemColor.Green, systemColor.Blue, systemColor.Alpha);
|
||||
schematic[x, y] = new ColorTileCombination(xnaColor, map[xnaColor].SpecifiedTile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user