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