Ejemplo n.º 1
0
        void IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
        {
            if (eventArgs.Target == null)
            {
                return;
            }

            CloseAllSurgeryUIs();
            OptionsCache.Clear();
            PerformerCache = null;
            BodyCache      = null;

            if (eventArgs.Target.TryGetComponent(out IBody? body))
            {
                SendBodyPartListToUser(eventArgs, body);
            }
            else if (eventArgs.Target.TryGetComponent <IBodyPart>(out var part))
            {
                DebugTools.AssertNotNull(part);

                if (!part.TryAddMechanism(this))
                {
                    eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("You can't fit it in!"));
                }
            }
        }
        async Task <bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
        {
            if (eventArgs.Target == null)
            {
                return(false);
            }

            CloseAllSurgeryUIs();
            OptionsCache.Clear();
            PerformerCache = null;
            BodyCache      = null;

            if (_entities.TryGetComponent(eventArgs.Target.Value, out SharedBodyComponent? body))
            {
                SendBodyPartListToUser(eventArgs, body);
            }
            else if (_entities.TryGetComponent <SharedBodyPartComponent?>(eventArgs.Target.Value, out var part))
            {
                DebugTools.AssertNotNull(part);

                if (!part.TryAddMechanism(this))
                {
                    eventArgs.Target.Value.PopupMessage(eventArgs.User, Loc.GetString("mechanism-component-cannot-fit-message"));
                }
            }

            return(true);
        }