Example #1
0
 protected virtual IEnumerable <T> GetBlueprints <T>(WorldFactoryResource fi) where T : HasStatsBlueprint
 {
     try
     {
         return(Compiler.Instance.Deserializer.Deserialize <List <T> >(fi.Content));
     }
     catch (Exception e)
     {
         throw new Exception($"Error loading {typeof(T).Name} in file {fi.Location}", e);
     }
 }
Example #2
0
        /// <summary>
        /// Returns whether the given resource is declared with a hierarchy that exists below
        /// a given <see cref="IFaction"/> therefore the resource should be considered part of that
        /// faction.
        /// </summary>
        /// <param name="resource"></param>
        /// <returns></returns>
        protected virtual IFaction GetImplicitFactionFor(WorldFactoryResource resource)
        {
            var factionDir = _factionDirs.Keys.FirstOrDefault(k =>
                                                              k.SharesPath(resource));

            if (factionDir != null)
            {
                return(_factionDirs[factionDir]);
            }

            return(null);
        }
Example #3
0
        protected virtual IEnumerable <DialogueNode> GetDialogue(WorldFactoryResource fi)
        {
            try
            {
                var factory = new DialogueNodeFactory();

                var blueprints = Compiler.Instance.Deserializer.Deserialize <DialogueNodeBlueprint[]>(fi.Content);

                return(blueprints.Select(b => factory.Create(b)));
            }
            catch (Exception e)
            {
                throw new ArgumentException($"Error in dialogue yaml:{ e.Message } in file '{fi.Location}'", e);
            }
        }
Example #4
0
 /// <summary>
 /// Return true if this and the <paramref name="other"/> share the same directory
 /// or if <paramref name="other"/> is in a sub directory beneath this
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual bool SharesPath(WorldFactoryResource other)
 {
     return(other.GetPath().StartsWith(GetPath(), StringComparison.CurrentCultureIgnoreCase));
 }
Example #5
0
 private bool IsDialogueFile(WorldFactoryResource fi)
 {
     return(fi.Location.EndsWith("dialogue.yaml", StringComparison.CurrentCultureIgnoreCase));
 }
Example #6
0
 private bool IsBehavioursFile(WorldFactoryResource fi)
 {
     return(fi.Location.EndsWith("behaviours.yaml", StringComparison.CurrentCultureIgnoreCase));
 }