public bool UpdateRange(Object CurObj) { float Distance = CurObj.GetDistance(CurObj.LastRangeCheck); if (Distance > 100) { CurObj.LastRangeCheck.X = CurObj.X; CurObj.LastRangeCheck.Y = CurObj.Y; } else { return(false); } List <Object> Objects = GetRangedObject(CurObj, 1); foreach (Object DistObj in Objects) // Ici on check tous les objets visibles { if (CurObj == DistObj) { continue; } if (DistObj.IsPlayer() && !DistObj.GetPlayer().Client.IsPlaying()) { continue; } if (!CurObj.HasInRange(DistObj)) { CurObj.AddInRange(DistObj); DistObj.AddInRange(CurObj); if (CurObj.IsPlayer()) { DistObj.SendMeTo(CurObj.GetPlayer()); } if (DistObj.IsPlayer()) { CurObj.SendMeTo(DistObj.GetPlayer()); } } else { } } List <Object> ToDel = CurObj._ObjectRanged.FindAll(dist => dist != null && dist.GetDistance(CurObj) > MAX_VISIBILITY_RANGE); foreach (Object Dist in ToDel) { CurObj.RemoveInRange(Dist); Dist.RemoveInRange(CurObj); } return(true); }
public bool UpdateRange(Object CurObj, bool ForceUpdate = false) { if (CurObj.IsActive == false || CurObj.IsDisposed) { return(false); } if (CurObj.X == 0 && CurObj.Y == 0) { return(false); } float Distance = CurObj.GetDistance(CurObj.LastRangeCheck); if (Distance > 100 || ForceUpdate) { CurObj.LastRangeCheck.X = CurObj.X; CurObj.LastRangeCheck.Y = CurObj.Y; } else { return(false); } CurObj.OnRangeUpdate(); GetRangedObject(CurObj, 1, (Object DistObj) => { if (DistObj == null) { return; } if (IsVisibleBForA(CurObj, DistObj) && !CurObj.HasInRange(DistObj)) { CurObj.AddInRange(DistObj); DistObj.AddInRange(CurObj); if (CurObj.IsPlayer()) { DistObj.SendMeTo(CurObj.GetPlayer()); } if (DistObj.IsPlayer()) { CurObj.SendMeTo(DistObj.GetPlayer()); } } }); Object dist; for (int i = 0; i < CurObj._ObjectRanged.Count; ++i) { if ((dist = CurObj._ObjectRanged[i]) == null) { continue; } if (CurObj == null || dist == null) { continue; } if (dist.GetDistance(CurObj) > MAX_VISIBILITY_RANGE || !IsVisibleBForA(CurObj, dist)) { CurObj.RemoveInRange(dist); dist.RemoveInRange(CurObj); i--; } } return(true); }