A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.4KB

  1. using System;
  2. using System.Collections.Generic;
  3. using GamecraftModdingAPI.Engines;
  4. using GamecraftModdingAPI.Persistence;
  5. using GamecraftModdingAPI.Utility;
  6. using RobocraftX.Common;
  7. using Svelto.ECS;
  8. using Svelto.ECS.Experimental;
  9. using Svelto.ECS.Serialization;
  10. namespace GamecraftModdingAPI.Blocks
  11. {
  12. /*public class CustomBlockEngine : IFactoryEngine
  13. {
  14. public class CustomBlockEntityDescriptor : SerializableEntityDescriptor<CustomBlockEntityDescriptor._CustomBlockDescriptor>
  15. {
  16. [HashName("GamecraftModdingAPICustomBlockV0")]
  17. public class _CustomBlockDescriptor : IEntityDescriptor
  18. {
  19. public IComponentBuilder[] componentsToBuild { get; } =
  20. {
  21. new SerializableComponentBuilder<SerializationType, CustomBlock.DataStruct>(
  22. ((int) SerializationType.Network, new DefaultSerializer<CustomBlock.DataStruct>()),
  23. ((int) SerializationType.Storage, new DefaultSerializer<CustomBlock.DataStruct>()))
  24. };
  25. }
  26. }
  27. public void Ready()
  28. {
  29. SerializerManager.AddSerializer<CustomBlockEntityDescriptor>(
  30. new SimpleEntitySerializer<CustomBlockEntityDescriptor>(db =>
  31. {
  32. var (coll, c) = db.QueryEntities<CustomBlock.DataStruct>(ApiExclusiveGroups.customBlockGroup);
  33. var egids = new EGID[c];
  34. for (int i = 0; i < c; i++)
  35. egids[i] = new EGID(coll[i].ID, ApiExclusiveGroups.customBlockGroup);
  36. return egids;
  37. }));
  38. foreach (var (id, name) in _registeredBlocks)
  39. {
  40. Factory.BuildEntity<CustomBlockEntityDescriptor>(id, ApiExclusiveGroups.customBlockGroup)
  41. .Init(new CustomBlock.DataStruct {Name = new ECSString(name), ID = id});
  42. }
  43. }
  44. public EntitiesDB entitiesDB { get; set; }
  45. private List<(ushort id, string name)> _registeredBlocks = new List<(ushort, string)>();
  46. public void Dispose()
  47. {
  48. }
  49. public void RegisterBlock(ushort id, string name)
  50. {
  51. _registeredBlocks.Add((id, name));
  52. }
  53. public string Name { get; } = "GamecraftModdingAPICustomBlockEngine";
  54. public bool isRemovable { get; } = false;
  55. public IEntityFactory Factory { get; set; }
  56. }*/
  57. }