コード例 #1
0
ファイル: ProfileCache.cs プロジェクト: BUFORD/Funky
        ///<summary>
        ///Tracks Current Profile Behavior and sets IsRunningOOCBehavior depending on the current Type of behavior.
        ///</summary>
        internal void CheckCurrentProfileBehavior()
        {
            if (DateTime.Now.Subtract(LastProfileBehaviorCheck).TotalMilliseconds > 450)
            {
                LastProfileBehaviorCheck = DateTime.Now;

                if (currentProfileBehavior == null ||
                    ProfileManager.CurrentProfileBehavior != null &&
                    ProfileManager.CurrentProfileBehavior.Behavior != null &&
                    currentProfileBehavior.Behavior.Guid != ProfileManager.CurrentProfileBehavior.Behavior.Guid)
                {
                    currentProfileBehavior = ProfileManager.CurrentProfileBehavior;
                    Logger.Write(LogLevel.Event, "Profile Behavior Changed To {0}", currentProfileBehavior.GetType().ToString());

                    Type profileTagType = currentProfileBehavior.GetType();
                    if (oocDBTags.Contains(profileTagType))
                    {
                        if (InteractiveTags.Contains(profileTagType))
                        {
                            ProfileBehaviorIsOOCInteractive = true;
                            Logger.DBLog.DebugFormat("Interactable Profile Tag!");

                            InteractableCachedObject = GetInteractiveCachedObject(currentProfileBehavior);
                            if (InteractableCachedObject != null)
                            {
                                Logger.DBLog.DebugFormat("Found Cached Interactable Server Object");
                            }
                        }
                        else
                        {
                            ProfileBehaviorIsOOCInteractive = false;
                            InteractableCachedObject        = null;
                        }

                        Logger.DBLog.DebugFormat("Current Profile Behavior has enabled OOC Behavior.");
                        IsRunningOOCBehavior = true;
                    }
                    else
                    {
                        ProfileBehaviorIsOOCInteractive = false;
                        InteractableCachedObject        = null;
                        IsRunningOOCBehavior            = false;
                    }
                }
            }
        }
コード例 #2
0
ファイル: ProfileCache.cs プロジェクト: BUFORD/Funky
        internal static CacheObject GetInteractiveCachedObject(ProfileBehavior tag)
        {
            Type TagType = tag.GetType();

            if (InteractiveTags.Contains(TagType))
            {
                if (TagType == typeof(UseWaypointTag))
                {
                    UseWaypointTag tagWP           = (UseWaypointTag)tag;
                    var            WaypointObjects = Bot.Game.Profile.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 (TagType == typeof(UseObjectTag))
                {
                    UseObjectTag tagUseObj = (UseObjectTag)tag;
                    if (tagUseObj.ActorId > 0)
                    {                    //Using SNOID..
                        var Objects = Bot.Game.Profile.InteractableObjectCache.Values.Where(obj => obj.SNOID == tagUseObj.ActorId);
                        foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(Bot.Character.Data.Position)))
                        {
                            //Found matching object!
                            return(item);
                        }
                    }
                    else
                    {                    //use position to match object
                        Vector3 tagPosition = tagUseObj.Position;
                        var     Objects     = Bot.Game.Profile.InteractableObjectCache.Values.Where(obj => obj.Position.Distance(tagPosition) <= 100f);
                        foreach (CacheObject item in Objects)
                        {
                            //Found matching object!
                            return(item);
                        }
                    }
                }
                else if (TagType == typeof(UsePortalTag))
                {
                    UsePortalTag tagUsePortal = (UsePortalTag)tag;
                    if (tagUsePortal.ActorId > 0)
                    {                    //Using SNOID..
                        var Objects = Bot.Game.Profile.InteractableObjectCache.Values.Where(obj => obj.SNOID == tagUsePortal.ActorId);
                        foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(Bot.Character.Data.Position)))
                        {
                            //Found matching object!
                            return(item);
                        }
                    }
                    else
                    {                    //use position to match object
                        Vector3 tagPosition = tagUsePortal.Position;
                        var     Objects     = Bot.Game.Profile.InteractableObjectCache.Values.Where(obj => obj.Position.Distance(tagPosition) <= 100f);
                        foreach (CacheObject item in Objects.OrderBy(obj => obj.Position.Distance(Bot.Character.Data.Position)))
                        {
                            //Found matching object!
                            return(item);
                        }
                    }
                }
            }

            return(null);
        }