Beispiel #1
0
		public static Packet AddRegen(this Packet packet, StatRegen regen)
		{
			packet.PutInt(regen.Id);

			// It makes more sense for us to *increase* the hunger, but the
			// client wants to *decrease* the amount of available Stamina.
			packet.PutFloat(regen.Stat != Stat.Hunger ? regen.Change : -regen.Change);

			packet.PutInt(regen.TimeLeft);
			packet.PutInt((int)regen.Stat);
			packet.PutByte(0); // ?
			packet.PutFloat(regen.Max);

			return packet;
		}
Beispiel #2
0
        /// <summary>
        /// Adds regen and returns the new object.
        /// Sends stat update.
        /// </summary>
        /// <param name="stat"></param>
        /// <param name="change"></param>
        /// <param name="max"></param>
        /// <param name="duration">Duration in milliseconds, -1 (default) for constant.</param>
        /// <returns></returns>
        public StatRegen Add(Stat stat, float change, float max, int duration = -1)
        {
            var regen = new StatRegen(stat, change, max, duration);

            lock (_regens)
                _regens.Add(regen.Id, regen);

            // Only send updates if the creature is actually in-game already.
            if (this.Creature.Region != Region.Limbo)
            {
                Send.NewRegens(this.Creature, StatUpdateType.Private, regen);
                if (regen.Stat >= Stat.Life && regen.Stat <= Stat.LifeMaxMod)
                    Send.NewRegens(this.Creature, StatUpdateType.Public, regen);
            }

            return regen;
        }
Beispiel #3
0
        /// <summary>
        /// Adds regen and returns the new object.
        /// Sends stat update.
        /// </summary>
        /// <param name="stat"></param>
        /// <param name="change"></param>
        /// <param name="max"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public StatRegen Add(Stat stat, float change, float max, int duration = -1)
        {
            var regen = new StatRegen(stat, change, max, duration);

            lock (_regens)
                _regens.Add(regen.Id, regen);

            // Only send updates if the creature is actually in-game already.
            if (this.Creature.Region != null)
            {
                Send.NewRegens(this.Creature, StatUpdateType.Private, regen);
                if (regen.Stat >= Stat.Life && regen.Stat <= Stat.LifeMaxMod)
                {
                    Send.NewRegens(this.Creature, StatUpdateType.Public, regen);
                }
            }

            return(regen);
        }
Beispiel #4
0
 /// <summary>
 /// Removes regen by id, returns false if regen didn't exist.
 /// Sends stat update if successful.
 /// </summary>
 /// <param name="regen"></param>
 /// <returns></returns>
 public bool Remove(StatRegen regen)
 {
     return(this.Remove(regen.Id));
 }
Beispiel #5
0
 /// <summary>
 /// Removes regen by id, returns false if regen didn't exist.
 /// Sends stat update if successful.
 /// </summary>
 /// <param name="regen"></param>
 /// <returns></returns>
 public bool Remove(StatRegen regen)
 {
     return this.Remove(regen.Id);
 }