Example #1
0
        public static TweenerHolder Tween(this PositionedObject positionedObject, string memberToSet)
        {
            TweenerHolder toReturn = new TweenerHolder();

            toReturn.Caller = positionedObject;
            toReturn.Tween(memberToSet);
            return(toReturn);
        }
Example #2
0
        public static TweenerHolder Tween(this PositionedObject positionedObject, string property, float to,
                                          float during, InterpolationType interpolation, Easing easing)
        {
            TweenerHolder toReturn = new TweenerHolder();

            toReturn.Caller = positionedObject;
            toReturn.Tween(property, to, during, interpolation, easing);
            return(toReturn);
        }
Example #3
0
 public static Tweener Tween(this PositionedObject positionedObject, string property, float to,
                             float during, InterpolationType interpolation, Easing easing)
 {
     // let's to handle the most common properties without making a TweenerHolder and without using reflection:
     if (property == nameof(PositionedObject.X))
     {
         // We use closures to reference the PO which does cause allocation, but it's not as bad
         // as the every-frame allocation that occurs when setting a property through reflection. Maybe
         // one day we can get rid of this, but this should make some improvements:
         return(positionedObject.Tween((value) => positionedObject.X = value, positionedObject.X, to, during, interpolation, easing));
     }
     else if (property == nameof(PositionedObject.Y))
     {
         return(positionedObject.Tween((value) => positionedObject.Y = value, positionedObject.Y, to, during, interpolation, easing));
     }
     else if (property == nameof(PositionedObject.Z))
     {
         return(positionedObject.Tween((value) => positionedObject.Z = value, positionedObject.Z, to, during, interpolation, easing));
     }
     if (property == nameof(PositionedObject.RelativeX))
     {
         return(positionedObject.Tween((value) => positionedObject.RelativeX = value, positionedObject.RelativeX, to, during, interpolation, easing));
     }
     else if (property == nameof(PositionedObject.RelativeY))
     {
         return(positionedObject.Tween((value) => positionedObject.RelativeY = value, positionedObject.RelativeY, to, during, interpolation, easing));
     }
     else if (property == nameof(PositionedObject.RelativeZ))
     {
         return(positionedObject.Tween((value) => positionedObject.RelativeZ = value, positionedObject.RelativeZ, to, during, interpolation, easing));
     }
     else
     {
         // If the most common properties aren't handled, then we'll fall back to the old method. The user can still mimic the code above
         // to avoid using a TweenerHolder for better performance.
         TweenerHolder toReturn = new TweenerHolder();
         toReturn.Caller = positionedObject;
         return(toReturn.Tween(property, to, during, interpolation, easing));
     }
 }
 public static TweenerHolder Tween(this PositionedObject positionedObject, string memberToSet)
 {
     TweenerHolder toReturn = new TweenerHolder();
     toReturn.Caller = positionedObject;
     toReturn.Tween(memberToSet);
     return toReturn;
 }