コード例 #1
0
ファイル: WrapperReg.cs プロジェクト: ForceRain/PlaygroundOSS
		/// <summary>
		/// Generates a handle and registers the game object in the array
		/// </summary>
		/// <returns>
		/// The handle of the GameObject.
		/// </returns>
		/// <param name='pObj'>
		/// GameObject to register.
		/// </param>
		public uint registerGameObject(GameObject pObj)
		{
            Console.WriteLine("[C#] WrapperReg.registerGameObject BEGIN");
			if(pObj.Handle == GameObject.NULLHANDLER) {
                Console.WriteLine("[C#] WrapperReg - Handle OK");
                // no free handles in the array
				if(m_freeHandlesList.Count == 0) {
					m_list[m_objectCounter] = pObj;
					pObj.Handle = m_objectCounter;
					if(++m_objectCounter == m_listSize) {
						Console.WriteLine("[C#] WrapperReg - array RESIZE");
						Array.Resize(ref m_list, m_listSize += 10);
					}
                    Console.WriteLine("[C#] WrapperReg - Register GameObject with handle " + (m_objectCounter - 1));
					return m_objectCounter - 1;
				} else {
                    // there are free handles in the array
					uint idx = m_freeHandlesList[0];
					m_freeHandlesList.RemoveAt(0);
					m_list[idx] = pObj;
					pObj.Handle = idx;
					
					Console.WriteLine("Register GameObject with handle " + idx);
					return idx;
				}
			} else {
				throw new CKLBException("This object is already registered.");
			}
		}
コード例 #2
0
ファイル: WrapperReg.cs プロジェクト: ForceRain/PlaygroundOSS
		/// <summary>
		/// Unregisters the game object from the array and set the handle to NULLHANDLER
		/// </summary>
		/// <param name='pObj'>
        /// GameObject to register.
		/// </param>
		public void unregisterGameObject(GameObject pObj)
		{
            Console.WriteLine("[C#] WrapperReg.unregisterGameObject " + pObj + " BEGIN");
			if(pObj.Handle != GameObject.NULLHANDLER) {
				m_freeHandlesList.Add(pObj.Handle);
				m_list[pObj.Handle] = null;
				pObj.Handle = GameObject.NULLHANDLER;
			} else {
				throw new CKLBException("Already unregistered.");
			}
            Console.WriteLine("[C#] WrapperReg.unregisterGameObject END");
		}