Exemple #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;
        }
Exemple #2
0
        unsafe public override void Load(FakeStruct fake)
        {
            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.Load(fs);
                        child.Add(model);
                        model.parent = this;
                    }
                }
            }
            name = buff.GetData(data.name) as string;
            tag  = buff.GetData(data.tag) as string;
        }