Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.6KB

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Reflection;
  6. using CLre_server.API.Engines;
  7. using Game.DataLoader;
  8. using GameServer;
  9. using HarmonyLib;
  10. using Svelto.Context;
  11. using Svelto.DataStructures;
  12. using Svelto.ECS;
  13. using User.Server;
  14. namespace CLre_server.API.MainServer
  15. {
  16. class ServerReadyEngine : ServerEnginePostBuild, IWaitForFrameworkInitialization, IWaitForFrameworkDestruction
  17. {
  18. internal static event EventHandler<StartedEventArgs> serverEngineReady;
  19. internal static event EventHandler<StartedEventArgs> serverFrameworkReady;
  20. internal static event EventHandler<StopEventArgs> serverFrameworkDestroyed;
  21. public override void Ready()
  22. {
  23. GameServerSettings gss = Server.Instance.GameServerSettings;
  24. if (serverEngineReady != null) serverEngineReady(this, new StartedEventArgs
  25. {
  26. photonVersion = PhotonNetwork.gameVersion,
  27. photonRegion = PhotonNetwork.CloudRegion,
  28. gameGuid = gss == null ? "" : gss.GetGameGuid(),
  29. worldName = gss == null ? "" : gss.GetWorldName(),
  30. });
  31. }
  32. public void OnFrameworkInitialized()
  33. {
  34. GameServerSettings gss = Server.Instance.GameServerSettings;
  35. if (serverFrameworkReady != null) serverFrameworkReady(this, new StartedEventArgs
  36. {
  37. photonVersion = PhotonNetwork.gameVersion,
  38. photonRegion = PhotonNetwork.CloudRegion,
  39. gameGuid = gss == null ? "" : gss.GetGameGuid(),
  40. worldName = gss == null ? "" : gss.GetWorldName(),
  41. });
  42. }
  43. public void OnFrameworkDestroyed()
  44. {
  45. if (serverFrameworkDestroyed != null) serverFrameworkDestroyed(this, new StopEventArgs{});
  46. }
  47. }
  48. class ServerDatabaseQueryEngine : ServerEnginePostBuild
  49. {
  50. public override void Ready()
  51. {
  52. }
  53. public AccountIdServerNode[] GetConnectedAccounts()
  54. {
  55. FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
  56. ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
  57. ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
  58. entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
  59. List<AccountIdServerNode> list = new List<AccountIdServerNode>();
  60. foreach (var a in accounts)
  61. {
  62. list.Add(a);
  63. }
  64. return list.ToArray();
  65. }
  66. }
  67. }