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; }
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()); }
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); }
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); }
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); }
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); }
public PotionEffectType GetEffectType() { return(PotionEffectType.GetById(this.Id)); }
public PotionEffect(PotionEffectType type, int duration, int amplifier) : this(type, duration, amplifier, true) { }