public static Construct[] ConvertModelBlocksToDSConstructs(HashSet <ModelBlock> blocks) { int resultIndex = 0; Construct[] result = new Construct[blocks.Count]; foreach (ModelBlock block in blocks) { int childIndex = 0; string name = block.isOrigin ? ComponentType.Origin.ToString() : ComponentType.Function.ToString(); Position pos = new Position(block.Position.x, block.Position.y, block.Position.z); ConstructInfo2 info = new ConstructInfo2(block.isOrigin, block.Id); Construct[] children = new Construct[block.Components.Count]; foreach (ModelComponent component in block.Components) { string childName = component.ComponentType.ToString(); if (block.isOrigin && component.ComponentType == ComponentType.Return) { childName = "Result"; } Position childPos = new Position(component.Position.x, component.Position.y, component.Position.z); ConstructInfo2 childInfo = new ConstructInfo2(false, component.Id, "number", component.InitializeValue); Construct child = new Construct(childName, new Construct[] { }, childPos, childInfo); children[childIndex++] = child; } Construct construct = new Construct(name, children, pos, info); result[resultIndex++] = construct; } return(result); }
public Construct(string name, Construct[] children, Position pos, ConstructInfo2 info) { this.name = name; this.children = children; this.pos = pos; this.info = info; }