MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / GameObjectPool

Method GameObjectPool

LuaSTGPlus/GameObjectPool.cpp:443–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443GameObjectPool::GameObjectPool(lua_State* pL)
444 : L(pL)
445{
446 // ��ʼ��αͷ������
447 memset(&m_pObjectListHeader, 0, sizeof(GameObject));
448 memset(&m_pRenderListHeader, 0, sizeof(GameObject));
449 memset(m_pCollisionListHeader, 0, sizeof(m_pCollisionListHeader));
450 memset(&m_pObjectListTail, 0, sizeof(GameObject));
451 memset(&m_pRenderListTail, 0, sizeof(GameObject));
452 memset(m_pCollisionListTail, 0, sizeof(m_pCollisionListTail));
453 m_pObjectListHeader.pObjectNext = &m_pObjectListTail;
454 m_pObjectListHeader.uid = numeric_limits<uint64_t>::min();
455 m_pObjectListTail.pObjectPrev = &m_pObjectListHeader;
456 m_pObjectListTail.uid = numeric_limits<uint64_t>::max();
457 m_pRenderListHeader.pRenderNext = &m_pRenderListTail;
458 m_pRenderListHeader.uid = numeric_limits<uint64_t>::min();
459 m_pRenderListHeader.layer = numeric_limits<lua_Number>::min();
460 m_pRenderListTail.pRenderPrev = &m_pRenderListHeader;
461 m_pRenderListTail.uid = numeric_limits<uint64_t>::max();
462 m_pRenderListTail.layer = numeric_limits<lua_Number>::max();
463 for (size_t i = 0; i < LGOBJ_GROUPCNT; ++i)
464 {
465 m_pCollisionListHeader[i].pCollisionNext = &m_pCollisionListTail[i];
466 m_pCollisionListTail[i].pCollisionPrev = &m_pCollisionListHeader[i];
467 }
468
469 // ����һ��ȫ�ֱ����ڴ�����ж���
470 lua_pushlightuserdata(L, (void*)&LAPP); // p(ʹ��APPʵ��ָ���������Է�ֹ�û�����)
471 lua_createtable(L, LGOBJ_MAXCNT, 0); // p t(�����㹻���table���ڴ�����е���Ϸ������lua�еĶ�Ӧ����)
472
473 // ȡ��lstg.GetAttr��lstg.SetAttr����Ԫ��
474 lua_newtable(L); // ... t
475 lua_getglobal(L, "lstg"); // ... t t
476 lua_pushstring(L, "GetAttr"); // ... t t s
477 lua_gettable(L, -2); // ... t t f(GetAttr)
478 lua_pushstring(L, "SetAttr"); // ... t t f(GetAttr) s
479 lua_gettable(L, -3); // ... t t f(GetAttr) f(SetAttr)
480 LASSERT(lua_iscfunction(L, -1) && lua_iscfunction(L, -2));
481 lua_setfield(L, -4, "__newindex"); // ... t t f(GetAttr)
482 lua_setfield(L, -3, "__index"); // ... t t
483 lua_pop(L, 1); // ... t(��������Ԫ��)
484
485 // ����Ԫ���� register[app][mt]
486 lua_setfield(L, -2, METATABLE_OBJ); // p t
487 lua_settable(L, LUA_REGISTRYINDEX);
488}
489
490GameObjectPool::~GameObjectPool()
491{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected