public SightTargetAggroInfo GetAggroForTarget(ISightTarget target) { if (aggroDict.ContainsKey(target) == false || target.IsDestroyed()) { return(null); } return(aggroDict[target]); }
protected virtual void UpdateAggro() { ForgetTargetsNow(); // In case some were queued up. var before = _targetWithHighestAggro; _targetWithHighestAggro = null; float targetsHighestAggro = 0f; foreach (var keyValuePair in aggroDict) { // if (keyValuePair.Key.enabled == false) // { // if (_targetWithHighestAggro == keyValuePair.Key) // { // _targetWithHighestAggro = null; // } // // continue; // } if (keyValuePair.Key.IsDestroyed()) { ForgetTarget(keyValuePair.Key); continue; } keyValuePair.Value.modulesValue = 0f; foreach (var module in _aggroModules) { if (ReferenceEquals(module, null) || module.Equals(null) || module.enabled == false) { continue; } keyValuePair.Value.modulesValue += module.CalculateAggroForTarget(keyValuePair.Key); if (_targetWithHighestAggro == null || _targetWithHighestAggro.IsDestroyed() || keyValuePair.Value.finalValue > targetsHighestAggro) { _targetWithHighestAggro = keyValuePair.Key; targetsHighestAggro = keyValuePair.Value.finalValue; } } } if (before != _targetWithHighestAggro) { NotifyTargetWithHighestAggroChanged(_targetWithHighestAggro, targetsHighestAggro); } ForgetTargetsNow(); // After updating some modules may want to forget a target. }