Beispiel #1
0
        /// <summary>
        /// Drops candies from the bag.
        /// </summary>
        /// <param name="type">The <see cref="CandyKindID"/> type sof candies to drop.</param>
        /// <param name="dropAll">Whether or not to drop all candies matching the given type, or just one.</param>
        /// <param name="dropIndividual">Whether or not to drop all candies individually, or as a bag, when dropping more than one candy.</param>
        /// <param name="overrideExposedType">Whether or not to override the exposed type of the candy dropped.</param>
        /// <param name="exposedType">The <see cref="ExposedType"/> to use, if the override is set to true.</param>
        /// <returns>a <see cref="List{T}"/> of pickups generated by this method. *Can be empty!*.</returns>
        public List <Pickup> DropCandy(CandyKindID type, bool dropAll = false, bool dropIndividual = false, bool overrideExposedType = false, CandyKindID exposedType = CandyKindID.None)
        {
            int count = 0;

            for (int i = 0; i < Base.Candies.Count; i++)
            {
                if (Base.Candies[i] == type)
                {
                    count++;

                    if (!dropAll)
                    {
                        break;
                    }
                }
            }

            List <Pickup> pickups = new List <Pickup>();

            if (count > 1 && !dropIndividual)
            {
                Scp330Pickup ipb = (Scp330Pickup)Object.Instantiate(Base.PickupDropModel, Owner.Position, default);
                ipb.NetworkExposedCandy = overrideExposedType ? exposedType : CandyKindID.None;
                for (int i = 0; i < count; i++)
                {
                    ipb.StoredCandies.Add(type);
                }
                NetworkServer.Spawn(ipb.gameObject);
                ipb.InfoReceived(default, Base.PickupDropModel.NetworkInfo);
Beispiel #2
0
 /// <summary>
 /// Adds a specific candy to the bag.
 /// </summary>
 /// <param name="type">The <see cref="CandyKindID"/> to add.</param>
 public void AddCandy(CandyKindID type)
 {
     if (Base.TryAddSpecific(type))
     {
         Base.ServerRefreshBag();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Adds a specific candy to the bag.
        /// </summary>
        /// <param name="type">The <see cref="CandyKindID"/> to add.</param>
        /// <returns><see langword="true"/> if the candy was successfully added to the bag; otherwise, <see langword="false"/>.</returns>
        public bool AddCandy(CandyKindID type)
        {
            if (Base.TryAddSpecific(type))
            {
                Base.ServerRefreshBag();
                return(true);
            }

            return(false);
        }
Beispiel #4
0
 /// <summary>
 /// Removes a specific candy from the bag.
 /// </summary>
 /// <param name="type">The <see cref="CandyKindID"/> to be removed.</param>
 /// <param name="removeAll">Whether or not to only remove all matching candy. (If true, all candies of the given type are removed).</param>
 public void RemoveCandy(CandyKindID type, bool removeAll = false)
 {
     while (Base.Candies.Contains(type))
     {
         Base.TryRemove(Base.Candies.IndexOf(type));
         if (!removeAll)
         {
             break;
         }
     }
 }
Beispiel #5
0
        /// <summary>
        /// Removes a specific candy from the bag.
        /// </summary>
        /// <param name="type">The <see cref="CandyKindID"/> to be removed.</param>
        /// <param name="removeAll">Whether or not to only remove all matching candy. (If <see langword="true"/>, all candies of the given type are removed).</param>
        /// <returns>The total amount of candies that were dropped from the bag.</returns>
        public int RemoveCandy(CandyKindID type, bool removeAll = false)
        {
            int amount = 0;

            while (Base.Candies.Contains(type))
            {
                Base.TryRemove(Base.Candies.IndexOf(type));
                amount++;
                if (!removeAll)
                {
                    break;
                }
            }

            return(amount);
        }