예제 #1
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);
     }
 }
예제 #2
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
                });
            }
        }
예제 #3
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
         });
     }
 }
예제 #4
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;
        }
예제 #5
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);
     }
 }