static int OnEnterPool(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Pathfinding.Path obj = (Pathfinding.Path)ToLua.CheckObject <Pathfinding.Path>(L, 1); obj.OnEnterPool(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/** Adds a path to the pool. * This function should not be used directly. Instead use the Path.Claim and Path.Release functions. */ public static void Pool(Path path) { lock (pool) { if (path.pooled) { throw new System.ArgumentException("The path is already pooled."); } Stack <Path> poolStack; if (!pool.TryGetValue(path.GetType(), out poolStack)) { poolStack = new Stack <Path>(); pool[path.GetType()] = poolStack; } path.pooled = true; path.OnEnterPool(); poolStack.Push(path); } }
public static void Pool(Path path) { Dictionary <Type, Stack <Path> > pool = PathPool.pool; lock (pool) { Stack <Path> stack; if (path.pooled) { throw new ArgumentException("The path is already pooled."); } if (!PathPool.pool.TryGetValue(path.GetType(), out stack)) { stack = new Stack <Path>(); PathPool.pool[path.GetType()] = stack; } path.pooled = true; path.OnEnterPool(); stack.Push(path); } }