private void HandleBuildAction(string selectedObject) { Info = $"Please select where you want to build {selectedObject}"; var buildable = ResourceMasterList.GetDefault(selectedObject).GetTag("buildable"); if (buildable.GetTag("resources") != null) { var resources = buildable.GetTag("resources"); foreach (var r in resources.SubTags) { Info += r.ToString() + '\n'; } } CurrentMenuContext = new Dictionary <char, string>(); State = 1; StoredValue = selectedObject; SetPointAction = FinishBuildAction; }
private static Entity BuildFromJSON(IDictionary <string, object> json) { Entity e; var Attributes = (IDictionary <string, object>)json["attributes"]; Logger.Log($"Found base Object in file with subobjects of {string.Join(",", json.Keys)}"); Logger.Log("Found Attributes in file: " + string.Join(", ", Attributes.Keys)); switch (Attributes.TryGetValue("class", out var output) ? output : "") { case "entity": Logger.Log("Found class to be Entity"); e = new Entity(); break; case "actor": Logger.Log("Found class to be Actor"); e = new Actor(); break; default: Logger.Log("Could not find class definition in attributes, using entity as default"); e = new Entity(); break; } if (json.TryGetValue("inheritance", out var inheritanceOut)) { Logger.Log(inheritanceOut.GetType().ToString()); var InheritanceArray = (List <object>)inheritanceOut; Logger.Log($"Entering inheritance with {InheritanceArray.Count} elements"); foreach (var o in InheritanceArray) { var s = (string)o; var defaultE = ResourceMasterList.GetDefault(s); if (defaultE == null) { return(new Entity { Name = "Inheritance Missing" }); } e.Inherit(defaultE); } } if (Attributes["name"] != null) { e.Name = (string)Attributes["name"]; } if (Attributes["ascii"] != null) { e.Ascii = ((string)Attributes["Ascii"])[0]; } if (Attributes["display"] != null) { e.Display = (string)Attributes["display"]; } Enum.TryParse((string)Attributes["backgroundcolor"], true, out ConsoleColor c); e.BackgroundColor = c; Enum.TryParse((string)Attributes["foregroundcolor"], true, out c); e.ForegroundColor = c; // Set up all tags, regardless of their use in fields foreach (var o in json) { Logger.Log($"Trying ParseTag on tag {o.Key}"); e.AddTag(ParseTag(o)); } Logger.Log(e.ToString()); return(e); }