Ejemplo n.º 1
0
        private void HandleChatMsg(MsgChat msg)
        {
            Logger.Debug($"Got it! {msg.Text}");
            var channel  = msg.Channel;
            var text     = msg.Text;
            var index    = msg.SessionId;
            var entityId = msg.EntityId;

            switch (channel)
            {
            case ChatChannel.Local:
            case ChatChannel.Server:
            case ChatChannel.OOC:
            case ChatChannel.Radio:
            {
                string name;
                if (index.HasValue && _players.SessionsDict.TryGetValue(index.Value, out var session))
                {
                    name = session.Name;
                }
                else if (entityId.HasValue)
                {
                    var ent = _entityManager.GetEntity(entityId.Value);
                    name = ent.Name ?? ent.ToString();
                }
                else
                {
                    name = "<TERU-SAMA>";
                }

                text = $"[{channel}] {name}: {text}";
                break;
            }
            }

            AddLine(text, channel, GetChannelColor(channel));

            if (entityId.HasValue && _entityManager.TryGetEntity(entityId.Value, out var a))
            {
                a.SendMessage(null, new SaidSomethingMsg(channel, text));
            }
        }