public NIFReference(DB db, long key) { CObject nifObj = db.toObj(7305, key); baseName = nifObj.getMember(2).convert().ToString(); if (nifObj.hasMember(5)) { Dictionary <int, CObject> dict = nifObj.getMember(5).asDict(); foreach (int race in dict.Keys) { CObject nifRaceObj = dict[race]; nifs[race] = new Dictionary <int, string>(); string malenif = nifRaceObj.getMember(0).convert().ToString(); if (nifRaceObj.hasMember(2)) { string femalenif = nifRaceObj.getMember(2).convert().ToString(); nifs[race][2] = femalenif; } nifs[race][0] = malenif; } } }
// Update is called once per frame void Update() { if (filterToSet != null && DateTime.Now > filterSetTime) { filter = filterToSet; filterToSet = null; changeSlot(); } NIFTexturePool.inst.process(); if (text != null) { text.text = progress; } if (db != null && !first) { first = true; // finally everything is loaded and ready so lets load an appearence set try { // fill animations updateAnimDropbox(); // fill the "appearence" sets List <DOption> options = new List <DOption>(); options.Add(new DOption("", null)); foreach (entry e in db.getEntriesForID(7638)) { CObject _7637 = db.toObj(e.id, e.key); int textKey = _7637.getMember(1).getIntMember(0); string str = DBInst.lang_inst.getOrDefault(textKey, _7637.getMember(0).convert().ToString()); DOption option = new DOption(str, e); options.Add(option); } options.Sort((a, b) => string.Compare(a.text, b.text)); appearanceDropdown.AddOptions(options.Cast <Dropdown.OptionData>().ToList()); appearanceDropdown.GetComponent <FavDropDown>().doOptions(); changeSlot(); updatePreviews(); } catch (Exception ex) { Debug.LogException(ex, this.gameObject); } } if (db != null && lastVisible != this.panelUpdater.getVisiblePanels() || this.panelUpdater.changed) { updatePreviews(); lastVisible = panelUpdater.getVisiblePanels(); } }
public void setAppearenceSet(long setKey) { Debug.Log("set appearence set to key:" + setKey, this.gameObject); // clear all the previous "clothing" clearGearSlot(GearSlot.CAPE); clearGearSlot(GearSlot.LEGS); clearGearSlot(GearSlot.SHOULDER); clearGearSlot(GearSlot.HEAD); clearGearSlot(GearSlot.HANDS); clearGearSlot(GearSlot.FEET); clearGearSlot(GearSlot.TORSO); CObject obj = DBInst.inst.toObj(7638, setKey); CObject setParts = obj.getMember(2); foreach (CObject part in setParts.members) { ClothingItem item = new ClothingItem(DBInst.inst, int.Parse(part.convert().ToString())); setGearSlotKey(item.allowedSlots.First(), item.key); } if (state == ClassState.IDLE) { state = ClassState.UPDATE; } }
private static string getSceneName(long key) { try { CObject entry = DBInst.inst.getObject(114, key); return(getLocalized(entry.getMember(0), "")); } catch (Exception ex) { Debug.LogError(ex); return(""); } }
private static List <string> getSky(long key) { List <string> ilist = new List <string>(); CObject entry = DBInst.inst.getObject(114, key); CObject skyInfo = DBInst.inst.getObject(111, entry.getIntMember(31)); CObject list = skyInfo.getMember(20); for (int i = 0; i < list.members.Count; i++) { int _7305 = list.getIntMember(i); ilist.Add(DBInst.inst.getObject(7305, _7305).getStringMember(2)); } return(ilist); }
public static List <WorldSpawn> getSpawns(AssetDatabase adb, DB db, string world) { List <WorldSpawn> worlds = new List <WorldSpawn>(); IEnumerable <entry> keys = db.getEntriesForID(4479); foreach (entry e in keys) { byte[] data = e.decompressedData; using (MemoryStream ms = new MemoryStream(data)) { CObject obj = Parser.processStreamObject(ms); string worldName = obj.getStringMember(0); string imagePath = obj.getStringMember(5); string internalSpawnName = obj.getStringMember(1); string spawnName = getLocalized(obj.getMember(10), internalSpawnName); if (world != null) { if (!worldName.Equals(world)) { continue; } } try { Vector3 pos = obj.getVector3Member(2); float angle = angle = obj.getFloatMember(3, 0); pos.y += 2; if (adb.filenameExists(worldName + "_map.cdr")) { WorldSpawn ws = new WorldSpawn(worldName, spawnName, pos, angle); ws.imagePath = imagePath; worlds.Add(ws); } } catch (Exception ex) { Debug.Log("Unable to get position for spawn [" + e.id + "][" + e.key + "]" + ex); } } } return(worlds); }
private static List <Zone> getZones(string worldNameNoCDR) { List <Zone> zones = new List <Zone>(); try { string worldName = worldNameNoCDR + "_map.cdr"; AssetDatabase adb = AssetDatabaseInst.DB; if (!adb.getManifest().containsHash(Util.hashFileName(worldName))) { throw new Exception("Unable to find world name:" + worldName); } Debug.Log("loading world zones:" + worldName); byte[] data = adb.extractUsingFilename(worldName); CObject obj = Parser.processStreamObject(data); CObject zonesObj = obj.getMember(8); Debug.Log("found zones object with " + zonesObj.members.Count + " members"); for (int i = 0; i < zonesObj.members.Count; i++) { CObject zoneObj = zonesObj.get(i); long key = zoneObj.getIntMember(0); //Debug.Log("found zone with key:" + key); List <Vector3> points = getPoints(zoneObj.getMember(3)); Zone zone = new WorldStuff.Zone(); zone._113Key = key; zone.name = getZoneName(key); zone.points = points; //zone.sky = getSky(key); zones.Add(zone); } }catch (Exception ex) { Debug.LogWarning(ex); } return(zones); }
public ClothingItem(DB db, long id, long key) { this.key = key; this.id = id; try { CObject gearDef = db.toObj(id, key); if (id == 7629) { this.name = gearDef.getMember(0).convert() + ""; if (gearDef.hasMember(1)) { this.langKey = gearDef.getMember(1).getIntMember(0); } if (gearDef.hasMember(4)) { icon = db.toObj(6009, gearDef.getIntMember(4)).getStringMember(1); } if (gearDef.hasMember(5)) { CObject allowedSlotsArray = gearDef.getMember(5); foreach (CObject o in allowedSlotsArray.members) { int slot = int.Parse(o.convert() + ""); allowedSlots.Add(WardrobeStuff.getSlot(slot)); } } if (gearDef.hasMember(6)) { type = WardrobeStuff.getGearType(gearDef.getIntMember(6)); } if (gearDef.hasMember(7)) { hidden = gearDef.getBoolMember(7, false); } nifKey = gearDef.getIntMember(2); nifRef = new NIFReference(db, nifKey); } else if (id == 7305) { nifRef = new NIFReference(db, key); nifKey = key; if (gearDef.hasMember(2)) { string nifPath = gearDef.getMember(2).convert() + ""; this.name = System.IO.Path.GetFileName(nifPath); if (nifPath.Contains(@"\player\") && nifPath.Contains(@"\wings\")) { allowedSlots.Add(GearSlot.CAPE); } } if (gearDef.hasMember(15)) { CObject allowedSlotsArray = gearDef.getMember(15); foreach (CObject o in allowedSlotsArray.members) { int slot = int.Parse(o.convert() + ""); allowedSlots.Add(WardrobeStuff.getSlot(slot)); } } else { } } else { throw new Exception("Bad id:" + id); } } catch (Exception ex) { Debug.Log("Unable to process [" + this + "] nif reference:" + ex); } }
static void processCDR(Stream ms, string cdrName, Action <ObjectPosition> addFunc, DB db) { try { CObject obj = Parser.processStreamObject(ms); if (obj.type != 107) { throw new Exception("CDR file was not class 107"); } List <CObject> members = obj.members; if (members.Count > 0) { CObject first = members[0]; if (first.type == 11) { foreach (CObject child in first.members) { if (child.type == 600) { if (child.members.Count > 1) { string oname = child.getStringMember(1); CObject ary = child.getMember(4); // child members in ary 602 and 603 contain references into the database under id 623 // they point to object 628 which contains references to the actual NIF/HKX files long nif_hkx_ref = long.MaxValue; CObject _602 = findFirstType(ary, 602); if (_602 == null) { UnityEngine.Debug.Log("no nif ref found for :" + oname); } else { bool visible = true; // this is not a visibility property? _602.getBoolMember(2, true); try { nif_hkx_ref = Convert.ToInt64(_602.get(0).convert()); CObject _603 = findFirstType(ary, 603); Quaternion qut = _603.getMember(4).readQuat(); float scale = _603.getFloatMember(5, 1.0f); Vector3 translation = _603.getVector3Member(3); Vector3 centroid = translation; if (_603.hasMember(9)) { centroid = _603.getVector3Member(9); } Vector3 min = translation; Vector3 max = centroid; if (nif_hkx_ref != long.MaxValue) { CObject dbObj = getDBObj(db, 623, nif_hkx_ref); if (dbObj != null) { CObject dbAry = dbObj.getMember(4); CObject _7319 = findFirstType(dbAry, 7319); //CObject _7318 = findFirstType(dbAry, 7318); if (_7319 != null) { if (_7319.members.Count == 0) { // Collision only NIF, ignore it // Debug.Log("empty 7319 for nif ref 623:" + nif_hkx_ref); } else { long nifKey = Convert.ToInt64(_7319.get(0).convert()); CObject _7305Obj = getDBObj(db, 7305, nifKey); String nif = "" + _7305Obj.members[0].convert(); string nifFile = Path.GetFileName(nif); Assets.ObjectPosition op = new Assets.ObjectPosition(nifFile, min, qut, max, scale); op.index = child.index; op.cdrfile = cdrName; op.visible = visible; op.entityname = oname; addFunc.Invoke(op); } } } } // does it have a light source? if (_602.hasMember(3)) { Vector3 color = _602.getVector3Member(3); float r = color.x; float g = color.y; float b = color.z; float range = _602.getFloatMember(4, 2.0f); Assets.LightPosition lp = new Assets.LightPosition(range, r, g, b, min, qut, max, scale); lp.visible = visible; lp.index = child.index; lp.cdrfile = cdrName; lp.entityname = oname; addFunc.Invoke(lp); } } catch (Exception ex) { Debug.Log(ex); } } } } } } } } catch (Exception ex) { Debug.Log("exception trying to process CDR:" + cdrName); Debug.Log(ex); } finally { //Debug.Log("process cdr[" + cdrName + "]: done in " + watch.ElapsedMilliseconds + " ms"); } return; }