Exemplo n.º 1
0
        public bool RunPower(Actor user, PowerScript power, Actor target = null,
                             Vector3D targetPosition = null, TargetMessage targetMessage = null)
        {
            // replace power with existing channel instance if one exists
            if (power is ChanneledSkill)
            {
                var existingChannel = _FindChannelingSkill(user, power.PowerSNO);
                if (existingChannel != null)
                {
                    power = existingChannel;
                }
                else  // new channeled skill, add it to the list
                {
                    _channeledSkills.Add((ChanneledSkill)power);
                }
            }

            // copy in context params
            power.User           = user;
            power.Target         = target;
            power.World          = user.World;
            power.TargetPosition = targetPosition;
            power.TargetMessage  = targetMessage;

            _StartScript(power);
            return(true);
        }
Exemplo n.º 2
0
        public bool RunPower(Actor user, PowerScript power, Actor target = null,
                             Vector3D targetPosition = null, TargetMessage targetMessage = null)
        {
            // replace power with existing channel instance if one exists
            if (power is ChanneledSkill)
            {
                var existingChannel = _FindChannelingSkill(user, power.PowerSNO);
                if (existingChannel != null)
                {
                    power = existingChannel;
                }
                else  // new channeled skill, add it to the list
                {
                    _channeledSkills.Add((ChanneledSkill)power);
                }
            }

            // copy in context params
            power.User = user;
            power.Target = target;
            power.World = user.World;
            power.TargetPosition = targetPosition;
            power.TargetMessage = targetMessage;

            _StartScript(power);
            return true;
        }
Exemplo n.º 3
0
 private void _StartScript(PowerScript script)
 {
     //TODO: If any executing script starts another script this needs to be executed in it's own thread as it will create a circular multi-threading lock
     lock (_locker)
     {
         //wait for Update if in progress
         while (!_go)
         {
             Monitor.Wait(_locker);
         }
         //Block updates and everything else until full addition of effects is done.
         //Otherwise yield returns that have a wait timer will mess up update collection and block forever
         _go = false;
         var powerEnum = script.Run().GetEnumerator();
         if (powerEnum.MoveNext() && powerEnum.Current != PowerScript.StopExecution)
         {
             _executingScripts.Add(new ExecutingScript
             {
                 PowerEnumerator = powerEnum,
                 Script          = script
             });
         }
         //Release all threads waiting on this
         _go = true;
         Monitor.PulseAll(_locker);
     }
 }
Exemplo n.º 4
0
 public PowerAction(Actor owner, int powerSNO)
     : base(owner)
 {
     _power = PowerLoader.CreateImplementationForPowerSNO(powerSNO);
     _power.User = owner;
     _powerRan = false;
     _baseAttackRadius = this.Owner.ActorData.Cylinder.Ax2 + _power.EvalTag(PowerKeys.AttackRadius) + 1.5f;
     _ownerMover = new ActorMover(owner);
 }
Exemplo n.º 5
0
        private void _StartScript(PowerScript script)
        {
            var powerEnum = script.Run().GetEnumerator();

            if (powerEnum.MoveNext() && powerEnum.Current != PowerScript.StopExecution)
            {
                _executingScripts.Add(new ExecutingScript
                {
                    PowerEnumerator = powerEnum,
                    Script          = script
                });
            }
        }
Exemplo n.º 6
0
 public static PowerScript CreateImplementationForPowerSNO(int powerSNO)
 {
     if (_implementations.ContainsKey(powerSNO))
     {
         PowerScript script = (PowerScript)Activator.CreateInstance(_implementations[powerSNO]);
         script.PowerSNO = powerSNO;
         return(script);
     }
     else
     {
         Logger.Debug("Unimplemented power: {0}", powerSNO);
         return(null);
     }
 }
Exemplo n.º 7
0
        public bool UsePower(Actor user, PowerScript power, Actor target = null,
                             Vector3D targetPosition = null, TargetMessage targetMessage = null)
        {
            // replace power with existing channel instance if one exists
            if (power is ChanneledPower)
            {
                var chanpow = _FindChannelingPower(user, power.PowerSNO);
                if (chanpow != null)
                    power = chanpow;
            }

            // copy in context params
            power.User = user;
            power.Target = target;
            power.World = user.World;
            power.TargetPosition = targetPosition;
            power.TargetMessage = targetMessage;

            // process channeled power events
            var channeledPower = power as ChanneledPower;
            if (channeledPower != null)
            {
                if (channeledPower.ChannelOpen)
                {
                    channeledPower.OnChannelUpdated();
                }
                else
                {
                    channeledPower.OnChannelOpen();
                    channeledPower.ChannelOpen = true;
                    _channeledPowers.Add(channeledPower);
                }
            }

            var powerEnum = power.Run().GetEnumerator();
            // actual power will first run here, if it yielded a timer process it in the waiting list
            if (powerEnum.MoveNext() && powerEnum.Current != PowerScript.StopExecution)
            {
                _waitingPowers.Add(new WaitingPower
                {
                    PowerEnumerator = powerEnum,
                    Implementation = power
                });
            }

            return true;
        }
Exemplo n.º 8
0
 private void _StartScript(PowerScript script)
 {
     var powerEnum = script.Run().GetEnumerator();
     if (powerEnum.MoveNext() && powerEnum.Current != PowerScript.StopExecution)
     {
         _executingScripts.Add(new ExecutingScript
         {
             PowerEnumerator = powerEnum,
             Script = script
         });
     }
 }
Exemplo n.º 9
0
 private void _StartScript(PowerScript script)
 {
     //TODO: If any executing script starts another script this needs to be executed in it's own thread as it will create a circular multi-threading lock
     lock (_locker)
     {
         //wait for Update if in progress
         while (!_go)
             Monitor.Wait(_locker);
         //Block updates and everything else until full addition of effects is done. 
         //Otherwise yield returns that have a wait timer will mess up update collection and block forever
         _go = false;
         var powerEnum = script.Run().GetEnumerator();
         if (powerEnum.MoveNext() && powerEnum.Current != PowerScript.StopExecution)
         {
             _executingScripts.Add(new ExecutingScript
             {
                 PowerEnumerator = powerEnum,
                 Script = script
             });
         }
         //Release all threads waiting on this
         _go = true;
         Monitor.PulseAll(_locker);
     }
 }