|
|
@@ -15,6 +15,7 @@ using RobocraftX.Rendering.GPUI; |
|
|
|
using Svelto.DataStructures; |
|
|
|
using Svelto.ECS; |
|
|
|
using Svelto.ECS.EntityStructs; |
|
|
|
using Svelto.ECS.Experimental; |
|
|
|
using Svelto.ECS.Hybrid; |
|
|
|
using Techblox.BuildingDrone; |
|
|
|
using Unity.Mathematics; |
|
|
@@ -138,7 +139,7 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
} |
|
|
|
|
|
|
|
uint prefabId = |
|
|
|
PrefabsID.GetOrCreatePrefabID((ushort) prefabAssetID, material, 1, flipped); |
|
|
|
PrefabsID.GetOrAddPrefabID((ushort) prefabAssetID, material, 1, flipped); |
|
|
|
entitiesDB.QueryEntityOrDefault<GFXPrefabEntityStructGPUI>(block).prefabID = prefabId; |
|
|
|
if (block.Exists) |
|
|
|
{ |
|
|
@@ -168,28 +169,25 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
public SimBody[] GetSimBodiesFromID(byte id) |
|
|
|
{ |
|
|
|
var ret = new FasterList<SimBody>(4); |
|
|
|
var oide = entitiesDB.QueryEntities<ObjectIdEntityStruct>(); |
|
|
|
var (oids, tags, count) = entitiesDB.QueryEntities<ObjectIdEntityStruct, BlockTagEntityStruct>(CommonExclusiveGroups.OBJID_BLOCK_GROUP); |
|
|
|
EGIDMapper<GridConnectionsEntityStruct>? connections = null; |
|
|
|
foreach (var ((oids, count), _) in oide) |
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
for (int i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
ref ObjectIdEntityStruct oid = ref oids[i]; |
|
|
|
if (oid.objectId != id) continue; |
|
|
|
if (!connections.HasValue) //Would need reflection to get the group from the build group otherwise |
|
|
|
connections = entitiesDB.QueryMappedEntities<GridConnectionsEntityStruct>(oid.ID.groupID); |
|
|
|
var rid = connections.Value.Entity(oid.ID.entityID).machineRigidBodyId; |
|
|
|
foreach (var rb in ret) |
|
|
|
{ |
|
|
|
if (rb.Id.entityID == rid) |
|
|
|
goto DUPLICATE; //Multiple Object Identifiers on one rigid body |
|
|
|
} |
|
|
|
|
|
|
|
ret.Add(new SimBody(rid)); |
|
|
|
DUPLICATE: ; |
|
|
|
if (oids[i].objectId != id) continue; |
|
|
|
var tag = tags[i]; |
|
|
|
if (!connections.HasValue) //Would need reflection to get the group from the build group otherwise |
|
|
|
connections = entitiesDB.QueryMappedEntities<GridConnectionsEntityStruct>(tag.ID.groupID); |
|
|
|
var rid = connections.Value.Entity(tag.ID.entityID).machineRigidBodyId; |
|
|
|
foreach (var rb in ret) |
|
|
|
{ |
|
|
|
if (rb.Id.entityID == rid) |
|
|
|
goto DUPLICATE; //Multiple Object Identifiers on one rigid body |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ret.Add(new SimBody(rid)); |
|
|
|
DUPLICATE: ; |
|
|
|
} |
|
|
|
|
|
|
|
return ret.ToArray(); |
|
|
|
} |
|
|
|
|
|
|
@@ -256,15 +254,16 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
|
|
|
|
public Block[] GetBodyBlocks(uint sbid) |
|
|
|
{ |
|
|
|
var groups = entitiesDB.QueryEntities<GridConnectionsEntityStruct>(); |
|
|
|
var groups = entitiesDB.FindGroups<GridConnectionsEntityStruct>(); |
|
|
|
groups = new QueryGroups(groups).Except(CommonExclusiveGroups.DISABLED_JOINTS_IN_SIM_GROUP).Evaluate().result; |
|
|
|
var set = new HashSet<Block>(); |
|
|
|
foreach (var ((coll, count), _) in groups) |
|
|
|
foreach (var ((coll, tags, count), _) in entitiesDB.QueryEntities<GridConnectionsEntityStruct, BlockTagEntityStruct>(groups)) |
|
|
|
{ |
|
|
|
for (var index = 0; index < count; index++) |
|
|
|
{ |
|
|
|
var conn = coll[index]; |
|
|
|
if (conn.machineRigidBodyId == sbid) |
|
|
|
set.Add(Block.New(conn.ID)); |
|
|
|
set.Add(Block.New(tags[index].ID)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|