public bool IsVisibleBForA(Object a, Object b) { if (a == null || b == null || a.IsDisposed || b.IsDisposed) { return(false); } if (a == b || !a.IsActive || !b.IsActive || !b.IsVisible) { return(false); } if (b.IsPlayer() && (b.GetPlayer().Client == null || !b.GetPlayer().Client.IsPlaying())) { return(false); } return(true); }
public void RemoveObject(Object obj) { //Log.Success("RemoveObject", "[" + X + "," + Y + "] Cell Remove " + Obj.Name); if (obj._Cell == this) { if (obj.IsPlayer()) { Players.Remove(obj.GetPlayer()); } Objects.Remove(obj); obj._Cell = null; } }
public bool UpdateRange(Object curObj, bool forceUpdate = false) { if (!curObj.IsActive || curObj.IsDisposed) { return(false); } if (curObj.X == 0 && curObj.Y == 0) { return(false); } float distance = curObj.Get2DDistanceToWorldPoint(curObj.LastRangeCheck); if (distance > 100 || forceUpdate) { curObj.LastRangeCheck.X = curObj.WorldPosition.X; curObj.LastRangeCheck.Y = curObj.WorldPosition.Y; } else { return(false); } curObj.OnRangeUpdate(); GetRangedObject(curObj, 1, 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 (var i = 0; i < curObj.ObjectsInRange.Count; ++i) { if ((dist = curObj.ObjectsInRange[i]) == null) { continue; } if (dist.Get2DDistanceToObject(curObj) > MaxVisibilityRange || !IsVisibleBForA(curObj, dist)) { curObj.RemoveInRange(dist); dist.RemoveInRange(curObj); i--; } } return(true); }