示例#1
0
        private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
        {
            if (!component.Opened || !args.IsInDetailsRange)
            {
                return;
            }

            var color      = IsEmpty(uid, component) ? "gray" : "yellow";
            var openedText =
                Loc.GetString(IsEmpty(uid, component) ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened");

            args.Message.AddMarkup($"\n{Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))}");
            if (!IsEmpty(uid, component))
            {
                if (TryComp <ExaminableSolutionComponent>(component.Owner, out var comp))
                {
                    //provide exact measurement for beakers
                    args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", _solutionContainerSystem.DrainAvailable(uid)))}");
                }
                else
                {
                    //general approximation
                    string remainingString;
                    switch ((int)_solutionContainerSystem.PercentFull(uid))
                    {
                    case int perc when perc == 100:
                        remainingString = "drink-component-on-examine-is-full";
                        break;

                    case int perc when perc > 66:
                        remainingString = "drink-component-on-examine-is-mostly-full";
                        break;

                    case int perc when perc > 33:
                        remainingString = HalfEmptyOrHalfFull(args);
                        break;

                    default:
                        remainingString = "drink-component-on-examine-is-mostly-empty";
                        break;
                    }
                    args.Message.AddMarkup($" - {Loc.GetString(remainingString)}");
                }
            }
        }