Example #1
0
        unsafe public void Clone(FakeStruct fake, List <AssociatedInstance> table)
        {
            data    = *(ElementData *)fake.ip;
            ModData = fake;
            var buff = fake.buffer;

            Int16[] coms = buff.GetData(data.coms) as Int16[];
            if (coms != null)
            {
                for (int i = 0; i < coms.Length; i++)
                {
                    int index = coms[i];
                    i++;
                    int type = coms[i];
                    var fs   = buff.GetData(index) as FakeStruct;
                    var dc   = ModelManagerUI.Load(type);
                    if (dc != null)
                    {
                        dc.model = this;
                        if (fs != null)
                        {
                            dc.Load(fs);
                        }
                        components.Add(dc);
                        if (dc.Entity)
                        {
                            EnityType |= ((long)1 << type);
                        }
                    }
                }
            }
            Int16[] chi = fake.buffer.GetData(data.child) as Int16[];
            if (chi != null)
            {
                for (int i = 0; i < chi.Length; i++)
                {
                    var fs = buff.GetData(chi[i]) as FakeStruct;
                    if (fs != null)
                    {
                        ModelElement model = new ModelElement();
                        model.Clone(fs, table);
                        child.Add(model);
                        model.parent = this;
                        AssociatedInstance instance = new AssociatedInstance();
                        instance.id     = model.data.instanceID;
                        instance.target = model;
                        table.Add(instance);
                    }
                }
            }
            name = buff.GetData(data.name) as string;
            tag  = buff.GetData(data.tag) as string;
        }
Example #2
0
 public static ModelElement CloneModel(string asset, string name)
 {
     for (int i = 0; i < prefabs.Count; i++)
     {
         if (asset == prefabs[i].name)
         {
             var models = prefabs[i].models;
             var mod    = models.Find(name);
             if (mod != null)
             {
                 List <AssociatedInstance> table = new List <AssociatedInstance>();
                 ModelElement model = new ModelElement();
                 model.Clone(mod.ModData, table);
                 RestoringRelationships(model, table);
                 return(model);
             }
             return(null);
         }
     }
     return(null);
 }