コード例 #1
0
 /// <summary>Tests whether another draw context is identical to this one</summary>
 /// <param name="otherContext">Other context to check for equality</param>
 /// <returns>True if the other context is identical to this one</returns>
 public override bool Equals(DrawContext otherContext) {
   return ReferenceEquals(this, otherContext);
 }
コード例 #2
0
    /// <summary>Tests whether another draw context is identical to this one</summary>
    /// <param name="otherContext">Other context to check for equality</param>
    /// <returns>True if the other context is identical to this one</returns>
    /// <remarks>
    ///   Classes deriving from the EffectDrawContext should override this method
    ///   and do their own comparison - for example, two drawing contexts might
    ///   use the same effect instance, but apply different effect parameters before
    ///   rendering - in that case, an additional comparison of the draw context's
    ///   own settings needs to be performed here.
    /// </remarks>
    public override bool Equals(DrawContext otherContext) {
      EffectDrawContext other = otherContext as EffectDrawContext;
      if(other == null)
        return false;

      Effect thisEffect = this.effect;
      Effect otherEffect = other.effect;

      // If the same effect instance is behind the other class, we can be sure that
      // the effects are identical. Derived clases should override this method,
      // otherwise, instance using the same effect but with different effect parameters
      // would be compared as equal in this line. If on the other hand, the effect
      // draw context is used directly, this comparison is what we want!
      if(ReferenceEquals(thisEffect, otherEffect))
        return true;

      // Short cut didn't work, compare the effects member by member
      return CompareEffectParameters(otherEffect);
    }
コード例 #3
0
ファイル: DrawContext.cs プロジェクト: pr0gramm3r1/AngryTanks
 /// <summary>Tests whether another draw context is identical to this one</summary>
 /// <param name="otherContext">Other context to check for equality</param>
 /// <returns>True if the other context is identical to this one</returns>
 public abstract bool Equals(DrawContext otherContext);
コード例 #4
0
    /// <summary>Tests whether another draw context is identical to this one</summary>
    /// <param name="otherContext">Other context to check for equality</param>
    /// <returns>True if the other context is identical to this one</returns>
    public override bool Equals(DrawContext otherContext) {
      TextDrawContext other = otherContext as TextDrawContext;
      if(other == null)
        return false;

      Effect thisEffect = this.effect;
      Effect otherEffect = other.effect;

      // If the same effect instances are different, we stop comparing right here.
      // This context is specialized to run the same effect in multiple configurations,
      // different effects with identical settings will not happen due to its usage.
      if(!ReferenceEquals(thisEffect, otherEffect))
        return false;

      // It's the same effect instance, so compare the configuration we're assigning
      // to the effect before each drawing cycle
      return
        (this.textColor == other.textColor) &&
        (this.transform == other.transform);
    }