/// <inheritdoc/> public void Add(TKey key, TValue value) { Contract.Require(key, nameof(key)); var weakKey = new WeakKeyReference <TKey>(key, this.comparer); var weakVal = WeakReference <TValue> .Create(value); this.dictionary.Add(weakKey, weakVal); }
protected override bool TickCore(RealmTime time) { if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) { return(true); } var speed = this.speed * GetSpeedMultiplier(Host.Self); CirclingState state; object o; if (!Host.StateStorage.TryGetValue(Key, out o)) { float dist = sight; Host.StateStorage[Key] = state = new CirclingState() { target = WeakReference <Entity> .Create(GetNearestEntity(ref dist, objType)), angle = (float)(2 * Math.PI * rand.NextDouble()) }; } else { state = (CirclingState)o; state.angle += angularSpeed * (time.thisTickTimes / 1000f); if (!state.target.IsAlive) { Host.StateStorage.Remove(Key); return(false); } var target = state.target.Target; if (target == null || target.Owner == null) { Host.StateStorage.Remove(Key); return(false); } double x = target.X + Math.Cos(state.angle) * radius; double y = target.Y + Math.Sin(state.angle) * radius; if (x != Host.Self.X || y != Host.Self.Y) { Vector2 vect = new Vector2((float)x, (float)y) - new Vector2(Host.Self.X, Host.Self.Y); vect.Normalize(); vect *= (speed / 1.5f) * (time.thisTickTimes / 1000f); ValidateAndMove(Host.Self.X + vect.X, Host.Self.Y + vect.Y); Host.Self.UpdateCount++; } } if (state.angle >= Math.PI * 2) { state.angle -= (float)(Math.PI * 2); } return(true); }
public override void Add(TKey key, TValue value) { if (key == null) { throw new ArgumentNullException("key"); } WeakReference <TKey> weakKey = new WeakKeyReference <TKey>(key, this.comparer); WeakReference <TValue> weakValue = WeakReference <TValue> .Create(value); this.dictionary.Add(weakKey, weakValue); }
protected override bool TickCore(RealmTime time) { if (Host.Self.HasConditionEffect(ConditionEffects.Paralyzed)) { return(true); } float speed = this.speed * GetSpeedMultiplier(Host.Self); CirclingState state; object o; if (!Host.StateStorage.TryGetValue(Key, out o)) { float dist = radius + 1; double SP = startPercent; Host.StateStorage[Key] = state = new CirclingState { target = WeakReference <Entity> .Create(GetNearestEntity(ref dist, objType)), angle = (float)(2 * Math.PI * SP) }; } else { state = (CirclingState)o; state.angle += angularSpeed * (time.thisTickTimes / 1000f); if (!state.target.IsAlive) { Host.StateStorage.Remove(Key); return(false); } Entity target = state.target.Target; if (target == null || target.Owner == null) { Host.StateStorage.Remove(Key); return(false); } double x = target.X + Math.Cos(state.angle) * radius; double y = target.Y + Math.Sin(state.angle) * radius; ValidateAndMove((float)x, (float)y); Host.Self.UpdateCount++; } if (state.angle >= Math.PI * 2) { state.angle -= (float)(Math.PI * 2); } return(true); }
/// <inheritdoc/> public TValue this[TKey key] { get { Contract.Require(key, nameof(key)); var weakKey = new WeakKeyReference <TKey>(key, this.comparer); return(this.dictionary[weakKey].Target); } set { Contract.Require(key, nameof(key)); var weakKey = new WeakKeyReference <TKey>(key, this.comparer); this.dictionary[weakKey] = WeakReference <TValue> .Create(value); } }
protected override WeakReference <TKey> WrapKey(TKey key, IEqualityComparer <TKey> comparer) { return(WeakReference <TKey> .Create(key, comparer)); }
protected override void SetValue(TKey key, TValue value) { WeakReference <TKey> weakKey = new WeakKeyReference <TKey>(key, this.comparer); this.dictionary[weakKey] = WeakReference <TValue> .Create(value); }
public void Push(T o) { stack.Push(WeakReference <T> .Create(o, strong)); }
public void Initialize(Texture2D texture) { Original = WeakReference <Texture2D> .Create(texture); }
public void Put(TKey key, TValue value) { mMap[key] = WeakReference <TValue> .Create(value); CullIfNeeded(); }
public void Add(TKey key, TValue value) { mMap.Add(key, WeakReference <TValue> .Create(value)); CullIfNeeded(); }
public void SetOriginal(Texture2D texture) { Original = WeakReference <Texture2D> .Create(texture); }
public void Reset(Texture2D newTexture) { IsTranslated = false; Original = WeakReference <Texture2D> .Create(newTexture); }
protected override WeakReference <TValue> WrapValue(TValue value) { return(WeakReference <TValue> .Create(value)); }
public bool Contains(T o) { return(stack.Contains(WeakReference <T> .Create(o, strong))); }
public TestKey(string message, object weakObject) : this() { Message = message; WeakObject = WeakReference <object> .Create(weakObject); }
public void Enqueue(T o) { queue.Enqueue(WeakReference <T> .Create(o, strong)); }