fBaseXtensions.Game.GameCache.GetInteractiveCachedObject C# (CSharp) Method

GetInteractiveCachedObject() private method

private GetInteractiveCachedObject ( Profile type ) : CacheObject
type Profile
return fBaseXtensions.Cache.Internal.Objects.CacheObject
        internal CacheObject GetInteractiveCachedObject(Profile.ProfileBehaviorTypes type)
        {
            if (type == Profile.ProfileBehaviorTypes.UseWaypoint)
            {
                UseWaypointTag tagWP = (UseWaypointTag)FunkyGame.Profile.CurrentProfileBehavior;
                var WaypointObjects = ObjectCache.InteractableObjectCache.Values.Where(obj => obj.SNOID == 6442);
                foreach (CacheObject item in WaypointObjects)
                {
                    if (item.Position.Distance(tagWP.Position) < 100f)
                    {
                        //Found matching waypoint object!
                        return item;
                    }
                }
            }
            else if (type == Profile.ProfileBehaviorTypes.UseObject)
            {
                UseObjectTag tagUseObj = (UseObjectTag)FunkyGame.Profile.CurrentProfileBehavior;
                if (tagUseObj.ActorId > 0)
                {//Using SNOID..
                    var Objects = ObjectCache.InteractableObjectCache.Values.Where(obj => obj.SNOID == tagUseObj.ActorId);
                    foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(FunkyGame.Hero.Position)))
                    {
                        //Found matching object!
                        return item;
                    }

                }
                else
                {//use position to match object
                    Vector3 tagPosition = tagUseObj.Position;
                    var Objects = ObjectCache.InteractableObjectCache.Values.Where(obj => obj.Position.Distance(tagPosition) <= 100f);
                    foreach (CacheObject item in Objects)
                    {
                        //Found matching object!
                        return item;
                    }
                }
            }
            else if (type == Profile.ProfileBehaviorTypes.UsePortal)
            {
                UsePortalTag tagUsePortal = (UsePortalTag)FunkyGame.Profile.CurrentProfileBehavior;
                if (tagUsePortal.ActorId > 0)
                {//Using SNOID..
                    var Objects = ObjectCache.InteractableObjectCache.Values.Where(obj => obj.SNOID == tagUsePortal.ActorId);
                    foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(FunkyGame.Hero.Position)))
                    {
                        //Found matching object!
                        return item;
                    }

                }
                else
                {//use position to match object
                    Vector3 tagPosition = tagUsePortal.Position;
                    var Objects = ObjectCache.InteractableObjectCache.Values.Where(obj => obj.Position.Distance(tagPosition) <= 100f);
                    foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(FunkyGame.Hero.Position)))
                    {
                        //Found matching object!
                        return item;
                    }
                }
            }

            return null;
        }