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; } }
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)); }
public static Cluster ClusterFromPosition(ClusterPos pos) { if (!Clusters.ContainsKey(pos)) { return(null); } return(Clusters[pos]); }
public override bool Equals(object obj) { ClusterPos p = obj as ClusterPos; if (p == null) { return(false); } return(p.H == H && p.V == V); }
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]); }
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); }
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)); }
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)); }
public ClusterPos(ClusterPos pos) { H = pos.H; V = pos.V; }
public virtual bool PreloadCluster(ClusterPos pos) { return(false); }