Ejemplo n.º 1
0
        public static void RecycleElement(ModelElement mod)
        {
            if (mod == null)
            {
                return;
            }
            mod.SetParent(null);
            if (mod.Main != null)
            {
                long type = mod.data.type;
                for (int i = 0; i < models.Count; i++)
                {
                    if (models[i].type == type)
                    {
                        var g = mod.Main;
                        if (models[i].ReCycle(g))
                        {
                            g.SetActive(false);
                            mod.Context.SetParent(CycleBuffer);
                            mod.Context = null;
                            mod.Main    = null;
                        }
                        break;
                    }
                }
            }
            var child = mod.child;

            for (int i = 0; i < child.Count; i++)
            {
                RecycleElement(child[i]);
            }
            child.Clear();
        }
Ejemplo n.º 2
0
        unsafe public override void Load(FakeStruct fake)
        {
            data = *(ElementData *)fake.ip;
            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;
                    if (fs != null)
                    {
                        var dc = ModelManagerUI.Load(type);
                        if (dc != null)
                        {
                            dc.Load(fs);
                            components.Add(dc);
                        }
                    }
                }
            }
            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.Load(fs);
                        model.SetParent(this);
                        //child.Add(model);
                        //model.parent = this;
                    }
                }
            }
            name    = buff.GetData(data.name) as string;
            tag     = buff.GetData(data.tag) as string;
            ModData = fake;
        }