Example #1
0
        private static void onTimer(object state)
        {
            lock (homeLock)
            {
                read();

                int num_of_paths = DrawingStore.GetNumberOfPaths(homeBlockIndex.X, homeBlockIndex.Y);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                num_of_paths = DrawingStore.GetNumberOfPaths(homeBlockIndex.X, homeBlockIndex.Y + 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                num_of_paths = DrawingStore.GetNumberOfPaths(homeBlockIndex.X, homeBlockIndex.Y - 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                homeBlockIndex.X++;
                write();
            }
        }
Example #2
0
        private static void updateRoomHome(string name)
        {
            RoomInfoEntity entity = RoomStore.GetRoom(name);

            if (entity != null)
            {
                int num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

#if GO_SLOWER
                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY + 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }

                num_of_paths = DrawingStore.GetNumberOfPaths(entity.HomeX, entity.HomeY - 1);
                if (num_of_paths < Config.MOVE_HOME_THRESHOLD)
                {
                    return;
                }
#endif
                if (entity.HomeX < 0)
                {
                    if (entity.HomeY < 0)
                    {
                        entity.HomeX--;
                    }
                    else
                    {
                        entity.HomeY++;
                    }
                }
                else
                if (entity.HomeY < 0)
                {
                    entity.HomeY--;
                }
                else
                {
                    entity.HomeX++;
                }

                Warehouse.RoomsTable.Execute(TableOperation.Replace(entity));                      // Throws StorageException ((412) Precondition Failed) if the entity is modified in between.

                RoomsPond.Notify(name);
            }
        }
Example #3
0
        public int AddPath(PathModel model)
        {
            int ret = DrawingStore.AddPath(model);

            if (ret == 0 || ret == 3)
            {
                string         key = Config.DRAWING_PAR_KEY_PREFIX + model.BlockIndexX.ToString() + ',' + model.BlockIndexY.ToString();
                BlockPathsRoll obj = (BlockPathsRoll)HttpRuntime.Cache.Get(key);

                if (obj != null)
                {
                    obj.AddPath(model);
                }
            }
            return(ret);
        }
Example #4
0
 public BlockPathsRoll(string key)
 {
     DrawingStore.GetStoredPaths(key, entity => addPath(entity));
 }