public static StackCacheObject createFrom(StackLinkObjectCache cache, rtObjectBase src)
            {
                LinkSystemObject lobj = (LinkSystemObject)src.value;

                StackCacheObject clone = new StackCacheObject(cache, (lobj).Clone(),
                                                              null
                                                              );

                RunTimeScope scope =
                    new RunTimeScope(null, src.objScope.blockId, null,
                                     clone, RunTimeScopeType.objectinstance);

                clone.objScope = scope;

                return(clone);
            }
        public StackLinkObjectCache(CSWC bin, Player player)
        {
            this.player = player;
            int maxstructidx = -1;

            foreach (var item in bin.class_Creator)
            {
                var cls = item.Key;

                {
                    if (cls.structIndex > maxstructidx)
                    {
                        maxstructidx = cls.structIndex;
                    }
                }
            }

            structuseswitchs = new bool[maxstructidx + 1];
            strunctuseindexs = new int[maxstructidx + 1];
            strunctusecount  = 0;

            if (maxstructidx >= 0)
            {
                cache = new StackCacheObject[maxstructidx + 1];
                //cache[0] = player.alloc_pureHostedOrLinkedObject(player.swc.LinkObjectClass);
                cache[0] = StackCacheObject.createFrom(this, player.alloc_pureHostedOrLinkedObject(player.swc.LinkObjectClass));


                foreach (var item in bin.class_Creator)
                {
                    var cls = item.Key;
                    if (cls.isStruct)
                    {
                        cache[cls.structIndex] = StackCacheObject.createFrom(this, player.alloc_pureHostedOrLinkedObject(cls));
                    }
                }
            }
        }
        public StackLinkObjectCache Clone()
        {
            StackLinkObjectCache c = new StackLinkObjectCache();

            c.player = player;
            if (cache != null)
            {
                c.cache            = new StackCacheObject[cache.Length];
                c.structuseswitchs = new bool[structuseswitchs.Length];
                c.strunctuseindexs = new int[strunctuseindexs.Length];
                c.strunctusecount  = 0;

                for (int i = 0; i < cache.Length; i++)
                {
                    //c.cache[i] = (rtObject)cache[i].Clone();

                    if (cache[i] != null)
                    {
                        c.cache[i] = StackCacheObject.createFrom(c, cache[i]);
                    }
                }
            }
            return(c);
        }