private bool HandleThrowItem(ICommonSession?session, EntityCoordinates coords, EntityUid uid)
        {
            if (session is not IPlayerSession playerSession)
            {
                return(false);
            }

            if (playerSession.AttachedEntity is not {
                Valid : true
            } player ||
                !Exists(player) ||
                player.IsInContainer() ||
                !TryComp(player, out SharedHandsComponent? hands) ||
                hands.ActiveHandEntity is not EntityUid throwEnt ||
                !_actionBlockerSystem.CanThrow(player))
            {
                return(false);
            }

            if (EntityManager.TryGetComponent(throwEnt, out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually)
            {
                var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent <TransformComponent>(player).Coordinates, stack);

                if (splitStack is not {
                    Valid : true
                })
Exemple #2
0
        /// <summary>
        /// Activates the Throw behavior of an object
        /// Verifies that the user is capable of doing the throw interaction first
        /// </summary>
        public bool TryThrowInteraction(IEntity user, IEntity item)
        {
            if (user == null || item == null || !_actionBlockerSystem.CanThrow(user))
            {
                return(false);
            }

            ThrownInteraction(user, item);
            return(true);
        }