protected override void OnUpdate() { Entities .WithAll <NetworkStreamDisconnected>() .ForEach((Entity entity, ref NetworkIdComponent networkIdComponent, ref CommandTargetComponent commandTargetComponent) => { PostUpdateCommands.DestroyEntity(commandTargetComponent.targetEntity); ServerManager.Instance.OnDisconnected(entity); UnityLogger.Info($"[Server] Client disconnected from server with network id = [{networkIdComponent.Value}]"); }); }
protected override void OnUpdate() { Entities .WithAll <NetworkStreamDisconnected>() .ForEach((Entity entity, ref CommandTargetComponent commandTargetComponent) => { PostUpdateCommands.DestroyEntity(commandTargetComponent.targetEntity); ClientManager.Instance.OnDisconnected(); UnityLogger.Info($"[Client] Disconnected from server"); }); }
protected override void OnUpdate() { var startServer = GetSingleton <StartServer>(); EntityManager.DestroyEntity(GetSingletonEntity <StartServer>()); var network = World.GetExistingSystem <NetworkStreamReceiveSystem>(); NetworkEndPoint ep = NetworkEndPoint.AnyIpv4; ep.Port = startServer.port; network.Listen(ep); UnityLogger.Info($"Server started on {ep.Port} port in {World.Name} world"); }
protected override void OnUpdate() { Entities .WithNone <NetworkStreamInGame>() .ForEach((Entity connectionEntity, ref NetworkIdComponent id) => { UnityLogger.Info($"[Client] Connection to server established with network id = [{id.Value}]"); var commandHandler = EntityManager.CreateEntity(); PostUpdateCommands.AddComponent(commandHandler, new ClientToServerCommandHandler()); ClientManager.Instance.OnConnectionEstablished(connectionEntity, commandHandler, id.Value); PostUpdateCommands.SetComponent(connectionEntity, new CommandTargetComponent { targetEntity = commandHandler }); PostUpdateCommands.AddComponent <NetworkStreamInGame>(connectionEntity); }); }
protected override void OnUpdate() { Entities .WithAll <NetworkIdComponent>() .WithNone <NetworkStreamInGame>() .ForEach((Entity connectionEntity, ref NetworkIdComponent networkIdComponent) => { UnityLogger.Info($"[Server] Client connected with network id = [{networkIdComponent.Value}]"); var playerConnectionCommandHandler = EntityManager.CreateEntity(); PostUpdateCommands.AddComponent <ServerToClientCommandHandler>(playerConnectionCommandHandler); PostUpdateCommands.SetComponent(connectionEntity, new CommandTargetComponent { targetEntity = playerConnectionCommandHandler }); PostUpdateCommands.AddComponent <NetworkStreamInGame>(connectionEntity); ServerManager.Instance.OnConnected(connectionEntity); }); }
private static void WeaveAssemblyCore(string assemblyPath, IEnumerable <string> references) { var logger = new UnityLogger(); var name = Path.GetFileNameWithoutExtension(assemblyPath); try { var timer = new Stopwatch(); timer.Start(); var resolutionResult = WeaverAssemblyResolver.Resolve(assemblyPath, references); if (resolutionResult == null) { return; } using (resolutionResult) { // Unity doesn't add the [TargetFramework] attribute when compiling the assembly. However, it's // using NETStandard2, so we just hardcode this. var weaver = new Weaver(resolutionResult.Module, logger, new FrameworkName(".NETStandard,Version=v2.0")); var results = weaver.Execute(); // Unity creates an entry in the build console for each item, so let's not pollute it. if (results.SkipReason == null) { resolutionResult.SaveModuleUpdates(); logger.Info($"[{name}] Weaving completed in {timer.ElapsedMilliseconds} ms.{Environment.NewLine}{results}"); } } } catch (Exception ex) { logger.Warning($"[{name}] Weaving failed: {ex.StackTrace}"); } }
public void TestLog__Info() { logger.Info("well hi there"); innerLogger.Received().Log(LogType.Log, "well hi there"); }