Esempio n. 1
0
 public static void Decon(PtrLst *self)
 {
                 #if FDB
     Verify(self);
                 #endif
     Mem.Free(self->arr);
 }
Esempio n. 2
0
 public static void Remove(PtrLst *self, void *ptr)
 {
                 #if FDB
     Should.NotNull("self", self);
     Should.TypeEqual("self", self->type, Type);
     int oldCount = self->count;
                 #endif
     void **arr = self->arr;
     int    i = 0, len = self->count;
     while (i < len && arr[i] != ptr)
     {
         i += 1;
     }
     if (i < len)                // arr[i] == p
     // for (len = self->count -= 1; i < len; i += 1) arr[i] = arr[i + 1];
     {
         byte *src   = (byte *)(arr + i);
         int   size  = self->size;
         int   count = self->count -= 1;
         Mem.Memmove(src, src + size, (count - i) * size);
     }
                 #if FDB
     else
     {
         Fdb.Error("{0:X} does not exist in PtrLst {1:X}", (ulong)ptr, (ulong)self);
     }
     Should.Equal("self->count", self->count, oldCount - 1);
                 #endif
 }
Esempio n. 3
0
 public static void Clear(PtrLst *self)
 {
                 #if FDB
     Should.NotNull("self", self);
     Should.TypeEqual("self", self->type, Type);
                 #endif
     self->count = 0;
 }
Esempio n. 4
0
        public static void Verify(PtrLst *self)
        {
            Should.NotNull("self", self);
            Should.TypeEqual("self", self->type, Type);
            int len = Mem.Verify(self->arr) / sizeof(void *);

            Should.Equal("self->len", self->len, len);
            Should.InRange("self->count", self->count, 0, self->len);
            Should.Equal("self->size", self->size, sizeof(void *));
        }
Esempio n. 5
0
 public static void ShiftBase(PtrLst *self, long shift)
 {
                 #if FDB
     Verify(self);
                 #endif
     void **arr = self->arr;
     for (int i = 0, count = self->count; i < count; i += 1)
     {
         *(byte **)(arr + i) += shift;
     }
 }
Esempio n. 6
0
        public void Dispose()
        {
            cmdQueue.Clear();
            esJobList.Clear();
            PtrIntDict.Decon(nodeDict); Mem.Free(nodeDict); nodeDict         = null;
            Pool.Decon(spritePool); Mem.Free(spritePool); spritePool         = null;
            PtrLst.Decon(spritePtrLst); Mem.Free(spritePtrLst); spritePtrLst = null;
            DrawCtx.Dispose();

            Debug.Log("Clean up GPC");
        }
Esempio n. 7
0
        public static void RemoveAt(PtrLst *self, int idx)
        {
                        #if FDB
            Verify(self);
            Should.InRange("idx", idx, 0, self->count - 1);
                        #endif
            byte *src   = (byte *)(self->arr + idx);
            int   size  = self->size;
            int   count = self->count -= 1;
//			void **arr = self->arr;
//			for (int i = idx; i < count; i += 1) arr[i] = arr[i + 1];
            Mem.Memmove(src, src + size, (count - idx) * size);
        }
Esempio n. 8
0
 public static void Push(PtrLst *self, void *ptr)
 {
                 #if FDB
     Verify(self);
                 #endif
     int oldCount = self->count;
     self->count = oldCount + 1;
     if (oldCount >= self->len)                // resize
     {
         self->arr = (void **)Mem.Realloc(self->arr, (self->len <<= 1) * self->size);
     }
     self->arr[oldCount] = ptr;
 }
Esempio n. 9
0
 public static void Init(PtrLst *self, int len)
 {
                 #if FDB
     Should.NotNull("self", self);
     Should.GreaterThanZero("len", len);
     self->type = Type;
                 #endif
     self->tag   = Tag.PtrLst;
     self->len   = len;
     self->count = 0;
     int size = self->size = sizeof(void *);
     self->arr = (void **)Mem.Malloc(len * size);
 }
Esempio n. 10
0
 public static void Init(PtrLst *self)
 {
     Init(self, 4);
 }
