Exemplo n.º 1
0
        /// <summary>
        /// Updates the ammo count or destroys the ammo after launching the projectile.
        /// </summary>
        /// <param name="ammo">The equipped missile ammo object</param>
        public void UpdateAmmoAfterLaunch(WorldObject ammo)
        {
            ammo.StackSize--;

            if (ammo.StackSize == 0)
            {
                TryDequipObjectWithBroadcasting(ammo.Guid, out _, out _);

                ammo.Destroy();
            }
            else
            {
                EnqueueBroadcast(new GameMessagePickupEvent(ammo), new GameMessageSetStackSize(ammo));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the ammo count or destroys the ammo after launching the projectile.
        /// </summary>
        /// <param name="ammo">The equipped missile ammo object</param>
        public virtual void UpdateAmmoAfterLaunch(WorldObject ammo)
        {
            // hide previously held ammo
            EnqueueBroadcast(new GameMessagePickupEvent(ammo));

            if (ammo.StackSize == 1)
            {
                TryUnwieldObjectWithBroadcasting(ammo.Guid, out _, out _);
                ammo.Destroy();
            }
            else
            {
                ammo.SetStackSize(ammo.StackSize - 1);
                EnqueueBroadcast(new GameMessageSetStackSize(ammo));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the ammo count or destroys the ammo after launching the projectile.
        /// </summary>
        /// <param name="ammo">The equipped missile ammo object</param>
        public void UpdateAmmoAfterLaunch(WorldObject ammo)
        {
            ammo.SetStackSize(ammo.StackSize - 1);

            if (ammo.StackSize == 0)
            {
                if (this is Player player)
                {
                    player.TryDequipObjectWithNetworking(ammo.Guid, out _, Player.DequipObjectAction.ConsumeItem);
                }
                else
                {
                    TryUnwieldObjectWithBroadcasting(ammo.Guid, out _, out _);
                    ammo.Destroy();
                }
            }
            else
            {
                EnqueueBroadcast(new GameMessagePickupEvent(ammo), new GameMessageSetStackSize(ammo));
            }
        }