private void Calculate() { //will prevent spam of location packets if (ExtDatetime.Utc - _lastCalcMs < RecalculateMinimalDelay) { return; } var allCreatures = Owner.Area.GetObjectsInRange(Owner.Position, MaximalVisibleRange); for (int i = 0; i < allCreatures.Count; i++) { var aVisibleObject = allCreatures[i]; if (CanSeeObject(aVisibleObject)) { if (_objectsThatISee.AddIfNotPresent(aVisibleObject)) { aVisibleObject.VisibleAi._objectThatSeeMe.AddIfNotPresent(Owner); } } else if (_objectsThatISee.Remove(aVisibleObject)) { aVisibleObject.VisibleAi._objectThatSeeMe.Remove(Owner); } if (aVisibleObject.VisibleAi.CanSeeObject(Owner)) { if (aVisibleObject.VisibleAi._objectsThatISee.AddIfNotPresent(Owner)) { _objectThatSeeMe.AddIfNotPresent(aVisibleObject); } } else { aVisibleObject.VisibleAi._objectsThatISee.Remove(Owner); _objectThatSeeMe.Remove(aVisibleObject); } } _objectsThatISee.ParallelAction(element => { if (!CanSeeObject(element)) { _objectsThatISee.Remove(element); element.VisibleAi._objectThatSeeMe.Remove(element); } }); _lastCalcMs = ExtDatetime.Utc; }
public bool PlaceToArea(ABdoObject obj) { return(_objects.AddIfNotPresent(obj)); }