/// <summary>
        /// Updates or resets the entries in the ALL items collection
        /// with the entries in the <param name="viewModels"/> parameter.
        /// </summary>
        /// <param name="updateMode">Specifies whether the ALL items collection is updated or reset.</param>
        /// <param name="viewModels"></param>
        public void SetEntries(UpdateMode updateMode = UpdateMode.Replace,
                               params VM[] viewModels)
        {
            Logger.InfoFormat("_");

            switch (updateMode)
            {
            case UpdateMode.Update:
                UpdateAllEntries(viewModels);
                break;

            case UpdateMode.Replace:
                ResetAllEntries(viewModels);
                break;

            default:
                throw new NotSupportedException(updateMode.ToString());
            }
        }
Beispiel #2
0
        public void ToXml(XmlTextWriter xw)
        {
            xw.WriteStartElement("row");

            xw.WriteAttributeString("id", ID.ToString());
            xw.WriteAttributeString("mode", Mode.ToString());

            xw.WriteStartElement("fields");
            if (Values != null)
            {
                foreach (FieldValue val in Values)
                {
                    val.ToXml(xw);
                }
            }
            // /fields
            xw.WriteEndElement();

            // /row
            xw.WriteEndElement();
        }
Beispiel #3
0
 public override string ToString()
 {
     return(Title + " - " + UpdateMode.ToString() + " (" + VersionInstalled.ToString() + " / " + VersionAvailable.ToString() + ")");
 }
Beispiel #4
0
        /// <summary>
        /// Returns a value from the client Items collection
        /// </summary>
        /// <typeparam name="TType"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public TType GetItemValue <TType>(string key)
        {
            HttpRequest Request = HttpContext.Current.Request;

            if (UpdateMode == AllowUpdateTypes.None || UpdateMode == AllowUpdateTypes.PropertiesOnly)
            {
                throw new InvalidOperationException(Resources.CanTRetrieveItemsInUpdateMode + UpdateMode.ToString());
            }

            if (Request.HttpMethod != "POST")
            {
                return(default(TType)); // throw new InvalidOperationException("GetValue can only be called during postback");
            }
            // Get the postback value which is __ + ClientObjectName
            string textValue = PostBackValue;

            if (string.IsNullOrEmpty(textValue))
            {
                return(default(TType));
            }

            // Retrieve individual Url encoded value from the buffer
            textValue = WebUtils.GetUrlEncodedKey(textValue, "_Items");
            if (string.IsNullOrEmpty(textValue))
            {
                return(default(TType));
            }

            textValue = WebUtils.GetUrlEncodedKey(textValue, key);
            if (textValue == null)
            {
                return(default(TType));
            }

            // And deserialize as JSON
            object value = JsonSerializer.Deserialize(textValue, typeof(TType));

            return((TType)value);
        }
