public void Init() { registerAllSystem(); registerAllEntity(); registerAllComponent(); for (int i = 0; i < mSystemCount; i++) { mUSystem [i].Init(); } for (int i = 0; i < mSystemCount; i++) { for (int j = i + 1; j < mSystemCount; j++) { if (mUSystem [i].power > mUSystem [j].power) { USystem tSystem = mUSystem [i]; mUSystem [i] = mUSystem [j]; mUSystem [j] = tSystem; } } } //ECSSort.QuickSortRelax (mUSystem,0,(int)mSystemCount-1); for (int i = 0; i < mEntityCount; i++) { mUEntity [i].Init(); } MainWorld = this; MainWorld.ToString(); }
// register the system public void registerSystem(USystem uSystem) { if (mSystemCount < mMaxSystemCount) { mUSystem [mSystemCount] = uSystem; mUSystem [mSystemCount].mWorld = this; mSystemCount++; } else { mMaxSystemCount *= 2; USystem[] uSystems = new USystem[mMaxSystemCount]; for (int i = 0; i < mSystemCount; i++) { uSystems [i] = mUSystem [i]; } mUSystem = uSystems; mUSystem [mSystemCount] = uSystem; mUSystem [mSystemCount].mWorld = this; mSystemCount++; } }