private static void Init() { ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_FIELD); string[] test = aw.GetListOfFiles(); //TODO fix endless look on FieldID 50. if (Memory.FieldHolder.FieldID >= Memory.FieldHolder.fields.Length || Memory.FieldHolder.FieldID < 0) { return; } var CollectionEntry = test.Where(x => x.ToLower().Contains(Memory.FieldHolder.fields[Memory.FieldHolder.FieldID])); if (!CollectionEntry.Any()) { return; } string fieldArchive = CollectionEntry.First(); int fieldLen = fieldArchive.Length - 3; fieldArchive = fieldArchive.Substring(0, fieldLen); byte[] fs = aw.GetBinaryFile($"{fieldArchive}{Memory.Archive.B_FileArchive}"); byte[] fi = aw.GetBinaryFile($"{fieldArchive}{Memory.Archive.B_FileIndex}"); byte[] fl = aw.GetBinaryFile($"{fieldArchive}{Memory.Archive.B_FileList}"); if (fs == null || fi == null || fl == null) { return; } string[] test_ = aw.GetBinaryFileList(fl); string mim = null; string map = null; try { mim = test_.First(x => x.ToLower().Contains(".mim")); } catch {} try { map = test_.First(x => x.ToLower().Contains(".map")); } catch {} if (mim != null && map != null) { byte[] mimb = aw.FileInTwoArchives(fi, fs, fl, mim); byte[] mapb = aw.FileInTwoArchives(fi, fs, fl, map); ParseBackground(mimb, mapb); } //let's start with scripts byte[] jsm = null; byte[] sy = null; string s_jsm = null; string s_sy = null; try { s_jsm = test_.First(x => x.ToLower().Contains(".jsm")); } catch { } try { s_sy = test_.First(x => x.ToLower().Contains(".sy")); } catch { } if (s_jsm != null && s_sy != null) { jsm = aw.FileInTwoArchives(fi, fs, fl, s_jsm); sy = aw.FileInTwoArchives(fi, fs, fl, s_sy); } else { return; // one or both values are null } List <Jsm.GameObject> jsmObjects = Jsm.File.Read(jsm); if (sy == null) { return; } Sym.GameObjects symObjects = Sym.Reader.FromBytes(sy); services = FieldInitializer.GetServices(); eventEngine = ServiceId.Field[services].Engine; eventEngine.Reset(); for (var objIndex = 0; objIndex < jsmObjects.Count; objIndex++) { Jsm.GameObject obj = jsmObjects[objIndex]; FieldObject fieldObject = new FieldObject(obj.Id, symObjects.GetObjectOrDefault(objIndex).Name); foreach (Jsm.GameScript script in obj.Scripts) { fieldObject.Scripts.Add(script.ScriptId, script.Segment.GetExecuter()); } eventEngine.RegisterObject(fieldObject); } //string mch = test_.Where(x => x.ToLower().Contains(".mch")).First(); //string one = test_.Where(x => x.ToLower().Contains(".one")).First(); //string msd = test_.Where(x => x.ToLower().Contains(".msd")).First(); //string inf = test_.Where(x => x.ToLower().Contains(".inf")).First(); //string id = test_.Where(x => x.ToLower().Contains(".id")).First(); //string ca = test_.Where(x => x.ToLower().Contains(".ca")).First(); //string tdw = test_.Where(x => x.ToLower().Contains(".tdw")).First(); //string msk = test_.Where(x => x.ToLower().Contains(".msk")).First(); //string rat = test_.Where(x => x.ToLower().Contains(".rat")).First(); //string pmd = test_.Where(x => x.ToLower().Contains(".pmd")).First(); //string sfx = test_.Where(x => x.ToLower().Contains(".sfx")).First(); //byte[] mchb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, mch); //Field character models //byte[] oneb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, one); //Field character models container //byte[] msdb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, msd); //dialogs //byte[] infb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, inf); //gateways //byte[] idb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, id); //walkmesh //byte[] cab = ArchiveWorker.FileInTwoArchives(fi, fs, fl, ca); //camera //byte[] tdwb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, tdw); //extra font //byte[] mskb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, msk); //movie cam //byte[] ratb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, rat); //battle on field //byte[] pmdb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, pmd); //particle info //byte[] sfxb = ArchiveWorker.FileInTwoArchives(fi, fs, fl, sfx); //sound effects mod++; return; }
public void SetSymbols(Sym.GameObjects symbols) { _symbols = symbols; }