public static bool CanLoad(ClusterPos pos) { float now = Urho.Application.Current.Time.ElapsedTime; // if (now - LastLoad < MinLoadTime) // return false; lock (LoadPriority) { if (LoadPriority.Count == 0) { if (LoadCount >= LoadLimit) { return(false); } LoadCount++; LastLoad = now; return(true); } int index = LoadPriority.IndexOf(pos); if (index >= 0 && index < LoadLimit) { LoadPriority.RemoveAt(index); LoadCount++; LastLoad = now; return(true); } return(false); } }
public static void SetOrigin(Int64 h, Int64 v) { ClusterPos oldOriign = CurrentOrigin; CurrentOrigin = new ClusterPos(h, v); OriginChanged?.Invoke(oldOriign, CurrentOrigin); }
private static void ForceClusterLoad(ClusterPos origin, int h, int v, bool display) { var newPos = origin.Offset(h, v); var cluster = World.ClusterFromPosition(newPos); if (cluster == null) { // it's off the current map, flag it for generation, another cycle will pick it up NeedCluster?.Invoke(newPos); return; } if (!display) { return; } cluster.AliveCount = ClusterZombieTime; var status = cluster.GetStatus(); if (status == Cluster.Statuses.Raw || status == Cluster.Statuses.GeometryBound || status == Cluster.Statuses.GeometryPending) { return; // it's good to go, or is waiting on generation } if (status == Cluster.Statuses.GeometryCreated) { // the geo was created, it just isn't bound, tell the Urho component to put a load in the pipe cluster.RequestBinding(); LoadLimiter.AddLoadPriority(cluster.Origin); return; } GeoLoadManager.GenerateGeometry(cluster, null, (c, t) => { LoadLimiter.AddLoadPriority(cluster.Origin); }); }
private void GeoLoadManager_OriginChanged(ClusterPos oldOrigin, ClusterPos newOrigin) { if (WorldPos == null) { return; } Node.SetWorldPosition(new Vector3((float)(WorldPos.H - newOrigin.H) + Offset.X, Offset.Y, (float)(WorldPos.V - newOrigin.V) + Offset.Z)); }
public static void AddLoadPriority(ClusterPos pos) { lock (LoadPriority) { if (!LoadPriority.Contains(pos)) { LoadPriority.Add(pos); } } }
private void GeoLoadManager_OriginChanged(ClusterPos oldOrigin, ClusterPos newOrigin) { float dh = newOrigin.H - oldOrigin.H; float dv = newOrigin.V - oldOrigin.V; float newPX = Node.Position.X - dh; float newPZ = Node.Position.Z - dv; Node.SetWorldPosition(new Vector3(newPX, Node.Position.Y, newPZ)); UpdateWorldPos(); }
private static void ForceRingLoad(int radius, ClusterPos origin, bool display) { int radUnits = radius * Cluster.HVSize; for (int i = 0; i <= radUnits; i += Cluster.HVSize) { ForceClusterLoad(origin, radUnits, i, display); ForceClusterLoad(origin, -radUnits, i, display); ForceClusterLoad(origin, i, radUnits, display); ForceClusterLoad(origin, i, -radUnits, display); // if (i != 0) { ForceClusterLoad(origin, radUnits, -i, display); ForceClusterLoad(origin, -radUnits, -i, display); ForceClusterLoad(origin, -i, radUnits, display); ForceClusterLoad(origin, -i, -radUnits, display); } } }