diff options
| author | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
|---|---|---|
| committer | pfg <[email protected]> | 2017-03-07 17:33:44 -0800 |
| commit | b20d77edd1227b2ce53b65b0752972bd65a36e84 (patch) | |
| tree | b15615591e009c9aa472ba5d95374a064c50e8b1 /ShiftOS_TheReturn/Story.cs | |
| parent | 4989356d6797335b44060ae94c9af34404773506 (diff) | |
| parent | 449d43d22c1d12ce6aa0243fbb4ea94481ff8f4c (diff) | |
| download | shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.gz shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.tar.bz2 shiftos_thereturn-b20d77edd1227b2ce53b65b0752972bd65a36e84.zip | |
Merge branch 'master' of https://github.com/shiftos-game/ShiftOS
Diffstat (limited to 'ShiftOS_TheReturn/Story.cs')
| -rw-r--r-- | ShiftOS_TheReturn/Story.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index 9d8078e..ecd04f4 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -37,6 +37,48 @@ namespace ShiftOS.Engine { public class Story { + public static void Start(string stid) + { + foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.EndsWith(".exe") || exec.EndsWith(".dll")) + { + try + { + if (SaveSystem.CurrentSave.StoriesExperienced == null) + SaveSystem.CurrentSave.StoriesExperienced = new List<string>(); + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes()) + { + foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + { + foreach(var attrib in mth.GetCustomAttributes(false)) + { + if(attrib is StoryAttribute) + { + var story = attrib as StoryAttribute; + if(story.StoryID == stid) + { + mth.Invoke(null, null); + SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + return; + } + } + } + } + } + } + catch { } + } + } +#if DEBUG + throw new ArgumentException("Story ID not found: " + stid + " - Talk to Michael. NOW."); +#else + Debug.Print("No such story: " + stid); +#endif + } + + public static void RunFromInternalResource(string resource_id) { var t = typeof(Properties.Resources); @@ -262,4 +304,25 @@ namespace ShiftOS.Engine thread.Start(); } } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class StoryAttribute : Attribute + { + /// <summary> + /// Creates a new instance of the <see cref="StoryAttribute"/> attribute. + /// </summary> + /// <param name="id">The ID of this story plot.</param> + /// <remarks> + /// <para> + /// The <see cref="StoryAttribute"/> is used to turn a static, public method into a story element. Using the specified <paramref name="id"/> argument, the ShiftOS Engine can determine whether this plot has already been experienced, and using the <see cref="Shiftorium"/> classes, the ID is treated as a special Shiftorium upgrade, and you can use the <see cref="RequiresUpgradeAttribute"/> attribute as well as the various other ways of determining whether a Shiftorium upgrade is installed to determine if this plot has been experienced. + /// </para> + /// </remarks> + public StoryAttribute(string id) + { + StoryID = id; + } + + public string StoryID { get; private set; } + + } } |
