public FormattedMessage GetExamineText(EntityUid entity, EntityUid?examiner)
        {
            var message = new FormattedMessage();

            if (examiner == null)
            {
                return(message);
            }

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription))
            {
                message.AddText(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            // Raise the event and let things that subscribe to it change the message...
            var isInDetailsRange = IsInDetailsRange(examiner.Value, entity);
            var examinedEvent    = new ExaminedEvent(message, entity, examiner.Value, isInDetailsRange, doNewline);

            RaiseLocalEvent(entity, examinedEvent, true);

            message.Pop();

            return(message);
        }
예제 #2
0
        public FormattedMessage GetExamineText(EntityUid entity, EntityUid?examiner)
        {
            var message = new FormattedMessage();

            if (examiner == null)
            {
                return(message);
            }

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription))
            {
                message.AddText(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            // Raise the event and let things that subscribe to it change the message...
            var isInDetailsRange = IsInDetailsRange(examiner.Value, entity);
            var examinedEvent    = new ExaminedEvent(message, entity, examiner.Value, isInDetailsRange, doNewline);

            RaiseLocalEvent(entity, examinedEvent);

            //Add component statuses from components that report one
            foreach (var examineComponent in EntityManager.GetComponents <IExamine>(entity))
            {
                var subMessage = new FormattedMessage();
                examineComponent.Examine(subMessage, isInDetailsRange);
                if (subMessage.Tags.Count == 0)
                {
                    continue;
                }

                if (doNewline)
                {
                    message.AddText("\n");
                }

                message.AddMessage(subMessage);
                doNewline = true;
            }

            message.Pop();

            return(message);
        }