Esempio n. 11
0
    void OnEnable()
    {
        Res.LoadAtlases(10);

                #if GPC_TEST
        nodePool = Pool.New();

        nodeLst = PtrLst.New();
        PtrLst.Push(&nodePool->dependentLst, nodeLst);

        var sprite = (TpSprite *)Pool.Alloc(nodePool, sizeof(TpSprite));
        TpSprite.Init(sprite, Res.GetSpriteMeta(10001));

        var container = (Group *)Pool.Alloc(nodePool, sizeof(Group));
        Group.Init(container);
        PtrLst.Push(&nodePool->dependentLst, &container->childLst);

        PtrLst.Push(nodeLst, sprite);
        Vec4.Set(sprite->color, 1, 1, 1, 1);
        Vec2.Set(sprite->scl, .015f, .015f);

        DrawCtx.Start();
        var arr = (TpSprite **)nodeLst->arr;
        for (int i = 0, len = nodeLst->count; i < len; i += 1)
        {
            Node.Draw(arr[i], null, false);
        }
        DrawCtx.Finish();

        return;
                #endif

        gpc = new GpController(Camera.main);

        for (int i = 0; i < 5; i += 1)
        {
            gpc.SetCamAttr(CamAttr.Position, 0f, 0f);
            gpc.SetCamAttr(CamAttr.Zoom, 5f);

            gpc.AddImg(1, 10001);
            gpc.SetImgInteractable(1, (phase, x, y) => Debug.LogFormat("hit img1: phase {0}, x {1}, y {2}", phase, x, y));
            gpc.SetImgAttr(1, ImgAttr.Position, 0f, 0f, 0f);
            gpc.SetImgAttr(1, ImgAttr.Rotation, 0f);
            gpc.SetImgAttr(1, ImgAttr.Alpha, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Scale, 1f, EsType.ElasticOut, 0.01f, 0.01f);
            gpc.Wait(.5f);
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1.5f, EsType.ElasticOut, 1f, 0.5f, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Position, 2f, EsType.ElasticOut, 2f, -1f, 0f);
            gpc.Wait();
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1.5f, EsType.ElasticOut, 1f, 1f, 1f);
            gpc.SetImgAttrEased(1, ImgAttr.Position, 2f, EsType.ElasticOut, -2f, 2f, 0f);
            gpc.SetImgAttrEased(1, ImgAttr.Rotation, 1.5f, EsType.ElasticOut, Mathf.PI * 2.5f);

            gpc.SetCamAttrEased(CamAttr.Zoom, 1.5f, EsType.ElasticOut, 2f);
            gpc.SetCamAttrEased(CamAttr.Position, 2f, EsType.ElasticOut, -2f, 2f);

            gpc.Wait(.5f);
            gpc.AddImg(2, 10001);
            gpc.SetImgInteractable(2, (phase, x, y) => Debug.LogFormat("hit img2: phase {0}, x {1}, y {2}", phase, x, y));
            gpc.SetImgAttr(2, ImgAttr.Position, 0f, 0f, -5f);
            gpc.SetImgAttr(2, ImgAttr.Rotation, 0f);
            gpc.SetImgAttr(2, ImgAttr.Scale, 0.1f, 0.1f);
            gpc.SetImgAttr(2, ImgAttr.Alpha, 1f);
            gpc.SetImgAttrEased(2, ImgAttr.Scale, 1f, EsType.ElasticOut, 0.006f, 0.006f);
            gpc.SetImgAttrEased(2, ImgAttr.Position, 4f, EsType.ElasticOut, -2f, 2f, 0f);

            gpc.SetImgInteractable(1, null);

            gpc.Wait();
            gpc.SetImgId(2, 103);

            gpc.Wait();
            gpc.SetImgAttrEased(1, ImgAttr.Tint, 1f, EsType.ElasticOut, 1.5f, 1.5f, 1.5f);

            gpc.Wait();
            gpc.RmImg(1);
            gpc.RmImg(2);
        }

        Application.targetFrameRate = Screen.currentResolution.refreshRate;

                #if FDB
        Fdb.Test();
                #endif
    }