Procházet zdrojové kódy

Implemented importing, it works!

tags/v1.0.0
NorbiPeti před 4 roky
rodič
revize
562cea3d49
Podepsáno: NorbiPeti <szatmari.norbert.peter@gmail.com> ID GPG klíče: DBA4C4549A927E56
4 změnil soubory, kde provedl 79 přidání a 0 odebrání
  1. +11
    -0
      GCMC/Blocks.cs
  2. +56
    -0
      GCMC/CubePlacerEngine.cs
  3. +3
    -0
      GCMC/GCMC.csproj
  4. +9
    -0
      GCMC/Location.cs

+ 11
- 0
GCMC/Blocks.cs Zobrazit soubor

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

+ 56
- 0
GCMC/CubePlacerEngine.cs Zobrazit soubor

@@ -1,6 +1,8 @@
using System;
using System.IO;
using DataLoader;
using GamecraftModdingAPI.Blocks;
using Newtonsoft.Json;
using RobocraftX.Blocks;
using RobocraftX.Blocks.Ghost;
using RobocraftX.Blocks.Scaling;
@@ -31,6 +33,60 @@ namespace GCMC

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)


+ 3
- 0
GCMC/GCMC.csproj Zobrazit soubor

@@ -27,6 +27,9 @@
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>IllusionPlugin.dll</HintPath>
</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">
<HintPath>..\ref\RobocraftX.Blocks.dll</HintPath>
</Reference>


+ 9
- 0
GCMC/Location.cs Zobrazit soubor

@@ -0,0 +1,9 @@
namespace GCMC
{
public struct Location
{
public int X { get; set; }
public int Y { get; set; }
public int Z { get; set; }
}
}

Načítá se…
Zrušit
Uložit