|
|
@@ -1,21 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using DataLoader; |
|
|
|
using GamecraftModdingAPI; |
|
|
|
using GamecraftModdingAPI.Blocks; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using RobocraftX.Blocks; |
|
|
|
using RobocraftX.Blocks.Ghost; |
|
|
|
using RobocraftX.Blocks.Scaling; |
|
|
|
using RobocraftX.Character; |
|
|
|
using RobocraftX.CommandLine.Custom; |
|
|
|
using RobocraftX.Common; |
|
|
|
using RobocraftX.Common.Input; |
|
|
|
using RobocraftX.Common.Utilities; |
|
|
|
using RobocraftX.CR.MachineEditing; |
|
|
|
using RobocraftX.StateSync; |
|
|
|
using Svelto.ECS; |
|
|
|
using Svelto.ECS.EntityStructs; |
|
|
|
using Unity.Jobs; |
|
|
|
using Unity.Mathematics; |
|
|
|
using uREPL; |
|
|
@@ -35,77 +27,69 @@ namespace GCMC |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
Log.Output("Reading block mappings..."); |
|
|
|
var parser = new IniParser.FileIniDataParser(); |
|
|
|
var ini = parser.ReadFile("BlockTypes.ini"); |
|
|
|
var mapping = new Dictionary<string, BlockType>(10); |
|
|
|
foreach (var section in ini.Sections) |
|
|
|
{ |
|
|
|
var mcblocks = section.SectionName.Split(','); |
|
|
|
if (section.Keys["type"] == null) |
|
|
|
{ |
|
|
|
if (section.Keys["ignore"] != "true") |
|
|
|
Log.Warn("Block type not specified for " + section.SectionName); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (!Enum.TryParse(section.Keys["type"], out BlockIDs type)) |
|
|
|
{ |
|
|
|
Log.Warn("Block type specified in ini not found: " + section.Keys["type"]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
BlockColors color; |
|
|
|
if (section.Keys["color"] == null) |
|
|
|
color = BlockColors.Default; |
|
|
|
else if (!Enum.TryParse(section.Keys["color"], out color)) |
|
|
|
{ |
|
|
|
Log.Warn("Block color specified in ini not found: " + section.Keys["color"]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
byte darkness; |
|
|
|
if (section.Keys["darkness"] == null) |
|
|
|
darkness = 0; |
|
|
|
else if (!byte.TryParse(section.Keys["darkness"], out darkness) || darkness > 9) |
|
|
|
{ |
|
|
|
Log.Warn("Block darkness specified in ini isn't a number between 0 and 9: " + |
|
|
|
section.Keys["darkness"]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var mcblock in mcblocks) |
|
|
|
{ |
|
|
|
mapping.Add(mcblock.ToUpper(), new BlockType |
|
|
|
{ |
|
|
|
Material = mcblock.ToUpper(), |
|
|
|
Type = type, |
|
|
|
Color = new BlockColor {Color = color, Darkness = darkness} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
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) |
|
|
|
if (!mapping.TryGetValue(blocks.Material, out var type)) |
|
|
|
{ |
|
|
|
case "DIRT": |
|
|
|
id = BlockIDs.DirtCube; |
|
|
|
color = BlockColors.Default; |
|
|
|
break; |
|
|
|
case "GRASS": |
|
|
|
id = BlockIDs.GrassCube; |
|
|
|
color = BlockColors.Default; |
|
|
|
break; |
|
|
|
case "STONE": |
|
|
|
case "COAL_ORE": |
|
|
|
case "IRON_ORE": |
|
|
|
id = BlockIDs.ConcreteCube; |
|
|
|
color = BlockColors.White; |
|
|
|
darkness = 5; |
|
|
|
break; |
|
|
|
case "LEAVES": |
|
|
|
id = BlockIDs.AluminiumCube; |
|
|
|
color = BlockColors.Green; |
|
|
|
darkness = 5; |
|
|
|
break; |
|
|
|
case "AIR": |
|
|
|
case "DOUBLE_PLANT": |
|
|
|
continue; |
|
|
|
case "LOG": |
|
|
|
id = BlockIDs.WoodCube; |
|
|
|
color = BlockColors.Default; |
|
|
|
break; |
|
|
|
case "WATER": |
|
|
|
id = BlockIDs.AluminiumCube; |
|
|
|
color = BlockColors.Blue; |
|
|
|
break; |
|
|
|
case "SAND": |
|
|
|
id = BlockIDs.AluminiumCube; |
|
|
|
color = BlockColors.Yellow; |
|
|
|
break; |
|
|
|
case "LONG_GRASS": |
|
|
|
id = BlockIDs.Flower1; |
|
|
|
color = BlockColors.Default; |
|
|
|
break; |
|
|
|
case "YELLOW_FLOWER": |
|
|
|
id = BlockIDs.Flower2; |
|
|
|
color = BlockColors.Default; |
|
|
|
break; |
|
|
|
case "GRAVEL": |
|
|
|
id = BlockIDs.ConcreteCube; |
|
|
|
color = BlockColors.White; |
|
|
|
darkness = 7; |
|
|
|
break; |
|
|
|
case "CLAY": |
|
|
|
id = BlockIDs.ConcreteCube; |
|
|
|
color = BlockColors.White; |
|
|
|
darkness = 4; |
|
|
|
break; |
|
|
|
default: |
|
|
|
Console.WriteLine("Unknown block: " + blocks.Material); |
|
|
|
continue; |
|
|
|
Console.WriteLine("Unknown block: " + blocks.Material); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Block.PlaceNew(id, (blocks.Start + blocks.End) / 10 * 3, color: color, darkness: darkness, |
|
|
|
scale: (blocks.End - blocks.Start + 1) * 3, rotation: float3.zero); |
|
|
|
Block.PlaceNew(type.Type, (blocks.Start + blocks.End) / 10 * 3, color: type.Color.Color, |
|
|
|
darkness: type.Color.Darkness, scale: (blocks.End - blocks.Start + 1) * 3, |
|
|
|
rotation: float3.zero); |
|
|
|
C++; |
|
|
|
} |
|
|
|
|
|
|
|