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); } }
/// <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); }
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); } }
/// <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)); }
private bool IsDialogueFile(WorldFactoryResource fi) { return(fi.Location.EndsWith("dialogue.yaml", StringComparison.CurrentCultureIgnoreCase)); }
private bool IsBehavioursFile(WorldFactoryResource fi) { return(fi.Location.EndsWith("behaviours.yaml", StringComparison.CurrentCultureIgnoreCase)); }