public CharacterInstance getClosestEnemyCharacterWithHighestLife(Vector3 worldPt, CharacterInstance referenceCharacter, bool lineOfSight, float withinRadius) { CharacterInstance instance = null; double minValue = double.MinValue; float maxValue = float.MaxValue; for (int i = 0; i < this.ActiveCharacters.Count; i++) { CharacterInstance another = this.ActiveCharacters[i]; if (((((another != referenceCharacter) && !another.IsDead) && !referenceCharacter.isFriendlyTowards(another)) && !another.isInvisible()) && (!lineOfSight || this.lineOfSightCharacterToCharacter(referenceCharacter, another))) { float num4 = PhysicsUtil.DistBetween(referenceCharacter, another); if ((num4 <= withinRadius) && ((another.MaxLife(true) > minValue) || ((another.MaxLife(true) == minValue) && (num4 < maxValue)))) { instance = another; minValue = another.MaxLife(true); maxValue = num4; } } } return(instance); }
private void onCharacterTargetUpdated(CharacterInstance character, CharacterInstance oldTarget) { if (((character == GameLogic.Binder.GameState.ActiveDungeon.PrimaryPlayerCharacter) && (character.TargetCharacter != null)) && ((character.CurrentHp < character.MaxLife(true)) && (PhysicsUtil.DistBetween(character, character.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD))) { this.m_hpRegenNextTick[character] = Time.fixedTime + ConfigGameplay.PASSIVE_HP_REGEN_TICK_INTERVAL; } }