public void LoadRegionAttributeModTest() { Manager.UpdateMainThreadReference(); Debug.Log("loading region attribute mod file..."); Adjective.ResetAdjectives(); RegionAttribute.ResetAttributes(); RegionAttribute.LoadRegionAttributesFile(Path.Combine("Mods", "Base", "RegionAttributes", "region_attributes.json")); foreach (RegionAttribute regionAttribute in RegionAttribute.Attributes.Values) { Debug.Log("generated region attribute: " + regionAttribute.Name); } }
private static RegionAttribute CreateRegionAttribute(LoadedRegionAttribute attr) { if (string.IsNullOrEmpty(attr.id)) { throw new ArgumentException("region attribute id can't be null or empty"); } if (string.IsNullOrEmpty(attr.name)) { throw new ArgumentException("region attribute name can't be null or empty"); } if (attr.variants == null) { throw new ArgumentException("region attribute's variants can't be null"); } if (attr.phraseAssociations == null) { throw new ArgumentException("region phrase attribute's association strings can't be null"); } Adjective[] adjectives = null; string[] variants = null; if (attr.adjectives != null) { adjectives = new Adjective[attr.adjectives.Length]; for (int i = 0; i < attr.adjectives.Length; i++) { string adj = attr.adjectives[i].Trim(); adjectives[i] = Adjective.TryGetAdjectiveOrAdd(adj); } } variants = attr.variants; for (int i = 0; i < variants.Length; i++) { variants[i] = variants[i].Trim(); } RegionAttribute regionAttribute = new RegionAttribute(attr.id, attr.name, adjectives, variants, attr.regionConstraints, attr.phraseAssociations, attr.secondary); return(regionAttribute); }
private static void AddAttribute(Dictionary <string, RegionAttribute> attributes, RegionAttribute attribute) { if (attributes.ContainsKey(attribute.Id)) { attributes[attribute.Id] = attribute; } else { attributes.Add(attribute.Id, attribute); } }