Implemented importing, it works!
This commit is contained in:
parent
b05197fa36
commit
562cea3d49
4 changed files with 79 additions and 0 deletions
11
GCMC/Blocks.cs
Normal file
11
GCMC/Blocks.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using Unity.Mathematics;
|
||||||
|
|
||||||
|
namespace GCMC
|
||||||
|
{
|
||||||
|
public struct Blocks
|
||||||
|
{
|
||||||
|
public float3 Start { get; set; }
|
||||||
|
public float3 End { get; set; }
|
||||||
|
public string Material { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using DataLoader;
|
using DataLoader;
|
||||||
using GamecraftModdingAPI.Blocks;
|
using GamecraftModdingAPI.Blocks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using RobocraftX.Blocks;
|
using RobocraftX.Blocks;
|
||||||
using RobocraftX.Blocks.Ghost;
|
using RobocraftX.Blocks.Ghost;
|
||||||
using RobocraftX.Blocks.Scaling;
|
using RobocraftX.Blocks.Scaling;
|
||||||
|
@ -31,6 +33,60 @@ namespace GCMC
|
||||||
|
|
||||||
private void ImportWorld(string name)
|
private void ImportWorld(string name)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log.Output("Starting...");
|
||||||
|
var blocksArray = JsonSerializer.Create()
|
||||||
|
.Deserialize<Blocks[]>(new JsonTextReader(File.OpenText(name)));
|
||||||
|
int C = 0;
|
||||||
|
foreach (var blocks in blocksArray)
|
||||||
|
{
|
||||||
|
BlockIDs id;
|
||||||
|
BlockColors color;
|
||||||
|
byte darkness = 0;
|
||||||
|
switch (blocks.Material)
|
||||||
|
{
|
||||||
|
case "DIRT":
|
||||||
|
id = BlockIDs.DirtCube;
|
||||||
|
color = BlockColors.Default;
|
||||||
|
break;
|
||||||
|
case "GRASS":
|
||||||
|
id = BlockIDs.GrassCube;
|
||||||
|
color = BlockColors.Default;
|
||||||
|
break;
|
||||||
|
case "STONE":
|
||||||
|
id = BlockIDs.ConcreteCube;
|
||||||
|
color = BlockColors.White;
|
||||||
|
darkness = 5;
|
||||||
|
break;
|
||||||
|
case "LEAVES":
|
||||||
|
id = BlockIDs.AluminiumCube;
|
||||||
|
color = BlockColors.Green;
|
||||||
|
darkness = 5;
|
||||||
|
break;
|
||||||
|
case "AIR":
|
||||||
|
continue;
|
||||||
|
case "LOG":
|
||||||
|
id = BlockIDs.WoodCube;
|
||||||
|
color = BlockColors.Default;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.Output("Unknown block: " + blocks.Material);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Placement.PlaceBlock(id, (blocks.Start + blocks.End) / 2, color: color, darkness: darkness,
|
||||||
|
scale: (blocks.End - blocks.Start + 1) * 5, rotation: quaternion.identity);
|
||||||
|
C++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Output(C + " blocks placed.");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
Log.Error(e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlaceBlock(string args)
|
private void PlaceBlock(string args)
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>IllusionPlugin.dll</HintPath>
|
<HintPath>IllusionPlugin.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net48\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
<Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
<HintPath>..\ref\RobocraftX.Blocks.dll</HintPath>
|
<HintPath>..\ref\RobocraftX.Blocks.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
9
GCMC/Location.cs
Normal file
9
GCMC/Location.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace GCMC
|
||||||
|
{
|
||||||
|
public struct Location
|
||||||
|
{
|
||||||
|
public int X { get; set; }
|
||||||
|
public int Y { get; set; }
|
||||||
|
public int Z { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue