コード例 #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;
 }
コード例 #2
0
ファイル: PotionType.cs プロジェクト: Mitch528/BukkitNET
        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());
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: PotionType.cs プロジェクト: Mitch528/BukkitNET
        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);
        }
コード例 #7
0
 public PotionEffectType GetEffectType()
 {
     return(PotionEffectType.GetById(this.Id));
 }
コード例 #8
0
 public PotionEffect(PotionEffectType type, int duration, int amplifier)
     : this(type, duration, amplifier, true)
 {
 }