Exemple #1
0
        public void Apply(Behaviour behaviour, GameObject caster)
        {
            if (!behaviour.IsIgnoresImmunity &&
                Behaviours.Any(element => (element.StatusImmunity & behaviour.StatusFlags) > 0) ||
                CombatEncounter.Active == null && behaviour.IsPreventsMovement())
            {
                AnyBehaviourImmune?.Invoke(gameObject, behaviour);
                return;
            }

            BeforeBehaviourApplied(behaviour);

            var applied = Behaviours.FirstOrDefault(b => b.Id == behaviour.Id);

            if (applied != null)
            {
                ReApply(applied, behaviour);
                return;
            }

            Behaviours.Add(behaviour);
            Behaviours = Behaviours.OrderBy(b => b.RemainingDuration).ToList();

            behaviour.Removed += OnBehaviourRemoved;
            behaviour.Apply(caster, gameObject);

            AnyBehaviourApplied?.Invoke(behaviour);
            BehaviourApplied?.Invoke(behaviour);
        }
        public async Task AddBehaviourAsync(IVectorBehaviourPlus behaviour)
        {
            if (!Behaviours.Any(b => b.UniqueReference == behaviour.UniqueReference))
            {
                Behaviours.Add(behaviour);
                UpdateFrameProcessors();

                if (Connection == ConnectedState.Connected)
                {
                    await ActOnAnyBehaviourPermanentRequirements();
                    await RegisterBehavioursAsync(new[] { behaviour });
                }

                if (behaviour.ActionOnAdded != null)
                {
                    EnqueueAction(behaviour.ActionOnAdded);
                }

                OnBehaviourEvent?.Invoke(Behaviours, BehaviourEvent.Add);
            }
        }
Exemple #3
0
 public bool IsBehaviourSetApplied(IEnumerable <Behaviour> behaviours)
 {
     return(behaviours.All(b => Behaviours.Any(bb => bb.Id == b.Id)));
 }