using Tiger.Communication.Messages.Interfaces; using Tiger.Communication.Messages.Types; using Tiger.Game.Navigator.Nodes; namespace Tiger.Communication.Messages.Outgoing.Navigator; public class NavNodeInfoComposer : IMessageComposer { private readonly bool _nodeMask; private readonly NavigatorNode _node; public NavNodeInfoComposer(bool nodeMask, NavigatorNode node) { _nodeMask = nodeMask; _node = node; } public OutgoingHeaders Header => OutgoingHeaders.NavNodeInfo; public void Compose(ServerMessage message) { message.AppendWire(_nodeMask); message.AppendWire(_node.Id); message.AppendWire((int)_node.Type); message.AppendString(_node.Name); message.AppendWire(0); message.AppendWire(0); message.AppendWire(_node.Parent?.Id ?? 0); if (_node.Type == NavigatorNodeType.Private) { try { var rooms = _node.Rooms.OrderByDescending(r => r.UsersIn).Take(30).ToList(); message.AppendWire(rooms.Count); foreach (var room in rooms) { room.ParseNode(message); } } catch (Exception ex) { Console.WriteLine(ex); } } foreach (var child in _node.Children.Where(nn => nn.Visible)) { message.AppendWire(child.Id); message.AppendWire((int)child.Type); message.AppendString(child.Name); message.AppendWire(0); // TODO: percent filled (changes bar color) message.AppendWire(0); message.AppendWire(_node.Id); } } }