public void assembleActor(Transform parentPart, Schematic schema, int index) { //reads node data to create child parts Part thisPart = schema.getPart (index); if (thisPart == null) return; else { for(int i=0; i<thisPart.nodes.Length; i+=1) { Node thisNode = thisPart.getNode(i); if(thisNode == null) continue; if(thisNode.equipped) { Debug.Log("node:yes"); PartTag attachedTag = thisNode.getPartTag (); if (attachedTag == null) continue; //nothing attached Part attachedPart = schema.getPart (attachedTag.index); //now that we pulled the data we need.. Transform partObject = createPart(attachedPart); if(partObject) { partObject.SetParent(parentPart); partObject.localPosition.Set (thisNode.localPosition.x,thisNode.localPosition.y,thisNode.localPosition.z); partObject.localRotation = Quaternion.Euler(thisNode.localRotation.x,thisNode.localRotation.y,thisNode.localRotation.z); assembleActor(partObject, schema, attachedTag.index); } else Debug.Log("Gag! no part!"); } } } }
//builds from schema public Transform createActor(Schematic schema) { if (schema == null) return null; if (schema.parts.Count < 1) return null; Transform core = createPart (schema.getPart (0)); if (core == null) return null; assembleActor (core, schema, 0); return core; }