public ClientGame(ClientGameContext ctx) { Assert.IsNotNull(ctx.World); World = ctx.World; //var networkInterface = new LidgrenClientNetworkInterface(ctx.LagSettings); var networkInterface = new LiteNetClientNetworkInterface(); Client = new CubeClient(ctx.World, networkInterface); Client.networkInterface.ConnectionRequestAccepted += OnConnectionRequestAccepted; Client.networkInterface.Disconnected += OnDisconnected; Client.reactor.AddHandler((byte)MessageId.LoadScene, OnLoadScene); Client.reactor.AddHandler((byte)MessageId.PossessPawn, OnPossessPawn); }
public void StartClient() { if (GameClient != null) { return; } var clientWorldGO = new GameObject("Client World"); var clientWorld = clientWorldGO.AddComponent <World>(); var ctx = new ClientGameContext() { World = clientWorld, LagSettings = LagSettings }; GameClient = CreateClient(ctx); OnClientRunning(); }
protected virtual ClientGame CreateClient(ClientGameContext ctx) { return(new ClientGame(ctx)); }