|
|
@@ -2,27 +2,19 @@ |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using DataLoader; |
|
|
|
using GamecraftModdingAPI.App; |
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
using GPUInstancer; |
|
|
|
using HarmonyLib; |
|
|
|
|
|
|
|
using DataLoader; |
|
|
|
using RobocraftX.Blocks; |
|
|
|
using RobocraftX.Common; |
|
|
|
using RobocraftX.Rendering; |
|
|
|
using Svelto.DataStructures; |
|
|
|
using Svelto.ECS; |
|
|
|
using Svelto.Tasks; |
|
|
|
using Unity.Entities.Conversion; |
|
|
|
using Unity.Physics; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.AddressableAssets; |
|
|
|
using BoxCollider = UnityEngine.BoxCollider; |
|
|
|
using Material = UnityEngine.Material; |
|
|
|
using Object = UnityEngine.Object; |
|
|
|
using ScalingPermission = DataLoader.ScalingPermission; |
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks |
|
|
|
{ |
|
|
@@ -62,18 +54,18 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
|
|
|
|
public CustomBlock(EGID id) : base(id) |
|
|
|
{ |
|
|
|
if (id.groupID != Group) |
|
|
|
throw new BlockTypeException("The block is not a custom block! It has a group of " + id.groupID); |
|
|
|
/*if (id.groupID != Group) |
|
|
|
throw new BlockTypeException("The block is not a custom block! It has a group of " + id.groupID);*/ |
|
|
|
} |
|
|
|
|
|
|
|
public CustomBlock(uint id) : this(new EGID(id, Group)) |
|
|
|
public CustomBlock(uint id) : base(id) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); |
|
|
|
//public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); |
|
|
|
|
|
|
|
[HarmonyPatch] |
|
|
|
public static class Patch |
|
|
|
public static class MaterialCopyPatch |
|
|
|
{ |
|
|
|
private static Material[] materials; |
|
|
|
|
|
|
@@ -110,6 +102,7 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
var cld = new CubeListData |
|
|
|
{ //"Assets/Prefabs/Cube.prefab" - "CTR_CommandBlock" - "strConsoleBlock" |
|
|
|
cubeType = attr.Type, |
|
|
|
//cubeCategory = (CubeCategory) 1000, |
|
|
|
cubeCategory = attr.Category, |
|
|
|
inventoryCategory = attr.InventoryCategory, |
|
|
|
ID = nextID++, |
|
|
@@ -141,8 +134,24 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static IEnumerator Prep() |
|
|
|
{ //TODO: Don't let the game load until this finishes |
|
|
|
/*[HarmonyPatch] - The block has no collision even in simulation if using a custom category |
|
|
|
private static class FactorySetupPatch |
|
|
|
{ |
|
|
|
public static void Prefix(BlockEntityFactory __instance) |
|
|
|
{ |
|
|
|
var builders = (Dictionary<CubeCategory, IBlockBuilder>) |
|
|
|
AccessTools.Field(__instance.GetType(), "_blockBuilders").GetValue(__instance); |
|
|
|
builders.Add((CubeCategory) 1000, new BlockBuilder<StandardBlockEntityDescriptor>(Group)); |
|
|
|
} |
|
|
|
|
|
|
|
public static MethodBase TargetMethod() |
|
|
|
{ |
|
|
|
return AccessTools.Method(typeof(BlockEntityFactory), "ParseDataDB"); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
internal static IEnumerator Prepare() |
|
|
|
{ //Should be pretty quick |
|
|
|
foreach (var type in _customBlocks.Values) |
|
|
|
{ |
|
|
|
var attr = type.GetCustomAttribute<CustomBlockAttribute>(); |
|
|
@@ -153,5 +162,12 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
Addressables.AddResourceLocator(res.Result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*internal static void OnBlockFactoryObtained(BlockEntityFactory factory) |
|
|
|
{ |
|
|
|
var builders = (Dictionary<CubeCategory, IBlockBuilder>) |
|
|
|
AccessTools.Field(factory.GetType(), "_blockBuilders").GetValue(factory); |
|
|
|
builders.Add((CubeCategory) 1000, new BlockBuilder<StandardBlockEntityDescriptor>(Group)); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |