Esempio n. 1
0
        private void OnSpellLaunch(Unit caster, int spellId, SpellProcessingToken processingToken)
        {
            if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo))
            {
                return;
            }

            if (!unitRendererController.TryFind(caster.Id, out UnitRenderer casterRenderer))
            {
                return;
            }

            if (!spellInfo.HasAttribute(SpellCustomAttributes.CastWithoutAnimation))
            {
                casterRenderer.TriggerInstantCast();
            }

            if (!SpellVisuals.TryGetValue(spellId, out SpellVisualsInfo spellVisuals))
            {
                return;
            }

            if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Projectile, out EffectSpellSettings settings))
            {
                foreach (var entry in processingToken.ProcessingEntries)
                {
                    if (unitRendererController.TryFind(entry.Item1, out UnitRenderer targetRenderer))
                    {
                        spellVisualController.SpawnVisual(casterRenderer, targetRenderer, settings, processingToken.ServerFrame, entry.Item2);
                    }
                }
            }

            if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Cast, out EffectSpellSettings spellVisualEffect))
            {
                IEffectEntity effectEntity = spellVisualEffect.EffectSettings.PlayEffect(processingToken.Source + Vector3.up, caster.Rotation);
                if (effectEntity != null && !spellInfo.HasAttribute(SpellCustomAttributes.LaunchSourceIsExplicit))
                {
                    effectEntity.ApplyPositioning(casterRenderer.TagContainer, spellVisualEffect);
                }
            }

            if (spellInfo.ExplicitTargetType == SpellExplicitTargetType.Destination)
            {
                if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Destination, out EffectSpellSettings destinationEffect))
                {
                    destinationEffect.EffectSettings.PlayEffect(processingToken.Destination + Vector3.up, caster.Rotation);
                }
            }
        }
Esempio n. 2
0
        private void OnSpellHit(Unit target, int spellId)
        {
            if (!unitRendererController.TryFind(target.Id, out UnitRenderer targetRenderer))
            {
                return;
            }

            if (!SpellVisuals.TryGetValue(spellId, out SpellVisualsInfo spellVisuals))
            {
                return;
            }

            if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Impact, out EffectSpellSettings spellVisualEffect))
            {
                IEffectEntity effectEntity = spellVisualEffect.EffectSettings.PlayEffect(target.Position, target.Rotation);
                effectEntity?.ApplyPositioning(targetRenderer.TagContainer, spellVisualEffect);
            }
        }