Exemplo n.º 1
0
            public void EnqueCluster(ClusterPos pos)
            {
                try
                {
                    Cluster newCluster = new Cluster();
                    newCluster.Origin = pos;

                    if (!UseThreads)
                    {
                        DynamicTerrainCluster(newCluster);
                        newCluster.FinalizeGeneration();
                    }
                    else
                    {
                        ThreadPool.QueueUserWorkItem(x => { DynamicTerrainCluster(newCluster); newCluster.FinalizeGeneration(); });
                    }

                    World.Clusters.Add(newCluster.Origin, newCluster);
                    PushNewCluster(newCluster);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
Exemplo n.º 2
0
        public static float DropDepth(float positionH, float positionV)
        {
            ClusterPos pos = new ClusterPos(AxisToGrid((int)positionH), AxisToGrid((int)positionV));

            if (!Clusters.ContainsKey(pos))
            {
                return(float.MinValue);
            }

            Cluster c = Clusters[pos];

//             Int64 x = (Int64)positionH - pos.H;
//             Int64 y = (Int64)positionV - pos.V;
//
//             float blockH = positionH - pos.H;
//             float blockV = positionV - pos.V;
//
//             for (int d = Cluster.DSize - 1; d >= 0; d--)
//             {
//                 float value = c.GetBlockRelative(x, y, d).GetDForLocalPosition(blockH - x, blockV - y);
//                 if (value != float.MinValue)
//                     return d + value;
//             }

            return(c.DropDepth(positionH - pos.H, positionV - pos.V));
        }
Exemplo n.º 3
0
        public static Cluster ClusterFromPosition(ClusterPos pos)
        {
            if (!Clusters.ContainsKey(pos))
            {
                return(null);
            }

            return(Clusters[pos]);
        }
Exemplo n.º 4
0
        public override bool Equals(object obj)
        {
            ClusterPos p = obj as ClusterPos;

            if (p == null)
            {
                return(false);
            }

            return(p.H == H && p.V == V);
        }
Exemplo n.º 5
0
        public static Cluster NeighborCluster(ClusterPos origin, int offsetH, int offsetV, int offsetD)
        {
            ClusterPos pos = origin.OffsetGrid(offsetH, offsetV);

            if (!Clusters.ContainsKey(pos))
            {
                return(null);
            }

            return(Clusters[pos]);
        }
Exemplo n.º 6
0
        public static bool PositionIsOffMap(Int64 h, Int64 v, Int64 d)
        {
            if (d >= Cluster.DSize || d < 0)
            {
                return(true);
            }

            ClusterPos pos = new ClusterPos(AxisToGrid(h), AxisToGrid(v));

            if (!Clusters.ContainsKey(pos))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public static Block BlockFromPosition(Int64 h, Int64 v, Int64 d)
        {
            if (d >= Cluster.DSize || d < 0)
            {
                return(Block.Invalid);
            }

            ClusterPos pos = new ClusterPos(AxisToGrid(h), AxisToGrid(v));

            if (!Clusters.ContainsKey(pos))
            {
                return(Block.Invalid);
            }

            return(Clusters[pos].GetBlockAbs(h, v, d));
        }
Exemplo n.º 8
0
        public static Block BlockFromRelativePosition(Cluster cluster, Int64 h, Int64 v, Int64 d)
        {
            if (d >= Cluster.DSize || d < 0)
            {
                return(Block.Invalid);
            }

            if (h >= 0 && h < Cluster.HVSize && v >= 0 && v < Cluster.HVSize)
            {
                return(cluster.GetBlockRelative(h, v, d));
            }

            ClusterPos pos = new ClusterPos(AxisToGrid(cluster.Origin.H + h), AxisToGrid(cluster.Origin.V + v));

            if (!Clusters.ContainsKey(pos))
            {
                return(Block.Invalid);
            }

            return(Clusters[pos].GetBlockAbs(cluster.Origin.H + h, cluster.Origin.V + v, d));
        }
Exemplo n.º 9
0
 public ClusterPos(ClusterPos pos)
 {
     H = pos.H; V = pos.V;
 }
Exemplo n.º 10
0
 public virtual bool PreloadCluster(ClusterPos pos)
 {
     return(false);
 }