Example #1
0
        public static Module CreateInstance(Plant plant, ModulePrototype module, Pose pose)
        {
            // Make a copy of all the nodes
            module.nodes.ForEach(node => { node.copyOfMe = Node.MemberwiseClone(node); });
            // Assign references of the copies to the copied elements
            List <Node> copiedNodes = Enumerable.ToList(
                Enumerable.Select(module.nodes, (node =>
            {
                node.copyOfMe.parent = GetCopyOfMeIfNotNull(node.parent);
                node.copyOfMe.main = GetCopyOfMeIfNotNull(node.main);
                node.copyOfMe.lateral = GetCopyOfMeIfNotNull(node.lateral);
                return(node.copyOfMe);
            })));

            Module result = new Module(plant, module.root.copyOfMe, copiedNodes, pose);

            result.nodes.ForEach(node =>
            {
                node.module = result;
            });
            return(result);
        }
Example #2
0
 public static Node MemberwiseClone(Node node)
 {
     return((Node)node.MemberwiseClone());
 }