public void UpdateUnitPointLists(ClusterConditions CC) { if (ListUnits.Count == 0) { return; } List <int> RemovalIndexList = new List <int>(); bool changeOccured = false; foreach (var item in ListUnits) { if (!item.IsStillValid() || (!CC.IgnoreNonTargetable || !item.IsTargetable.Value)) { RemovalIndexList.Add(ListUnits.IndexOf(item)); RAGUIDS.Remove(item.RAGUID); changeOccured = true; } } if (changeOccured) { RemovalIndexList.Sort(); RemovalIndexList.Reverse(); foreach (var item in RemovalIndexList) { //ListCacheObjects.RemoveAt(item); ListUnits.RemoveAt(item); ListPoints.RemoveAt(item); } if (ListUnits.Count > 1) { //Logger.DBLog.InfoFormat("Updating Cluster"); //Reset Vars Info = new ClusterInfo(); NearestMonsterDistance = -1f; //Set default using First Unit CacheUnit firstUnit = ListUnits[0]; MidPoint = firstUnit.PointPosition; RAGUIDS.Add(firstUnit.RAGUID); NearestMonsterDistance = firstUnit.CentreDistance; Info.Update(ref firstUnit); //Iterate thru the remaining for (int i = 1; i < ListUnits.Count - 1; i++) { this.UpdateProperties(ListUnits[i]); } } } }
/// <summary> /// Adds point to this cluster only if it is "reachable" /// (if point is inside a circle of radius Dist of any cluster's points ) /// </summary> /// <returns>false if point can't be added (that is either already in cluster /// or it is unreachable from any of the cluster's points)</returns> internal virtual bool AddObject(CacheObject obj) { bool l_bSuccess = true; if (!ContainsObject(obj) && IsPointReachable(obj.PointPosition)) { ListCacheObjects.Add(obj); ListPoints.Add(obj.PointPosition); RAGUIDS.Add(obj.RAGUID); MidPoint += obj.PointPosition; } else { l_bSuccess = false; } return(l_bSuccess); } // of AddPoint()