Exemple #1
0
        private void HandleAuraEffects()
        {
            for (int index = 0; index < Character.AuraEffects.Count; index++)
            {
                var removeAura = false;
                var auraEffect = Character.AuraEffects[index];
                if (auraEffect.TakeResourceAmountPerSec)
                {
                    auraEffect.ResourcePerSecTimer += Time.deltaTime;
                    if (auraEffect.ResourcePerSecTimer >= 1.0f)
                    {
                        var resourceVit = Character.GetVitalByID(auraEffect.AuraEffectStats.ResourceRequiredId);
                        if (resourceVit.CurrentValue - auraEffect.AuraEffectStats.ResourceRequirement >= 0)
                        {
                            resourceVit.CurrentValue -= auraEffect.AuraEffectStats.ResourceRequirement;
                        }
                        else
                        {
                            removeAura = true;
                        }
                        auraEffect.ResourcePerSecTimer = 0;
                    }
                }

                if (auraEffect.ApplyToAllies)
                {
                    var nearbyAllies = _controller.GetNearbyAllies(auraEffect.Radius);
                    foreach (var ally in nearbyAllies)
                    {
                        ally.Character.AddFriendlyAura(this, auraEffect);
                    }
                }

                if (!removeAura)
                {
                    if (auraEffect.PassiveEffect.RunsEvent)
                    {
                        HandleEvent(auraEffect.PassiveEffect.RunEventID);
                    }

                    if (auraEffect.PassiveEffect.RemoveStatusEffect)
                    {
                        var effectToRemove = Rm_RPGHandler.Instance.Repositories.StatusEffects.AllStatusEffects.FirstOrDefault(s => s.ID == auraEffect.PassiveEffect.RemoveStatusEffectID);
                        Character.RemoveStatusEffect(effectToRemove);
                    }
                }
                else
                {
                    Character.RemoveAuraEffect(auraEffect);
                    SpawnExpiredPrefab(auraEffect.PassiveEffect.OnExpiredPrefab);
                    Character.FullUpdateStats();
                    index--;
                }
            }
        }