Ejemplo n.º 1
0
 public PotionEffect(PotionEffectType type, int duration, int amplifier, bool ambient)
 {
     Debug.Assert(type != null, "effect type cannot be null");
     this.type      = type;
     this.duration  = duration;
     this.amplifier = amplifier;
     this.ambient   = ambient;
 }
Ejemplo n.º 2
0
        public static bool IsInstant(this PotionType type)
        {
            var attrib = type.GetAttribute <PotionTypeInfoAttribute>();
            var effect = attrib.Effect;

            var et = PotionEffectType.GetById(effect);

            return(et == null || et.IsInstant());
        }
Ejemplo n.º 3
0
        private static PotionEffectType GetEffectType <TKey, TValue>(Dictionary <TKey, TValue> map)
        {
            int type = GetInt(map, TYPE);
            PotionEffectType effect = PotionEffectType.GetById(type);

            if (effect != null)
            {
                return(effect);
            }
            throw new Exception(map + " does not contain " + TYPE);
        }
Ejemplo n.º 4
0
        public static void RegisterPotionEffectType(PotionEffectType type)
        {
            if (byId[type.id] != null || byName.ContainsKey(type.GetName().ToLower()))
            {
                throw new ArgumentException("Cannot set already-set type");
            }
            else if (!acceptingNew)
            {
                throw new Exception(
                          "No longer accepting new potion effect types (can only be done by the server implementation)");
            }

            byId[type.id] = type;
            byName.Add(type.GetName().ToLower(), type);
        }
Ejemplo n.º 5
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is PotionEffectType))
            {
                return(false);
            }
            PotionEffectType other = (PotionEffectType)obj;

            if (this.id != other.id)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 6
0
        public static PotionType GetByEffect(PotionEffectType effect)
        {
            if (effect == null)
            {
                return(PotionType.Water);
            }

            var vals = Enum.GetValues(typeof(PotionType));

            foreach (PotionType t in vals)
            {
                var attrib = t.GetAttribute <PotionTypeInfoAttribute>();

                if (PotionEffectType.GetById(attrib.Effect).Equals(effect))
                {
                    return(t);
                }
            }

            return(PotionType.Water);
        }
Ejemplo n.º 7
0
 public PotionEffectType GetEffectType()
 {
     return(PotionEffectType.GetById(this.Id));
 }
Ejemplo n.º 8
0
 public PotionEffect(PotionEffectType type, int duration, int amplifier)
     : this(type, duration, amplifier, true)
 {
 }