コード例 #1
0
        private PointF getAreaScaling()
        {
            if (_drawable?.IgnoreScalingArea ?? false)
            {
                return(NoScaling);
            }
            var room = _room?.Room;

            if (room == null)
            {
                return(NoScaling);
            }

            //Problem: we'd like to always use the world position when checking if the entity is standing
            //in a scaling area. However, the world position is calculated from the bounding box, which
            //in itself is calculated from the matrix, which is calculated here...
            //So at best this will always be in one frame delay, and at worst can cause real scaling jittering issues.
            //So this is why we're checking and in cases the entity doesn't have a parent (which is the vast majority of scenarios)
            //we'll continue using the local coordinates, at least until a better solution is found.
            var position = _tree.TreeNode.Parent == null ? _translate.Position.XY : _worldPosition.WorldXY;

            foreach (IArea area in room.GetMatchingAreas(position, Entity.ID))
            {
                IScalingArea scaleArea = area.GetComponent <IScalingArea>();
                if (scaleArea == null || (!scaleArea.ScaleObjectsX && !scaleArea.ScaleObjectsY))
                {
                    continue;
                }
                float scale = scaleArea.GetScaling(scaleArea.Axis == ScalingAxis.X ? position.X : position.Y);
                return(new PointF(scaleArea.ScaleObjectsX ? scale : 1f, scaleArea.ScaleObjectsY ? scale : 1f));
            }
            return(NoScaling);
        }
コード例 #2
0
 private PointF getAreaScaling()
 {
     if (_drawable.IgnoreScalingArea)
     {
         return(NoScaling);
     }
     foreach (IArea area in _room.Room.GetMatchingAreas(_translate.Location.XY, _entity.ID))
     {
         IScalingArea scaleArea = area.GetComponent <IScalingArea>();
         if (scaleArea == null || (!scaleArea.ScaleObjectsX && !scaleArea.ScaleObjectsY))
         {
             continue;
         }
         float scale = scaleArea.GetScaling(scaleArea.Axis == ScalingAxis.X ? _translate.X : _translate.Y);
         return(new PointF(scaleArea.ScaleObjectsX ? scale : 1f, scaleArea.ScaleObjectsY ? scale : 1f));
     }
     return(NoScaling);
 }