Cleanup, added INI file and parser lib (merged)

Updated plugin and removed commands that don't really belong here
Using ILMerge to merge the parser into the DLL
This commit is contained in:
Norbi Peti 2020-05-19 01:16:40 +02:00
parent 2ad5109639
commit 3e3fd0c767
8 changed files with 97 additions and 85 deletions

11
GCMC/BlockType.cs Normal file
View file

@ -0,0 +1,11 @@
using GamecraftModdingAPI.Blocks;
namespace GCMC
{
public struct BlockType
{
public string Material;
public BlockIDs Type;
public BlockColor Color;
}
}

45
GCMC/BlockTypes.ini Normal file
View file

@ -0,0 +1,45 @@
[Dirt]
type=DirtCube
[Grass]
type=GrassCube
[Stone,Coal_ore,Iron_ore]
type=ConcreteCube
color=White
darkness=5
[Leaves]
type=AluminiumCube
color=Green
darkness=5
[Air,Double_plant]
ignore=true
[Log]
type=WoodCube
[Water]
type=AluminiumCube
color=Blue
[Sand]
type=AluminiumCube
color=Yellow
[Long_grass]
type=Flower1
[Yellow_flower]
type=Flower2
[Gravel]
type=ConcreteCube
color=White
darkness=7
[Clay]
type=ConcreteCube
color=White
darkness=4

View file

@ -1,6 +1,7 @@
using System;
using System.IO;
using DataLoader;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using Newtonsoft.Json;
using RobocraftX.Blocks;
@ -21,30 +22,11 @@ using uREPL;
namespace GCMC
{
public class CubePlacerEngine : IQueryingEntitiesEngine, IDeterministicSim
public class CubePlacerEngine : IQueryingEntitiesEngine, IDeterministicTimeStopped
{
public void Ready()
{
RuntimeCommands.Register<string>("importWorld", ImportWorld, "Imports a Minecraft world.");
RuntimeCommands.Register<string>("placeCube", PlaceBlock, "Places a cube.");
RuntimeCommands.Register("placedBy", GetPlacedBy, "Gets who placed a block.");
}
private void GetPlacedBy()
{
try
{
var placementInfo =
entitiesDB.QueryEntity<BlockPlacementInfoStruct>(new EGID(BlockIdentifiers.LatestBlockID,
BlockIdentifiers.OWNED_BLOCKS));
Log.Output("Placed by: " + placementInfo.placedBy);
Log.Output("Loaded from disk: " + placementInfo.loadedFromDisk);
}
catch (Exception e)
{
Log.Error("Failed to get who placed the block.");
Console.WriteLine("Error getting who placed the block:\n" + e);
}
}
public EntitiesDB entitiesDB { get; set; }
@ -122,7 +104,7 @@ namespace GCMC
continue;
}
Placement.PlaceBlock(id, (blocks.Start + blocks.End) / 10 * 3, color: color, darkness: darkness,
Block.PlaceNew(id, (blocks.Start + blocks.End) / 10 * 3, color: color, darkness: darkness,
scale: (blocks.End - blocks.Start + 1) * 3, rotation: float3.zero);
C++;
}
@ -136,35 +118,7 @@ namespace GCMC
}
}
private void PlaceBlock(string args)
{
try
{
var s = args.Split(' ');
ushort block = ushort.Parse(s[0]);
byte color = byte.Parse(s[1]);
byte darkness = byte.Parse(s[2]);
float x = float.Parse(s[3]), y = float.Parse(s[4]), z = float.Parse(s[5]);
int scale = int.Parse(s[6]);
float scaleX = float.Parse(s[7]);
float scaleY = float.Parse(s[8]);
float scaleZ = float.Parse(s[9]);
float rotX = float.Parse(s[10]);
float rotY = float.Parse(s[11]);
float rotZ = float.Parse(s[12]);
uint playerId = 0;
Placement.PlaceBlock((BlockIDs) block, new float3(x, y, z), new float3(rotX, rotY, rotZ),
(BlockColors) color, darkness, scale, new float3(scaleX, scaleY, scaleZ), playerId);
}
catch (Exception e)
{
Console.WriteLine(e);
Log.Error(e.Message);
}
}
public JobHandle SimulatePhysicsStep(in float deltaTime, in PhysicsUtility utility,
in PlayerInput[] playerInputs)
public JobHandle SimulatePhysicsStep(in float deltaTime, in PhysicsUtility utility, in PlayerInput[] playerInputs)
{
return new JobHandle();
}

