Example #1
0
        public static void ResetScripts_Command(CommandEventArgs e)
        {
            GumpFileMap = new Dictionary <string, string>();
            Gumps       = new Dictionary <string, UberGumpBase>();

            // should probably ensure all the timer stuff is restarted as appropriate
            UberScriptTimedScripts.ClearSubscriptions();

            List <XmlScript> deletedScripts = new List <XmlScript>();

            foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
            {
                XmlScript script = scriptPair.Key;
                if (script.Deleted)
                {
                    deletedScripts.Add(script);
                    continue;
                }
                // hacky way to resubscribe the timers if at all possible
                XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                // unsubscribe them
                script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                // resubscribe them to what they were previously subscribed to
                script.TimerSubscriptions = temp;
            }
            foreach (XmlScript script in deletedScripts)
            {
                XmlScript.AllScripts.Remove(script);
            }
        }
Example #2
0
 public override void OnDelete()
 {
     base.OnDelete();
     try
     {
         RemoveScriptTriggerLookup();
         AllScripts.Remove(this);
         UberScriptTimedScripts.UnsubscribeScript(this);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
     }
 }
Example #3
0
        protected override void OnTick()
        {
            base.OnTick();

            UberScriptTimedScripts.OnTick(_InternalPriority);
        }
Example #4
0
        public static void ResetScripts_Command(CommandEventArgs e)
        {
            // first reset the gumps
            ParsedGumps.GumpFileMap = new Dictionary <string, string>();
            ParsedGumps.Gumps       = new Dictionary <string, UberGumpBase>();

            List <XmlScript> deletedScripts = new List <XmlScript>();

            if (e.Arguments.Length == 0)
            {
                ScriptFileMap = new Dictionary <string, string>();
                Scripts       = new Dictionary <string, RootNode>();

                // should probably ensure all the timer stuff is restarted as appropriate
                UberScriptTimedScripts.ClearSubscriptions();
                UberScriptFunctions.Methods.StopAllLineEffectTimers();
                UberScriptFunctions.Methods.StopAllLineScriptTimers();

                foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                {
                    XmlScript script = scriptPair.Key;
                    if (script.Deleted || script.AttachedTo == null || script.AttachedTo.Deleted)
                    {
                        deletedScripts.Add(script);
                        continue;
                    }
                    // hacky way to resubscribe the timers if at all possible
                    XmlScript.TimerSubscriptionFlag temp = script.TimerSubscriptions;
                    // unsubscribe them
                    script.TimerSubscriptions = XmlScript.TimerSubscriptionFlag.None;
                    // resubscribe them to what they were previously subscribed to
                    script.TimerSubscriptions = temp;

                    script.UpdateScriptTriggerLookup();
                }
                foreach (XmlScript script in deletedScripts)
                {
                    XmlScript.AllScripts.Remove(script);
                }
                if (e.Mobile != null)
                {
                    e.Mobile.SendMessage("All scripts have been reset.");
                }
            }
            else
            {
                try
                {
                    // first, always clear out deleted scripts
                    foreach (KeyValuePair <XmlScript, bool> scriptPair in XmlScript.AllScripts)
                    {
                        XmlScript script = scriptPair.Key;
                        if (script.Deleted)
                        {
                            deletedScripts.Add(script);
                            continue;
                        }
                    }
                    foreach (XmlScript script in deletedScripts)
                    {
                        XmlScript.AllScripts.Remove(script);
                    }

                    string fileName = e.Arguments[0].ToLower();
                    string path     = Path.GetFullPath(Path.Combine(Core.BaseDirectory, ParsedScripts.UberScriptDirectory, fileName));;

                    if (Directory.Exists(path))
                    {
                        // reset all uberscripts in that directory, allow to toggle subdirectory reset too
                        bool resetSubdirectories = (e.Arguments.Length > 1 && e.Arguments[1].ToLower() == "true");
                        foreach (string file in Directory.GetFiles(path, "*.*", resetSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
                        {
                            ResetScriptFile(file, out path);
                            e.Mobile.SendMessage("All scripts connected to " + path + " were reset.");
                        }
                        if (e.Mobile != null)
                        {
                            e.Mobile.SendMessage("All scripts INSIDE the DIRECTORY " + fileName + (resetSubdirectories ? " AND its SUBDIRECTORIES" : "") + " were reset.");
                        }
                    }
                    else
                    {
                        ResetScriptFile(fileName, out path);
                        if (e.Mobile != null)
                        {
                            e.Mobile.SendMessage("All scripts connected to " + path + " were reset.");
                        }
                    }
                }
                catch (Exception except)
                {
                    if (e.Mobile != null)
                    {
                        e.Mobile.SendMessage("Exception caught: " + except.Message);
                    }
                }
            }
        }