Beispiel #5
0
        public void Generate()
        {
            if (empty)
            {
                return;
            }

            if (!Initialized)
            {
                return;
            }

            Stopwatch watch = new Stopwatch();

            watch.Start();

            //surfaceBlocksCount = 0;
            GeneratedBlocks = 0;

            int cx = Location.x;
            int cy = Location.y;
            int cz = Location.z;

            int xStart = cx * ChunkSizeX;
            int xEnd   = cx * ChunkSizeX + ChunkSizeX;

            int yStart = cy * ChunkSizeY;
            int yEnd   = cy * ChunkSizeY + ChunkSizeY;

            int zStart = cz * ChunkSizeZ;
            int zEnd   = cz * ChunkSizeZ + ChunkSizeZ;

            int globalLocX = 0;
            int globalLocY = 0;
            int globalLocZ = 0;

            int x = 0;
            int y = 0;
            int z = 0;

            int Y_Min = 0;
            int Y_Max = ChunkSizeY;

            int heightmapMin = VoxelConversions.WorldToVoxel(new Vector3(0, Math.Max(0, (float)Sampler.GetMin() - Depth), 0)).y;

            Logger.Log("heightmapMin: {0}", heightmapMin);

            int heightmapMin_local = VoxelConversions.GlobalToLocalChunkCoord(new Vector3Int(0, heightmapMin, 0)).y;

            Logger.Log("heightmapMin_local: {0}", heightmapMin_local);

            int heightmapMax = VoxelConversions.WorldToVoxel(new Vector3(0, Math.Min(SmoothVoxelSettings.MeterSizeY, (float)Sampler.GetMax()), 0)).y;

            Logger.Log("heightmapMax: {0}", heightmapMax);

            int heightmapMax_local = VoxelConversions.GlobalToLocalChunkCoord(new Vector3Int(0, heightmapMax, 0)).y;

            Logger.Log("heightmapMax_local: {0}", heightmapMax_local);

            Logger.Log("Generating with updated mode {0}: {1}", updateMode.ToString(), DebugTimer.Elapsed());

            if (updateMode == UpdateMode.EmptyToHeightmap)
            {
                return;
            }
            else if (updateMode == UpdateMode.EmptyToReduced || updateMode == UpdateMode.EmptyToFull ||
                     updateMode == UpdateMode.HeightmapToReduced || updateMode == UpdateMode.HeightmapToFull)
            {
                //Min = int.MaxValue;
                //Max = int.MinValue;
                switch (updateMode)
                {
                case UpdateMode.EmptyToReduced:
                case UpdateMode.HeightmapToReduced:
                    Y_Min   = heightmapMin_local;
                    yStart += Y_Min;
                    Y_Max   = heightmapMax_local;
                    break;

                case UpdateMode.EmptyToFull:
                case UpdateMode.HeightmapToFull:
                    Y_Max = heightmapMax_local;
                    break;
                }
            }
            else if (updateMode == UpdateMode.ReducedToFull)
            {
                Y_Max = heightmapMin_local;
                Logger.Log("ReducedToFull: " + heightmapMin_local);
            }

            //else if(updateMode == UpdateMode.)

            //if (LoadedFromDisk && !ReduceDepth && Max_Mode == LOD_Mode.Full)
            //    Y_Max = VoxelConversions.GlobalToLocalChunkCoord(VoxelConversions.WorldToVoxel(new Vector3(0, (float)Sampler.GetMin() - Depth, 0))).y;

            UnityGameServer.Logger.Log("Column: Y_Min: {0}, Y_Max: {1}", Y_Min, Y_Max);

            col_data.Allocate(ChunkSizeX, ChunkSizeY, ChunkSizeZ);
            builder.Generate(Y_Min, Y_Max, xStart, zStart);


            /*for (globalLocY = yStart, y = Y_Min; y < Y_Max; globalLocY++, y++)
             * {
             *
             *  Max = Mathf.Max(y, Max);
             *  Min = Mathf.Min(y, Min);
             *
             *  for (globalLocZ = zStart, z = 0; z < ChunkSizeZ; globalLocZ++, z++)
             *  {
             *      for (globalLocX = xStart, x = 0; x < ChunkSizeX; globalLocX++, x++)
             *      {
             *          if (deactivated)
             *          {
             *              break;
             *          }
             *
             *          Vector3 worldPos = new Vector3(x * xSideLength, y * ySideLength, z * zSideLength);
             *          Vector3Int globalPos = new Vector3Int(globalLocX * skipDist, globalLocY * skipDist, globalLocZ * skipDist);
             *          Vector3Int localPos = new Vector3Int(x, y, z);
             *          GridPoint[] grid = new GridPoint[8];
             *          for (int i = 0; i < grid.Length; i++)
             *              grid[i] = GetGridPoint(worldPos + locOffset[i], localPos + directionOffsets[i], globalPos + globalOffsets[i]);
             *          ProcessBlock(grid, 0);
             *          GeneratedBlocks++;
             *      }
             *  }
             * }*/

            watch.Stop();
            Logger.Log("Generated from {0} to {1}: " + DebugTimer.Elapsed(), Y_Min, Y_Max);
            Logger.Log("Generated surface blocks: {0}", col_data.surfaceBlocksCount);
        }