FieldInitializer.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Linq;
  3. namespace FF8
  4. {
  5. public static class FieldInitializer
  6. {
  7. /// <summary>
  8. /// Should be called only once
  9. /// </summary>
  10. public static void Init()
  11. {
  12. ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_FIELD);
  13. string[] lists = aw.GetListOfFiles();
  14. string maplist = lists.First(x => x.ToLower().Contains("mapdata.fs"));
  15. maplist = maplist.Substring(0,maplist.Length - 3);
  16. byte[] fs = aw.GetBinaryFile($"{maplist}{Memory.Archives.B_FileArchive}");
  17. byte[] fl = aw.GetBinaryFile($"{maplist}{Memory.Archives.B_FileList}");
  18. byte[] fi = aw.GetBinaryFile($"{maplist}{Memory.Archives.B_FileIndex}");
  19. string map = System.Text.Encoding.UTF8.GetString(fl).TrimEnd();
  20. string[] maplistb = System.Text.Encoding.UTF8.GetString(
  21. aw.FileInTwoArchives(fi, fs, fl, map))
  22. .Replace("\r", "")
  23. .Split('\n');
  24. Memory.FieldHolder.fields = maplistb;
  25. FieldId.FieldId_ = maplistb;
  26. }
  27. public static IServices GetServices()
  28. {
  29. ServiceProvider services = new ServiceProvider();
  30. EventEngine engine = new EventEngine();
  31. services.Register(ServiceId.Interaction, new InteractionService());
  32. services.Register(ServiceId.Field, new FieldService(engine));
  33. services.Register(ServiceId.Global, new GlobalVariableService());
  34. services.Register(ServiceId.Gameplay, new GameplayService());
  35. services.Register(ServiceId.Salary, new SalaryService());
  36. services.Register(ServiceId.Party, new PartyService());
  37. services.Register(ServiceId.Movie, new MovieService());
  38. services.Register(ServiceId.Message, new MessageService());
  39. services.Register(ServiceId.Menu, new MenuService());
  40. services.Register(ServiceId.Music, new MusicService());
  41. services.Register(ServiceId.Sound, new SoundService());
  42. services.Register(ServiceId.Rendering, new RenderingService());
  43. return services;
  44. }
  45. }
  46. }