public static void InvokePlayerLeave(ReferenceHub hub, string userId, GameObject obj) { OnPlayerLeave onPlayerLeave = PlayerLeaveEvent; if (onPlayerLeave == null) { return; } PlayerLeaveEvent ev = new PlayerLeaveEvent() { Player = hub }; onPlayerLeave?.Invoke(ev); }
public void Start() { if (Active) { return; } Active = true; _listener = new TcpListener(IPAddress.Any, Port); _listener.Start(); Logger.Info("Started Coordinator Server"); _listenThread = new Thread(async() => { while (Active) { var client = await _listener.AcceptTcpClientAsync(); var c = new CoordinatorClient(client, _cancel.Token); Logger.Info($"CoordinationClient: {c.Descriptor.Address}"); c.OnRegistered += (descriptor) => { Logger.Info($"Client [{descriptor.Address}] registered {descriptor.Name}"); OnPlayerJoin?.Invoke(c, descriptor); }; c.OnDisconnected += (descriptor) => { Logger.Info($"Client [{descriptor.Address} disconnected"); OnPlayerLeave?.Invoke(c, descriptor); }; lock (_clients) { _clients.Add(c); } } }); _listenThread.Start(); }
private void Leave(PlayerInput playerInput, int index) { _playersByPadIndex.Remove(playerInput.Name); if (playerInput.PadUsedType != PadUsedType.SINGLE) { var otherName = PlayerInputUtils.NameByIndexAndPadUsedType(index, PadUsedTypeUtils.GetOtherSide(playerInput.PadUsedType)); var other = _playersByPadIndex[otherName]; ChangePadUsedTypeForPlayerInput(other, PadUsedType.SINGLE); } else { _activeIndex.Remove(index); } _padIndexInProcedure.Remove(index); if (_notification.ContainsKey(index)) { Destroy(_notification[index]); _notification.Remove(index); } if (_mainPlayerInput == playerInput) { if (_activeIndex.Count > 0) { _mainPlayerInput = _playersByPadIndex.Values.First(); } else { _mainPlayerInput = null; } } OnPlayerLeave?.Invoke(playerInput); }
public static void NetworkInit() { if (NetworkManager.field_Internal_Static_NetworkManager_0 == null) { return; } var field0 = NetworkManager.field_Internal_Static_NetworkManager_0.field_Internal_VRCEventDelegate_1_Player_0; var field1 = NetworkManager.field_Internal_Static_NetworkManager_0.field_Internal_VRCEventDelegate_1_Player_1; field0.field_Private_HashSet_1_UnityAction_1_T_0.Add(new Action <Player>((player) => OnPlayerJoin?.Invoke(player))); field1.field_Private_HashSet_1_UnityAction_1_T_0.Add(new Action <Player>((player) => OnPlayerLeave?.Invoke(player))); }
public void Parse(UpdatePacket packet) { Entity self = packet.NewObjs.FirstOrDefault(x => x.Status.Data.FirstOrDefault(z => z.Id == StatsType.AccountId && z.StringValue == Client.State.ACCID) != null); // The first new object whos data has a Status whos id is AccountId and equals the accound id of the client that's not null; if (self != null) { HitTheGround(self); if (Client.State["NextSpawn"] != null) { self.Status.Position = Client.State["NextSpawn"] as Location; Client.State["NextSpawn"] = null; } } foreach (Entity entity in packet.NewObjs) { if (entity.IsPlayer()) { Player freshy = new Player(entity); Players.Add(freshy); if (!AllRenderedPlayers.Select(x => x.Entity.Status.Data.GetHashCode()).Contains(freshy.Entity.Status.Data.GetHashCode())) { AllRenderedPlayers.Add(freshy); } OnPlayerJoin?.Invoke(freshy); } else if (entity.IsBag()) { Bags.Add(entity); OnBagSpawn?.Invoke(entity); } else if (entity.IsPortal()) { } else if (entity.IsEnemy()) { } } foreach (int objectId in packet.Drops.ToList()) { Entity entity = Client.GetEntity(objectId); OnEntityLeave?.Invoke(entity); if (entity.IsPlayer()) { //Player player = entity.GetPlayer(); Player player = Client.Self().Players.First(x => x.Entity.Status.ObjectId == entity.Status.ObjectId); // Don't know if ic an just do entity == entity too l8z two test if (!cPlayers.SelectMany(x => x.Players).Contains(player)) { AllRenderedPlayers.Remove(player); } Players.Remove(player); OnPlayerLeave?.Invoke(player); } else if (entity.IsBag()) { Bags.Remove(entity); OnBagDespawn?.Invoke(entity); } else if (entity.IsPortal()) { } else if (entity.IsEnemy()) { } } }