diff options
| author | Michael VanOverbeek <[email protected]> | 2017-06-11 11:57:31 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-06-11 11:57:31 +0000 |
| commit | 997a81457ebb6d6523c36ca552cee143e0d92244 (patch) | |
| tree | da98985ced112b6d238811f3ca770014d67e34fc /ShiftOS_TheReturn/Story.cs | |
| parent | 0d75f701778a0900a58343c4c80c124279bc231f (diff) | |
| parent | 107a98686a105468b5f200ebcbd27343c1210ce4 (diff) | |
| download | shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.gz shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.bz2 shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.zip | |
Merge pull request #129 from RogueAI42/master
ReflectMan Saves The Day..............
Diffstat (limited to 'ShiftOS_TheReturn/Story.cs')
| -rw-r--r-- | ShiftOS_TheReturn/Story.cs | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index e44d2be..c01c055 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -134,55 +134,42 @@ namespace ShiftOS.Engine /// <param name="stid">The storyline ID to start.</param> public static void Start(string stid) { - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + if (SaveSystem.CurrentSave.StoriesExperienced == null) + SaveSystem.CurrentSave.StoriesExperienced = new List<string>(); + foreach (var type in ReflectMan.Types) { - if(exec.EndsWith(".exe") || exec.EndsWith(".dll")) + foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { - try + foreach (var attrib in Array.FindAll(mth.GetCustomAttributes(false), a => a is StoryAttribute)) { - if (SaveSystem.CurrentSave.StoriesExperienced == null) - SaveSystem.CurrentSave.StoriesExperienced = new List<string>(); - var asm = Assembly.LoadFile(exec); - foreach(var type in asm.GetTypes()) + var story = attrib as StoryAttribute; + if (story.StoryID == stid) { - foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + new Thread(() => { - foreach(var attrib in mth.GetCustomAttributes(false)) + Context = new Engine.StoryContext { - if(attrib is StoryAttribute) - { - var story = attrib as StoryAttribute; - if(story.StoryID == stid) - { - new Thread(() => - { - Context = new Engine.StoryContext - { - Id = stid, - Method = mth, - AutoComplete = true, - }; - SaveSystem.CurrentSave.PickupPoint = Context.Id; - Context.OnComplete += () => - { - StoryComplete?.Invoke(stid); - SaveSystem.CurrentSave.PickupPoint = null; - }; - mth.Invoke(null, null); - if (Context.AutoComplete) - { - Context.MarkComplete(); - } - }).Start(); - return; - } - } + Id = stid, + Method = mth, + AutoComplete = true, + }; + SaveSystem.CurrentSave.PickupPoint = Context.Id; + Context.OnComplete += () => + { + StoryComplete?.Invoke(stid); + SaveSystem.CurrentSave.PickupPoint = null; + }; + mth.Invoke(null, null); + if (Context.AutoComplete) + { + Context.MarkComplete(); } - } + }).Start(); + return; } } - catch (Exception ex) { throw ex; } } + } #if DEBUG throw new ArgumentException("Story ID not found: " + stid + " - Talk to Michael. NOW."); |
