/* * @throws ConversionException */ public ITES5Type ResolveInferenceTypeByReferenceEdid(ITES5VariableOrProperty variable) { string edid = variable.ReferenceEDID; //WTM: Change: Without this if statement, SEBrithaurRef finds a reference //from qf_se35_01044c44_40_0 to SEBrithaurScript instead of //from qf_se35_01044c44_40_0 to SE35BrithaurScript //So the content of this if statement must be skipped. if (edid != "SEBrithaurRef") { //WTM: Change: I added the "FurnScript" (for qf_housebravil_01085480_10_0 and other house quests) and "QuestScript" (for MQDragonArmorQuestScript) items. List <string> namesToTry = new List <string>() { edid, edid + "QuestScript", edid + "FurnScript", edid + "Script" }; int edidLength = edid.Length; if (edid.Substring(edidLength - 3, 3).Equals("ref", StringComparison.OrdinalIgnoreCase)) { string tryAsRef = edid.Substring(0, edidLength - 3); namesToTry.AddRange(new string[] { tryAsRef, tryAsRef + "Script" }); } namesToTry = namesToTry.Distinct().ToList(); string firstNameMatch = namesToTry.Where(n => this.otherScriptsLower.Contains(n.ToLower())).FirstOrDefault(); if (firstNameMatch != null) { return(TES5TypeFactory.MemberByValue(firstNameMatch)); } } //If it"s not found, we"re forced to scan the ESM to see, how to resolve the ref name to script type return(this.esmAnalyzer.ResolveScriptTypeByItsAttachedName(variable.ReferenceEDID)); }
public TES5ScriptHeader(string scriptName, ITES5Type scriptType, string scriptNamePrefix, bool isHidden = false) { this.OriginalScriptName = scriptName; this.EscapedScriptName = NameTransformer.Limit(scriptName, scriptNamePrefix); this.EDID = scriptName; this.scriptNamePrefix = scriptNamePrefix; this.ScriptType = TES5TypeFactory.MemberByValue(scriptName, scriptType); this.BasicScriptType = scriptType; this.isHidden = isHidden; }
public static TES5ScriptHeader GetFromCacheOrConstructByBasicType(string scriptName, ITES5Type type, string scriptNamePrefix, bool isHidden) { TES5ScriptHeader?header = TryGetScriptHeader(scriptName); if (header != null) { return(header); } TES5BasicType?basicType = type as TES5BasicType; if (basicType != null) { type = TES5TypeFactory.MemberByValue(scriptName, basicType); } header = Construct(scriptName, type, scriptNamePrefix, isHidden); cache.Add(scriptName, header); return(header); }
private static ITES5Type?GetTypeByRecords(IReadOnlyList <TES4Record> tes4Records, string?scriptName) { TES5BasicType?commonBaseType = GetCommonBaseTES5Type(tes4Records); if (commonBaseType == null) { return(null); } ITES5Type tes5Type; if (scriptName != null) { tes5Type = TES5TypeFactory.MemberByValue(scriptName, commonBaseType); } else { tes5Type = commonBaseType; } return(tes5Type); }
/* * @todo REFACTOR, it"s really ugly! * @throws ConversionException */ public ITES5Type ResolveScriptTypeByItsAttachedName(string attachedName) { string attachedNameLower = attachedName.ToLower(); ITES5Type value; if (this.attachedNameCache.TryGetValue(attachedNameLower, out value)) { return(value); } TES4LoadedRecord attachedNameRecord = FindInTES4Collection(attachedName, false); if (attachedNameRecord == null) { throw new ConversionException("Cannot resolve script type by searching its base form edid - no record found, " + attachedName); } TES4RecordType attachedNameRecordType = attachedNameRecord.RecordType; if (attachedNameRecordType == TES4RecordType.REFR || attachedNameRecordType == TES4RecordType.ACRE || attachedNameRecordType == TES4RecordType.ACHR) { //Resolve the reference Nullable <int> baseFormid = attachedNameRecord.GetSubrecordAsFormid("NAME"); attachedNameRecord = esm.FindByFormid(baseFormid.Value); } Nullable <int> scriptFormid = attachedNameRecord.GetSubrecordAsFormid("SCRI"); if (scriptFormid == null) { throw new ConversionException("Cannot resolve script type for " + attachedName + " - Asked base record has no script bound."); } TES4LoadedRecord scriptRecord = esm.FindByFormid(scriptFormid.Value); ITES5Type customType = TES5TypeFactory.MemberByValue(scriptRecord.GetSubrecordTrim("EDID")); this.attachedNameCache.Add(attachedNameLower, customType); return(customType); }
public static ITES5Type Map(TES4RecordType type) { string propertyType; switch (type.Name) { case "AACT": { propertyType = "Action"; break; } case "ACTI": { propertyType = "Activator"; break; } case "ACHR": case "ACRE": case "NPC_": { propertyType = "Actor"; break; } case "AMMO": { propertyType = "Ammo"; break; } case "APPA": { propertyType = "Apparatus"; break; } case "CREA": { propertyType = "Actor"; break; } case "CLMT": { propertyType = "Climate"; break; } case "CLOT": case "ARMO": { propertyType = "Armor"; break; } case "ASTP": { propertyType = "AssociationType"; break; } case "BOOK": { propertyType = "Book"; break; } case "CELL": { propertyType = "Cell"; break; } case "CLAS": { propertyType = "Class"; break; } case "COBJ": { propertyType = "ConstructibleObject"; break; } case "CONT": { propertyType = "Container"; break; } case "DOOR": { propertyType = "Door"; break; } case "EFSH": { propertyType = "EffectShader"; break; } case "ENCH": { propertyType = "Enchantment"; break; } case "ECNZ": { propertyType = "EncounterZone"; break; } case "EXPL": { propertyType = "Explosion"; break; } case "FACT": { propertyType = "Faction"; break; } case "FLOR": { propertyType = "Flora"; break; } case "FLST": { propertyType = "FormList"; break; } case "FURN": { propertyType = "Furniture"; break; } case "GLOB": { propertyType = "GlobalVariable"; break; } case "HAZD": { propertyType = "Hazard"; break; } case "IMAD": { propertyType = "ImageSpaceModifier"; break; } case "IPDS": { propertyType = "ImpactDataSet"; break; } case "INGR": { propertyType = "Ingredient"; break; } case "KEYM": { propertyType = "Key"; break; } case "KYWD": { propertyType = "Keyword"; break; } case "LVLN": { propertyType = "LeveledActor"; break; } case "LVLI": { propertyType = "LeveledItem"; break; } case "LVSP": { propertyType = "LeveledSpell"; break; } case "LIGH": { propertyType = "Light"; break; } case "LCTN": { propertyType = "Location"; break; } case "LCRT": { propertyType = "LocationRefType"; break; } case "MGEF": { propertyType = "MagicEffect"; break; } case "MATH": { propertyType = "Math"; break; } case "MESG": { propertyType = "Message"; break; } case "MISC": { propertyType = "MiscObject"; break; } case "MUSC": { propertyType = "MusicType"; break; } case "REFR": { propertyType = "ObjectReference"; break; } case "OTFT": { propertyType = "Outfit"; break; } case "PACK": { propertyType = "Package"; break; } case "PERK": { propertyType = "Perk"; break; } case "ALCH": { propertyType = "Potion"; break; } case "PROJ": { propertyType = "Projectile"; break; } case "QUST": { propertyType = "Quest"; break; } case "RACE": { propertyType = "Race"; break; } case "SCEN": { propertyType = "Scene"; break; } case "SCRL": { propertyType = "Scroll"; break; } case "SHOU": { propertyType = "Shout"; break; } case "SLGM": { propertyType = "SoulGem"; break; } case "SOUN": { propertyType = "Sound"; break; } case "SNCT": { propertyType = "SoundCategory"; break; } case "SPEL": { propertyType = "Spell"; break; } case "STAT": { propertyType = "Static"; break; } case "TACT": { propertyType = "TalkingActivator"; break; } case "DIAL": { propertyType = "Topic"; break; } case "INFO": { propertyType = "TopicInfo"; break; } case "RFCT": { propertyType = "VisualEffect"; break; } case "VTYP": { propertyType = "VoiceType"; break; } case "WEAP": { propertyType = "Weapon"; break; } case "WTHR": { propertyType = "Weather"; break; } case "WOOP": { propertyType = "WordOfPower"; break; } case "WRLD": { propertyType = "WorldSpace"; break; } default: { throw new ConversionException("Unknown " + type.Name + " formid reference."); } } return(TES5TypeFactory.MemberByValue(propertyType)); }