Ejemplo n.º 1
0
        private void UpdateAvoidances()
        {
            _currentRActorIds.Clear();

            if (!Settings.Entries.Any(s => s.IsEnabled))
            {
                return;
            }

            var source = Core.Actors.Actors.ToList();

            foreach (var actor in source)
            {
                if (actor == null)
                {
                    continue;
                }

                var rActorId = actor.RActorId;

                TrinityActor existingActor;

                _currentRActorIds.Add(rActorId);

                var isValid = actor.IsValid;

                if (_cachedActors.TryGetValue(rActorId, out existingActor))
                {
                    if (!isValid)
                    {
                        _cachedActors.Remove(rActorId);
                    }
                    else
                    {
                        //Core.Logger.Verbose($"Updated Avoidance Actor {actor}");
                        //existingActor.Position = actor.Position;
                        //existingActor.Distance = actor.Distance;
                        //existingActor.Animation = actor.Animation;
                    }
                    continue;
                }

                if (!isValid)
                {
                    continue;
                }

                Structures.Avoidance avoidance;
                if (AvoidanceFactory.TryCreateAvoidance(source, actor, out avoidance))
                {
                    Core.Logger.Log(LogCategory.Avoidance, $"Created new Avoidance from {actor.InternalName} RActorId={actor.RActorId} ({avoidance.Definition.Name}, Immune: {avoidance.IsImmune})");
                    _cachedActors.Add(rActorId, actor);
                    CurrentAvoidances.Add(avoidance);
                }
            }
        }
Ejemplo n.º 2
0
        private void UpdateAvoidances()
        {
            _currentRActorIds = new HashSet <int>();
            foreach (var actor in Core.Actors.Actors)
            {
                if (actor == null || !actor.IsValid)
                {
                    continue;
                }

                var id = actor.RActorId;
                _currentRActorIds.Add(id);

                if (!CurrentAvoidances.Any(c => c.RActorId == id))
                {
                    Structures.Avoidance avoidance;
                    if (AvoidanceFactory.TryCreateAvoidance(actor, out avoidance))
                    {
                        Core.Logger.Log(LogCategory.Avoidance, $"Created new Avoidance from {actor.InternalName} RActorId={actor.RActorId} ({avoidance.Definition.Name}, Immune: {avoidance.IsImmune})");
                        CurrentAvoidances.Add(avoidance);
                    }
                }
            }
        }