private void HandleSpellCast(Event request, int spellId, MovementFlags movementFlags, Vector3?destination = null)
        {
            Player caster = World.FindPlayer(request.RaisedBy);
            SpellCastRequestAnswerEvent spellCastAnswer = request.FromSelf
                ? SpellCastRequestAnswerEvent.Create(GlobalTargets.OnlyServer)
                : SpellCastRequestAnswerEvent.Create(request.RaisedBy);

            spellCastAnswer.SpellId = spellId;

            if (caster == null)
            {
                spellCastAnswer.Result = (int)SpellCastResult.CasterNotExists;
                spellCastAnswer.Send();
                return;
            }

            if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo))
            {
                spellCastAnswer.Result = (int)SpellCastResult.SpellUnavailable;
                spellCastAnswer.Send();
                return;
            }

            SpellCastingOptions options = destination.HasValue
                ? new SpellCastingOptions(new SpellExplicitTargets {
                Destination = destination.Value
            })
                : new SpellCastingOptions(movementFlags: movementFlags);

            SpellCastResult castResult = caster.Spells.CastSpell(spellInfo, options);

            if (castResult != SpellCastResult.Success)
            {
                spellCastAnswer.Result = (int)castResult;
                spellCastAnswer.Send();
            }
        }
示例#2
0
 float IPriorityCalculator.CalculateEventPriority(BoltConnection connection, Bolt.Event evnt)
 {
     return((float)((base.state.State != 2) ? 256 : 8192));
 }
示例#3
0
 float IPriorityCalculator.CalculateEventPriority(BoltConnection connection, Bolt.Event evnt)
 {
     return(CoopUtils.CalculatePriorityFor(connection, base.entity, 1f, 1));
 }
示例#4
0
 float IPriorityCalculator.CalculateEventPriority(BoltConnection connection, Bolt.Event evnt)
 {
     return(CoopUtils.CalculatePriorityFor(connection, this.entity, this.MultiplayerPriority, 1));
 }