/// <summary> /// Called when a player comes into range of this crafter. /// </summary> private void OnPlayerEnter(BasePlayer player) { if (CraftingTasks.Count > 0) { SendCraftingList(player); } PlayerEnter?.Invoke(this, player); }
protected override void ServerOnPlayerEnter(int clientId) { var clientInfo = ClientInfo(clientId); if (Config["SvSilentSpectatorMode"] && Players[clientId].Team == Team.Spectators) { clientInfo.Silent = true; } for (var i = 0; i < Players.Length; i++) { if (i == clientId || Players[i] == null || !Server.ClientInGame(i) && !Players[i].IsDummy) { continue; } if (Server.ClientInGame(i)) { Server.SendPackMsg(clientInfo, MsgFlags.Vital | MsgFlags.NoRecord, i); } Server.SendPackMsg(ClientInfo(i), MsgFlags.Vital | MsgFlags.NoRecord, clientId); } clientInfo.Local = true; Server.SendPackMsg(clientInfo, MsgFlags.Vital | MsgFlags.NoRecord, clientId); if (false) // TODO DEMO { var msg = new GameMsg_DeClientEnter() { Name = clientInfo.Name, Team = clientInfo.Team, ClientId = clientId }; Server.SendPackMsg(msg, MsgFlags.NoSend, -1); } PlayerEnter?.Invoke(Players[clientId]); }
protected override void NetMsgEnterGame(Chunk packet, UnPacker unPacker, int clientId) { if (!packet.Flags.HasFlag(SendFlags.Vital)) { return; } if (Clients[clientId].State != ServerClientState.Ready) { return; } if (!GameContext.IsClientReady(clientId)) { return; } Console.Print(OutputLevel.Standard, "server", $"player has entered the game. ClientId={clientId} addr={NetworkServer.ClientEndPoint(clientId)}"); Clients[clientId].State = ServerClientState.InGame; SendServerInfo(clientId); PlayerEnter?.Invoke(clientId); }