/// <summary> /// Access a contained field by name. Forwards to the field accessor. /// </summary> /// <param name="fieldName">The field to access</param> /// <returns>Field value</returns> public object this[string fieldName] { get { object res = null; if (CachedValues.TryGetValue(fieldName, out res)) { return(res); } res = Accessor.GetValue(InnerItem, fieldName); CachedValues[fieldName] = res; return(res); } set { if (Accessor.GetValue(InnerItem, fieldName) != value) { CachedValues[fieldName] = value; Accessor.SetValue(InnerItem, fieldName, value); if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(fieldName)); } } } }
internal float Get(GameObject from, GameObject target) { if (IsDisposing) { return(0); } Tuple <float, float> output; if (CachedValues.TryGetValue(new KeyValuePair <int, int>(from.NetworkId, target.NetworkId), out output)) { if (Game.Time * 1000 - output.Item1 < RefreshRate) { return(output.Item2); } CachedValues[new KeyValuePair <int, int>(from.NetworkId, target.NetworkId)] = new Tuple <float, float>( Game.Time * 1000, from.Distance(target)); } else { CachedValues[new KeyValuePair <int, int>(from.NetworkId, target.NetworkId)] = new Tuple <float, float>( Game.Time * 1000, from.Distance(target)); } return(CachedValues[new KeyValuePair <int, int>(from.NetworkId, target.NetworkId)].Item2); }
internal bool Get(GameObject from, GameObject target, float range) { if (IsDisposing) { return(false); } Tuple <float, bool> output; if (CachedValues.TryGetValue(new Tuple <int, int, float>(from.NetworkId, target.NetworkId, range), out output)) { if (Game.Time * 1000 - output.Item1 < RefreshRate) { return(output.Item2); } CachedValues[new Tuple <int, int, float>(from.NetworkId, target.NetworkId, range)] = new Tuple <float, bool>( Game.Time * 1000, from.IsInRange(target, range)); } else { CachedValues[new Tuple <int, int, float>(from.NetworkId, target.NetworkId, range)] = new Tuple <float, bool>( Game.Time * 1000, from.IsInRange(target, range)); } return(CachedValues[new Tuple <int, int, float>(from.NetworkId, target.NetworkId, range)].Item2); }