View file

@ -1,74 +1,81 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="fNbt" Version="0.6.4" />
<PackageReference Include="ILMerge" Version="3.0.29" />
<PackageReference Include="ini-parser" Version="2.5.2" />
<PackageReference Include="Lib.Harmony" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, PublicKeyToken=null">
<HintPath>bin\Debug\netstandard2.0\0Harmony.dll</HintPath>
</Reference>
<Reference Include="BlockEntityFactory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\BlockEntityFactory.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\CommandLine.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
</Reference>
<Reference Include="DataLoader, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\DataLoader.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\DataLoader.dll</HintPath>
</Reference>
<Reference Include="GamecraftModdingAPI, Version=0.2.0.0, Culture=neutral, PublicKeyToken=null">
<Reference Include="GamecraftModdingAPI, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>IllusionPlugin.dll</HintPath>
<!-- <Private>False</Private> Need to copy for ILMerge -->
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.1.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.Blocks.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Character, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.Character.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.Common.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.GUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.GUI.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Input, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.Input.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.MachineEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.MachineEditor.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.StateSync, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.StateSync.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll</HintPath>
</Reference>
<Reference Include="Svelto.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\Svelto.Common.dll</HintPath>
<Reference Include="Svelto.Common_3, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\Games\SteamLibrary\steamapps\common\RobocraftX\Gamecraft_Data\Managed\Svelto.Common_3.dll</HintPath>
</Reference>
<Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\Svelto.ECS.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath>
</Reference>
<Reference Include="Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\Unity.Entities.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll</HintPath>
</Reference>
<Reference Include="Unity.Mathematics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\Unity.Mathematics.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="uREPL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\uREPL.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\uREPL.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="AfterBuild">
<!-- the ILMergePath property points to the location of ILMerge.exe console application -->
<Exec Command="$(ILMergeConsolePath) /ndebug /out:bin\Debug\net472\GCMC.dll bin\$(Configuration)\net472\GCMC.dll bin\$(Configuration)\net472\INIFileParser.dll" />
</Target>
</Project>

View file

@ -1,5 +1,5 @@
using System.Reflection;
using Harmony;
using HarmonyLib;
using IllusionPlugin;
using UnityEngine;
@ -9,14 +9,14 @@ namespace GCMC
{
public string Name { get; } = "GCMC";
public string Version { get; } = "v0.0.1";
public static HarmonyInstance harmony { get; protected set; }
public static Harmony harmony { get; protected set; }
public const string HarmonyID = "io.github.norbipeti.GCMC";
public void OnApplicationStart()
{
if (harmony == null)
{
harmony = HarmonyInstance.Create(HarmonyID);
harmony = new Harmony(HarmonyID);
harmony.PatchAll(Assembly.GetExecutingAssembly());
}

View file

@ -1,6 +1,6 @@
using System.Reflection;
using DataLoader;
using Harmony;
using HarmonyLib;
using JetBrains.Annotations;
using RobocraftX.Common;
using RobocraftX.CR.MachineEditing;
@ -26,7 +26,7 @@ namespace GCMC
Debug.Log("Not authoritative, not adding MC engine");
}
static MethodBase TargetMethod(HarmonyInstance instance)
static MethodBase TargetMethod()
{
return typeof(MainEditingCompositionRoot).GetMethod("Compose",
BindingFlags.Public | BindingFlags.Static);

View file

@ -5,10 +5,6 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="fNbt" Version="0.6.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GCMC\GCMC.csproj" />
</ItemGroup>

View file

@ -1,6 +1,5 @@
using System;
using System.Threading.Channels;
using fNbt;
using GCMC;
namespace GCMCTest