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); }
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; }
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); } }
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); }
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 }); } }
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); } }
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; }
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); } }