public void HandleCraftRequest(NetIncomingMessage msg) { //We don't like messages from nobody if (_playerManager.GetSessionByConnection(msg.SenderConnection).attachedEntity == null) { return; } int compo1Uid = msg.ReadInt32(); int compo2Uid = msg.ReadInt32(); Entity compo1Ent = _serverMain.EntityManager.GetEntity(compo1Uid); Entity compo2Ent = _serverMain.EntityManager.GetEntity(compo2Uid); foreach (CraftingTicket ticket in craftingTickets) { if (ticket.sourceConnection == msg.SenderConnection && ticket.sourceEntity == _playerManager.GetSessionByConnection(msg.SenderConnection).attachedEntity) { sendAlreadyCrafting(msg.SenderConnection); return; } } if (compo1Ent == null || compo2Ent == null) { return; } if (isValidRecipe(compo1Ent.Template.Name, compo2Ent.Template.Name)) { if (hasFreeInventorySlots(_playerManager.GetSessionByConnection(msg.SenderConnection).attachedEntity)) { BeginCrafting(compo1Ent, compo2Ent, _playerManager.GetSessionByConnection(msg.SenderConnection).attachedEntity, msg.SenderConnection); } else { sendInventoryFull(msg.SenderConnection); } } else { NetOutgoingMessage failCraftMsg = IoCManager.Resolve <ISS13NetServer>().CreateMessage(); failCraftMsg.Write((byte)NetMessage.PlayerUiMessage); failCraftMsg.Write((byte)UiManagerMessage.ComponentMessage); failCraftMsg.Write((byte)GuiComponentType.ComboGui); failCraftMsg.Write((byte)ComboGuiMessage.CraftNoRecipe); _netServer.SendMessage(failCraftMsg, msg.SenderConnection, NetDeliveryMethod.ReliableUnordered); } }
public void SendMessage(NetOutgoingMessage message, NetConnection recipient, NetDeliveryMethod method = NetDeliveryMethod.ReliableOrdered) { m_netServer.SendMessage(message, recipient, method); }