TechbloxModdingAPI/GamecraftModdingAPI/Blocks/CustomBlockEngine.cs
NorbiPeti d954060a5a Add ability to change properties of existing blocks
And not storing custom block data for now
2020-12-27 21:13:49 +01:00

64 lines
No EOL
2.4 KiB
C#

using System;
using System.Collections.Generic;
using GamecraftModdingAPI.Engines;
using GamecraftModdingAPI.Persistence;
using GamecraftModdingAPI.Utility;
using RobocraftX.Common;
using Svelto.ECS;
using Svelto.ECS.Experimental;
using Svelto.ECS.Serialization;
namespace GamecraftModdingAPI.Blocks
{
/*public class CustomBlockEngine : IFactoryEngine
{
public class CustomBlockEntityDescriptor : SerializableEntityDescriptor<CustomBlockEntityDescriptor._CustomBlockDescriptor>
{
[HashName("GamecraftModdingAPICustomBlockV0")]
public class _CustomBlockDescriptor : IEntityDescriptor
{
public IComponentBuilder[] componentsToBuild { get; } =
{
new SerializableComponentBuilder<SerializationType, CustomBlock.DataStruct>(
((int) SerializationType.Network, new DefaultSerializer<CustomBlock.DataStruct>()),
((int) SerializationType.Storage, new DefaultSerializer<CustomBlock.DataStruct>()))
};
}
}
public void Ready()
{
SerializerManager.AddSerializer<CustomBlockEntityDescriptor>(
new SimpleEntitySerializer<CustomBlockEntityDescriptor>(db =>
{
var (coll, c) = db.QueryEntities<CustomBlock.DataStruct>(ApiExclusiveGroups.customBlockGroup);
var egids = new EGID[c];
for (int i = 0; i < c; i++)
egids[i] = new EGID(coll[i].ID, ApiExclusiveGroups.customBlockGroup);
return egids;
}));
foreach (var (id, name) in _registeredBlocks)
{
Factory.BuildEntity<CustomBlockEntityDescriptor>(id, ApiExclusiveGroups.customBlockGroup)
.Init(new CustomBlock.DataStruct {Name = new ECSString(name), ID = id});
}
}
public EntitiesDB entitiesDB { get; set; }
private List<(ushort id, string name)> _registeredBlocks = new List<(ushort, string)>();
public void Dispose()
{
}
public void RegisterBlock(ushort id, string name)
{
_registeredBlocks.Add((id, name));
}
public string Name { get; } = "GamecraftModdingAPICustomBlockEngine";
public bool isRemovable { get; } = false;
public IEntityFactory Factory { get; set; }
}*/
}