private void OnAnyEpisodeComplete(Episode episode) { foreach (var behaviour in Behaviours.Where(behaviour => behaviour.IsPreventsMovement()).ToList()) { RemoveStack(behaviour, behaviour.StackCount); } }
private void OnAnySkillUsed(SkillUseEventData data) { var behaviours = Behaviours.Where(b => b.Flags.HasFlag(BehaviourFlags.BreaksOnCast) && b.Caster == data.Caster).ToList(); foreach (var behaviour in behaviours) { if (!behaviour.CanBeRemovedOnCast) { continue; } RemoveStack(behaviour, behaviour.StackCount); } // Skills triggering "AnySkillUsed" event right after behaviour is applied. Timer.Instance.WaitForEndOfFrame(() => { foreach (var behaviour in behaviours) { if (behaviour.CanBeRemovedOnCast) { continue; } behaviour.CanBeRemovedOnCast = true; } }); }
private void OnDealDamage(EntityDamagedEventData data) { if (data.Damage.Amount < 1) { return; } Timer.Instance.WaitForFixedUpdate(() => { foreach (var behaviour in Behaviours.Where( behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnDealDamage)).ToList()) { RemoveStack(behaviour, behaviour.StackCount); } if (!data.Damage.Flags.HasFlag(DamageFlags.DOT)) { foreach (var behaviour in Behaviours.Where( behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnDealDirectDamage)).ToList()) { RemoveStack(behaviour, behaviour.StackCount); } } }); }
private void RemoveBehaviours(Func <Behaviour, bool> predicate = null) { Behaviours .Where(behaviour => predicate?.Invoke(behaviour) ?? true) .ToList() .ForEach(behaviour => behaviour.Remove(behaviour.StackCount)); }
public int GetStackCount(int behaviourId) { return(Behaviours .Where(b => b.Id == behaviourId) .Select(b => b.StackCount) .DefaultIfEmpty(0) .Sum()); }
private void OnAnyEntityDied(EntityDiedEventData data) { foreach (var behaviour in Behaviours.Where(behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnCasterDeath) && behaviour.Caster == data.Victim).ToList()) { RemoveStack(behaviour, behaviour.StackCount); } }
private void BeforeBehaviourApplied(Behaviour applied) { if (!applied.IsPreventsActions()) { return; } foreach (var behaviour in Behaviours.Where(behaviour => behaviour.Flags.HasFlag(BehaviourFlags.BreaksOnCrowdControl)).ToList()) { RemoveAllStacks(behaviour.Id); } }
private void UpdateFrameProcessors() { var requiredTypes = new List <Type>(); var fb = Behaviours.Count(); var requestedTypes = Behaviours.Where(b => b.RequestedFrameProcessors != null).SelectMany(b => b.RequestedFrameProcessors); if (requestedTypes != null) { requiredTypes.AddRange(requestedTypes.Distinct()); } var presentTypes = FrameProcessors.Select(p => p.GetType()).Distinct(); var toRemove = presentTypes.Where(t => !requiredTypes.Contains(t)).ToList(); var toAdd = requiredTypes.Where(t => !presentTypes.Contains(t)); FrameProcessors.Where(p => toRemove.Contains(p.GetType())).ToList().ForEach(p => p.Dispose()); FrameProcessors.RemoveAll(p => toRemove.Contains(p.GetType())); FrameProcessors.AddRange(toAdd.Select(t => (ICameraFrameProcessor)Activator.CreateInstance(t))); }
public async Task RemoveBehaviourAsync(string reference) { var found = Behaviours.Where(b => b.UniqueReference == reference).ToList(); Behaviours.RemoveAll(b => b.UniqueReference == reference); UpdateFrameProcessors(); if (Connection == ConnectedState.Connected) { foreach (var behaviour in found) { if (behaviour.ActionOnRemoved != null) { EnqueueAction(behaviour.ActionOnRemoved); } } await ActOnAnyBehaviourPermanentRequirements(); await UnregisterBehavioursAsync(found); } OnBehaviourEvent?.Invoke(Behaviours, BehaviourEvent.Remove); }
private List <Behaviour> GetBehavioursByType(EBehaviourType type) => Behaviours.Where(_ => _.BehaviourType == type).ToList();
public IEnumerable <BaseBehaviour> GetBehavioursByType(Type behType) => Behaviours.Where(b => b.GetType() == behType);
private List <Behaviour> GetBehavioursByType(EBehaviourType type) => Behaviours.Where(_ => _.BehaviourType.Equals(type)).ToList();